Skip to content

Fix PathPatternNode wildcard cache lifecycle - #18672

Merged
jt2594838 merged 1 commit into
apache:masterfrom
Caideyipi:fix-path-pattern-node-wildcard-cache
Sep 21, 2026
Merged

jt2594838 merged 1 commit into
apache:masterfrom
Caideyipi:fix-path-pattern-node-wildcard-cache

Conversation

@Caideyipi

@Caideyipi Caideyipi commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Description

PathPatternNode used to retain non-trivial wildcard child names and compile a regular expression on every match. This change caches the compiled Pattern objects instead.

  • Compile each non-trivial wildcard pattern when the child is added.
  • Reuse the compiled pattern in getMatchChildren.
  • Remove cached patterns when children are deleted or cleared, including replacement of an existing wildcard child.
  • Include the compiled-pattern cache in memory estimation.
  • Reuse the same compilation helper from PathPatternUtil.isNodeMatch.

Testing

mvn spotless:apply -pl iotdb-core/node-commons
mvn -pl iotdb-core/node-commons -Dtest=PathPatternNodeTest test

Result: BUILD SUCCESS; 2 tests passed. Checkstyle and Spotless checks passed.


This PR has:

  • been self-reviewed.
  • added comments explaining the intent of the cache.
  • added unit tests covering wildcard-cache add, replacement, deletion, and clear paths.

Key changed/added classes
  • PathPatternNode
  • PathPatternUtil
  • PathPatternNodeTest

Local benchmark results

The follow-up benchmark from #18685 was run against the cached implementation from merge commit 9be80ead1dc and an in-test reproduction of the pre-change compile-on-every-match path. Environment: Windows 11 (build 26200), JDK 17.0.15, Intel Core i9-13900H, 2026-09-21. Each result is the median over 7 rounds after 2,000 warmup lookups; each round performed 20,000 lookups over 1,000 distinct queries.

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
wildcard children pre-change (ns/lookup) cached (ns/lookup) pre-change (lookups/s) cached (lookups/s) speedup latency reduction
1 1,217.7 205.0 821,207 4,879,239 5.94x 83.17%
10 1,767.5 348.5 565,787 2,869,193 5.07x 80.28%
100 16,148.7 2,800.8 61,925 357,039 5.77x 82.66%

The pre-change column is deliberately implemented inside the benchmark for an apples-to-apples comparison; it is not a separately built old binary. The cached implementation is about 5-6x faster in this workload, with 80-83% lower lookup latency. The targeted Maven run passed (1 test, 0 failures; Checkstyle, Spotless, compilation, and Surefire all passed).

@jt2594838
jt2594838 merged commit 9be80ea into apache:master Sep 21, 2026
58 of 60 checks passed
@Caideyipi
Caideyipi deleted the fix-path-pattern-node-wildcard-cache branch September 21, 2026 03:12
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.

2 participants