Skip to content

perf: optimize StateSet.equals to eliminate heap allocations during a…#16414

Open
rajat315315 wants to merge 2 commits into
apache:mainfrom
rajat315315:opt/NFA_to_DFA_IntSet_optimization
Open

perf: optimize StateSet.equals to eliminate heap allocations during a…#16414
rajat315315 wants to merge 2 commits into
apache:mainfrom
rajat315315:opt/NFA_to_DFA_IntSet_optimization

Conversation

@rajat315315

@rajat315315 rajat315315 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Closes: #16413

📊 Benchmark & GC Allocation Metrics

Evaluated using ThreadMXBean.getThreadAllocatedBytes() and GarbageCollectorMXBean across 30 determinization runs on complex NFA union automata (1,000 regex terms with overlapping state sets):

GC / Memory Metric Baseline (Before Optimization) Optimized (Option C) Improvement / Reduction
Total Heap Memory Allocated (30 runs) 548.72 MB 100.42 MB 81.7% reduction (~448.3 MB saved!)
Avg Heap Allocated per determinize() 18.29 MB (19,179,268 bytes) 3.35 MB (3,510,065 bytes) Saved ~14.94 MB of garbage per call!
GC Collection Cycles 11 GC cycles 2 GC cycles 81.8% reduction in GC pauses
Total GC Pause Time 142 ms 25 ms 82.4% reduction in GC pause duration
Average Execution Time 140.43 ms 76.30 ms ~1.84x faster execution speed

…utomaton determinization and add performance benchmarks.
@rajat315315

rajat315315 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Attaching the Benchmark file used to generate the results.
TestDeterminizeBenchmark.java

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Optimize StateSet.equals to avoid array allocation and sorting in Operations.determinize()

1 participant