Implement Slice Eleven text offset and record optimizations - #14
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
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.
Objective
Reduce repeated text walks and field copying that remain after #13. On a local Node benchmark with 1,024 email findings in one Unicode field, a complete scan-and-transform call improves from 242.3 ms to 3.2 ms (75.6×) with identical findings and transformation results.
This is a candidate for inclusion in 0.3.0. Package versions remain at 0.2.0; no release is published here.
Changes
TextIndexwith one checkpoint per 256 code points. Reuse it for finding validation, scan offsets, and Node/WASM UTF-16 conversion, including unordered ranges and separate structured fields.docs/bookkeeping-performance.md.Existing operations, configuration, output shapes, error precedence, selection policies, and provider sequencing are preserved. No new dependencies or model assets are added. Reusing validation results across preparation/completion stages is deferred; this PR makes offset work reusable within each stage.
Measured tradeoffs
Same-process, alternating release builds on macOS ARM64 with Node 24; seven-round medians, full-result comparisons, provider I/O excluded. Baseline: the merge of #13 (
083eaaab6bcfcfba9a31bc8ce1cfc99f1c2a3cae).Small/customer operations were approximately 0–4% slower depending on the operation. The long sparse Unicode scan-only case was about 10% slower, although its combined operation improved. These are local synthetic measurements, not universal latency guarantees. Checkpoint memory grows with visited text; no process-level memory benchmark is claimed.
Verification
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features— 84 passed, one existing manual benchmark ignorednpm run test:package --prefix bindings/node— includes dense Unicode byte/code-point/UTF-16 ranges, reversed findings, redaction/removal/emoji masking, and structured tokenization/restorationnpm run test:package --prefix bindings/wasm— includes dense range checks in Chromium and TypeScript checks