Skip to content

Add PathPatternNode wildcard cache benchmark - #18685

Open
Caideyipi wants to merge 2 commits into
apache:masterfrom
Caideyipi:perf/path-pattern-node-cache-benchmark
Open

Caideyipi wants to merge 2 commits into
apache:masterfrom
Caideyipi:perf/path-pattern-node-cache-benchmark

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds an opt-in microbenchmark for the compiled non-trivial wildcard cache introduced by #18672.

  • Reproduces the pre-change compile-on-every-match path.
  • Compares it with PathPatternNode.getMatchChildren, alternating execution order by round.
  • Checks that both paths return the same number of matches.
  • Reports median latency, throughput, speedup, and latency reduction for configurable wildcard counts.
  • Stays skipped in normal UT runs unless -Diotdb.path.pattern.node.perf.enabled=true is set.

Example:

mvn -pl iotdb-core/node-commons -Dtest=PathPatternNodePerformanceTest -Diotdb.path.pattern.node.perf.enabled=true test

The workload can be tuned with the iotdb.path.pattern.node.perf.* system properties documented by the test skip message.

Local benchmark results

Run on 2026-09-21 with Windows 11 (build 26200), JDK 17.0.15, and an Intel Core i9-13900H. The command used for both revisions was:

mvn -pl iotdb-core/node-commons -Dtest=PathPatternNodePerformanceTest -Diotdb.path.pattern.node.perf.enabled=true -Diotdb.path.pattern.node.perf.wildcard-counts=1,10,100 -Diotdb.path.pattern.node.perf.query-count=1000 -Diotdb.path.pattern.node.perf.warmup-lookups=2000 -Diotdb.path.pattern.node.perf.lookups=20000 -Diotdb.path.pattern.node.perf.rounds=7 test

The PR base is 9be80ead1dc (the #18672 cache implementation); the PR head is e78adaf878e. The benchmark's legacy column emulates the pre-#18672 implementation, while the cached column calls PathPatternNode.getMatchChildren:

wildcard children pre-#18672 path (ns/lookup) cached path (ns/lookup) cached throughput (lookups/s) speedup latency reduction
1 1,217.7 205.0 4,879,239 5.94x 83.17%
10 1,767.5 348.5 2,869,193 5.07x 80.28%
100 16,148.7 2,800.8 357,039 5.77x 82.66%

For the cached path alone, the same run on the PR base versus the PR head was:

wildcard children base 9be80ead1dc (ns/lookup) head e78adaf878e (ns/lookup) head vs. base
1 198.7 205.0 +3.2%
10 291.9 348.5 +19.4%
100 2,684.4 2,800.8 +4.3%

#18685 only adds the benchmark test (the two-line OPC UA reference cleanup in the head is unrelated to PathPatternNode); the base/head differences above are single-run microbenchmark noise, not a production-path change. The signal is the comparison against the emulated pre-#18672 path: about 5-6x higher throughput and 80-83% lower lookup latency with the compiled-pattern cache.

Testing

  • mvn spotless:apply -pl iotdb-core/node-commons - passed.
  • Targeted PathPatternNodePerformanceTest with the command above - passed on the PR head (1 test, 0 failures).
  • The same benchmark passed on a temporary worktree at the PR base; the benchmark source and the head's two-line OPC UA reference cleanup were applied there only to bypass an unrelated compile issue.
  • Checkstyle, Spotless, compilation, and Surefire phases in the targeted Maven run - passed.

This PR has:

  • been self-reviewed.
  • added comments explaining the benchmark intent.
  • kept the performance test disabled during regular unit-test runs.

Key changed/added classes
  • PathPatternNodePerformanceTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant