Commit 5ded812
Cut symbol-dict overhead and fix two blind guards
Five review findings on the delta symbol dictionary. The three performance
ones all sit on paths that scale with symbol cardinality -- the workload
this feature exists for introduces a new symbol per ROW -- and the two
guards were pinning nothing.
RecoveredFrameAnalysis.foldDelta issued one bounds check, one capacity
check and a ~12-byte copyMemory per SYMBOL. runningCoverage is
loop-invariant (it only advances after the walk) and id ascends, so
"id >= runningCoverage" is a step predicate: the entries a frame
contributes are always ONE contiguous run at the tail of its delta
section. Note where the run starts and copy it once. Recovery walks the
whole backlog, so this traded millions of stub-dispatched small copies for
one bulk copy per frame. It also drops the partial prefix the per-entry
version left behind on a markGap bail-out; that residue was already
unreachable (a gap pins coverage() at -1, and a later self-sufficient
frame resets the buffer), so not writing it is equivalent and leaves less
state to reason about. accumulateSentDict already solved the same problem
this way one file over.
Crc32c.updateUnsafe read each 8-byte slice-by-8 block with eight getByte
calls: 16 loads per block where 9 do. Consume it with two getInt loads.
getInt is an Unsafe intrinsic exactly as getByte is, so the catchable
InternalError this method exists for is unaffected; the loop becomes
little-endian, which costs nothing because the formats it checksums are
already little-endian throughout. This is the whole recovery CRC. The
differential test against the native intrinsic (8 alignments x 28 lengths
x 3 seeds, plus the chaining fuzz) proves it bit-identical.
The sent-dict entry-ends index was maintained incrementally by
accumulateSentDict and built eagerly by the constructor, yet
sendDictCatchUp is its ONLY reader. That put a store per new symbol on the
per-frame I/O path and retained 4 bytes per symbol for the connection's
whole life, to serve a reconnect that may never come. Build it lazily
instead: ensureSentDictEntryIndex() already notices sentDictIndexedCount
falling behind and rebuilds, at most once per reconnect, dwarfed by
shipping the same bytes over the wire. A connection that never reconnects
no longer allocates the index at all.
testCtorFreesSeededMirrorWhenFrameSeedThrows could not fail. The seam
threw BEFORE ensureSentDictCapacity -- the call that copy-on-writes the
borrowed prefix into a loop-OWNED allocation -- so the cleanup it guards,
gated on sentDictBytesOwned, freed nothing. Deleting that cleanup left the
test green. Move the seam past the grow: deleting the cleanup now fails
with a 4096-byte NATIVE_DEFAULT leak. The test's premise comment described
the old copy-based design and is corrected.
testPersistFailureSurfacesAsLineSenderException drove code production
never runs. FilesFacade.isMmapAllowed() defaults to (this == INSTANCE), so
installing any fault facade silently swapped the dictionary onto the
positioned-write fallback -- the act of injecting the fault replaced the
code under test. Fault a refused ff.allocate on the mmap append window
instead, with the facade opting into isMmapAllowed(): that is both the
real shape of ENOSPC here and the path production takes. Reverting the
wrap now escapes as "could not grow mmap append region", from the mapped
path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 68aa31a commit 5ded812
7 files changed
Lines changed: 155 additions & 78 deletions
File tree
- core/src
- main/java/io/questdb/client
- cutlass/qwp/client
- sf/cursor
- std
- test/java/io/questdb/client/test/cutlass/qwp/client
- sf/cursor
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3905 | 3905 | | |
3906 | 3906 | | |
3907 | 3907 | | |
3908 | | - | |
3909 | | - | |
3910 | | - | |
3911 | | - | |
3912 | | - | |
3913 | | - | |
3914 | | - | |
3915 | | - | |
3916 | | - | |
| 3908 | + | |
| 3909 | + | |
| 3910 | + | |
| 3911 | + | |
| 3912 | + | |
| 3913 | + | |
| 3914 | + | |
| 3915 | + | |
| 3916 | + | |
| 3917 | + | |
3917 | 3918 | | |
3918 | 3919 | | |
3919 | 3920 | | |
| |||
Lines changed: 33 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
| |||
784 | 786 | | |
785 | 787 | | |
786 | 788 | | |
| 789 | + | |
787 | 790 | | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
788 | 799 | | |
789 | 800 | | |
790 | 801 | | |
791 | | - | |
792 | 802 | | |
793 | 803 | | |
794 | 804 | | |
795 | 805 | | |
796 | 806 | | |
797 | 807 | | |
798 | 808 | | |
799 | | - | |
800 | | - | |
801 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
802 | 813 | | |
803 | 814 | | |
804 | 815 | | |
| |||
2446 | 2457 | | |
2447 | 2458 | | |
2448 | 2459 | | |
2449 | | - | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
2450 | 2470 | | |
2451 | 2471 | | |
2452 | 2472 | | |
| |||
2459 | 2479 | | |
2460 | 2480 | | |
2461 | 2481 | | |
2462 | | - | |
2463 | | - | |
| 2482 | + | |
| 2483 | + | |
2464 | 2484 | | |
2465 | 2485 | | |
2466 | 2486 | | |
| |||
2469 | 2489 | | |
2470 | 2490 | | |
2471 | 2491 | | |
2472 | | - | |
2473 | | - | |
2474 | | - | |
2475 | 2492 | | |
2476 | 2493 | | |
2477 | 2494 | | |
| |||
2482 | 2499 | | |
2483 | 2500 | | |
2484 | 2501 | | |
2485 | | - | |
2486 | 2502 | | |
2487 | 2503 | | |
2488 | 2504 | | |
| |||
Lines changed: 35 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| |||
235 | 241 | | |
236 | 242 | | |
237 | 243 | | |
238 | | - | |
239 | | - | |
240 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
241 | 247 | | |
242 | 248 | | |
243 | 249 | | |
| |||
292 | 298 | | |
293 | 299 | | |
294 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
295 | 316 | | |
| 317 | + | |
| 318 | + | |
296 | 319 | | |
297 | 320 | | |
298 | 321 | | |
| |||
310 | 333 | | |
311 | 334 | | |
312 | 335 | | |
313 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
314 | 340 | | |
315 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
316 | 345 | | |
317 | 346 | | |
318 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
Lines changed: 33 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
829 | 830 | | |
830 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
831 | 839 | | |
832 | 840 | | |
833 | 841 | | |
| |||
842 | 850 | | |
843 | 851 | | |
844 | 852 | | |
845 | | - | |
| 853 | + | |
846 | 854 | | |
847 | 855 | | |
848 | 856 | | |
| |||
851 | 859 | | |
852 | 860 | | |
853 | 861 | | |
854 | | - | |
| 862 | + | |
855 | 863 | | |
856 | 864 | | |
857 | 865 | | |
| |||
1553 | 1561 | | |
1554 | 1562 | | |
1555 | 1563 | | |
1556 | | - | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
1557 | 1575 | | |
1558 | 1576 | | |
1559 | 1577 | | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
1566 | 1585 | | |
1567 | 1586 | | |
1568 | 1587 | | |
| |||
0 commit comments