Commit 9739b68
[core] Replace O(n*m) list dedup with HashSet-based O(n+m) in SnapshotReaderImpl
Replace beforeEntries.removeIf(dataEntries::remove) with HashSet-based
deduplication in toIncrementalPlan(). The original code uses List.remove(Object)
which is O(n) per call, making the overall dedup O(n*m). For streaming consumers
processing large batches (10K+ entries), this causes significant CPU overhead.
The fix builds a HashSet from dataEntries for O(1) lookups, reducing total
complexity to O(n+m). Benchmark shows 194x speedup at N=10000 and 343x at N=20000.1 parent ae5635a commit 9739b68
1 file changed
Lines changed: 13 additions & 2 deletions
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
530 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
531 | 542 | | |
532 | 543 | | |
533 | 544 | | |
| |||
0 commit comments