Repository navigation
perf(query): bound large-document ngram deduplication - #5012
Merged
Merged
Conversation
|
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
ScriptedAlchemy
enabled auto-merge (squash)
November 29, 2026 06:55
ScriptedAlchemy
marked this pull request as draft
November 29, 2026 07:06
auto-merge was automatically disabled
November 29, 2026 07:06
Pull request was converted to draft
ScriptedAlchemy
marked this pull request as ready for review
November 29, 2026 08:41
ScriptedAlchemy
enabled auto-merge (squash)
November 29, 2026 09:44
Name producer and outbox phases with existing tracing spans and log the operation when a persistence deadline expires. Preserve the same typed errors, first-failure retention, persistence and shutdown budgets. Capture span-close busy/idle timing for the real receipt restart test through the existing thread-local tracing helper. Keep the full test and every receipt, replay, acknowledgement and shutdown assertion so canonical CI can identify which persistence operation causes the otherwise indistinguishable shutdown failure.
Apply the pinned formatter's one-line declaration without changing the persistence diagnostic, receipt assertions, or test deadlines.
Carry the reviewed hook fixture repair from 57487cd. Wait for the exact Stop event's completed durable settlement and a drained replay spool before resubmission. Preserve the original deadline and final delivery, suppression, and duplicate assertions. Keep the shared CI repair on the engineering branch so release-please regeneration cannot discard it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Large generated documents repeat many one-, two-, and three-byte windows. The current projection appends every window before sorting and deduplicating it, during both page preparation and final posting derivation. This consumes publication time in the exact-import MCP journey. The investigation began after the release candidate for #4985 exceeded its existing publication deadline following #5005.
Change
Deduplicate sufficiently large documents through a dense presence bitmap only when the bitmap plus the maximum possible unique output fit the existing admitted scratch allocation. Enumerate keys in the existing numeric order and reuse that allocation for the result. Smaller inputs retain the original sort path.
The implementation preserves the 64 MiB scratch ceiling, all byte values including NUL and UTF-8, ordering, and cancellation during input scanning and output extraction. Regression tests compare the dense output with an independent set of byte windows and test cancellation in both phases. Canonical layout, persisted format, and reader validation remain unchanged.
Measured result
Paired CI 46240345433 ran exactly 1 test with 320 filtered in 12.96 seconds under the canonical Bazel query-unit opt-level 1 configuration. It recorded seven inputs × eight pairs, with four old-first and four dense-first rounds for every input. Both algorithms used identical admitted scratch and cancellation checks; setup, warm-up, parity/capacity checks, and deallocation stayed outside timing. All parity/capacity assertions passed, with no timing assertion.
The three generated validator contents measured 10.54–10.81× faster in this kernel. This is specific to the tested configuration and inputs; it does not establish production throughput or a whole-publication latency guarantee. Earlier four-fixture hosted totals of 17.54 seconds and 5.01 seconds had material host/phase and merge-base differences, so that total-time difference is not attributed to this algorithm.
Full-CI findings and fixture corrections
Normal CI 46243838650 tested merge
883323cf, combining the prior PR head with master828fd99e. It passed 179/182 targets (78 executed, 104 cached). Clippy passed. The failures were the global-db unit target's 300.2-second aggregate timeout; two core CLI cases (208 passed, 2 failed); and the MCP peer-composition fixture (681 passed, 1 failed). The query target reused its valid 319-passed/1-ignored result.This update integrates already-merged master
64d43ed4and repairs the evidenced setup preconditions:The two publication fixtures have tiny source inputs below the dense-path threshold. That excludes direct execution of the new bitmap path in those fixtures, but does not establish the cause of their timing failures.
Persistence diagnostic and validation
The earlier
observability_persistence_deadlinefailure did not recur. The complete diagnostic ran all 442 daemon-service tests with zero filtering in 24.39 seconds; the previously failing test passed. Its observed claim/settle transactions were about 2.009 and 1.700 ms, final carrier batch 0.717 ms, and producer shutdown 6.429 ms. Trace overhead and isolated-target load differ from full-fleet CI; this is a measured pass, not a historical timeout fix. The subsequent normal run also passed all 442 daemon-service tests in 45.57 seconds.e7d1d971, pinned Rust 1.100.1 formatting, commitlint, and diff checks passed for the fixture corrections; independent reviews checked the exact three final file blobs and integration ancestry.e7d1d971revision removed its temporary timing/tracing scaffolds, test filters, and diagnostic workflow changes. At that revision, the diff against the integrated base contained the posting implementation/regressions and two fixture files: 170 additions, 11 deletions. The later persistent diagnostics and shared hook-fixture correction are described below.e7d1d971passed Repository gates, Clippy, Dashboard, Feature gates, and Windows. Linux passed 181/182 targets. The sole remaining failure wasreceipt_survives_restart_between_sse_frame_and_browser_ack: its receipt assertions completed, but producer shutdown returned the retainedobservability_persistence_deadlineerror.Persistence failure diagnosis
Commit cbe89f0c adds operation names at persistence timeout sites and existing tracing spans around producer/outbox phases. The receipt restart fixture captures span-close busy/idle timings through the existing thread-local helper. All error retention, receipt/restart assertions, test selection, and persistence/shutdown deadlines are unchanged.
The completed diagnostic Linux run 46291957115 passed all 182 targets: 120 executed and 62 cached. The dashboard unit suite executed uncached and passed in 3.2 seconds. The original receipt timeout did not recur. Passing test output is suppressed by the normal CI configuration, so this run supplies no receipt-phase timings and does not establish a repair of the historical timeout. Independent lifecycle review found no premature database-owner drop or lock held across outbox admission; error retention and deadlines remain unchanged.
That run also identified a one-line rustfmt correction in the trace-capture declaration. Commit f044f322 applies the exact correction, verified locally with the pinned Rust 1.100.1 formatter after executor access recovered.
Shared hook-fixture correction
Commit b7a9ccf2 carries the independently reviewed fixture correction from #5024 onto this engineering branch. A retained Stop retry now waits for the exact event's single durable completed settlement as well as a drained replay spool before resubmitting. The existing overall wait budget, suppression assertion, event identity, delivery count, and duplicate checks remain. This exact fixture content passed #5024's normal CI, including its uncached hook suite. It is not a persistence-timeout repair and adds no release/version changes.
The corrected head
b7a9ccf2is pushed. Current canonical CI 46298864221 has passed Repository gates (including formatting), Clippy, Dashboard, Feature gates, the benchmark harness, and Linux. The Linux fleet job passed all 182 test targets: 74 executed and 108 cached. The changed hook suite executed in 19.7 seconds and dashboard unit suite in 21.9 seconds; both passed. The application suite also executed successfully (60.3 seconds); the global-db target reused its valid 230.4-second cached pass. The original receipt timeout again did not recur, without establishing a causal repair. The Windows job subsequently built and type-checked all 515 targets and passed the Node-held-addon upgrade-refusal check. The workflow and Devin review are now successful. This PR was merged asfab2cde7; Windows completed successfully after the merge.Refs #4985. Follow-up to #5005.