-
Notifications
You must be signed in to change notification settings - Fork 5
perf(native): fix WASM fallback bypass and batch SQL inserts #606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b61951
chore: add benchmark npm script and stale embeddings warning
carlos-alm 9fb2e6b
perf(native): fix WASM fallback bypass and batch SQL inserts
carlos-alm 7a728a0
merge: resolve conflicts with main
carlos-alm c22b7eb
fix(structure): remove superfluous optional chaining on hotspot query…
carlos-alm 80100cd
fix(builder): cache export-marking UPDATE statement per chunk size (#…
carlos-alm 828157d
fix(types): resolve TS strict-mode errors in structure.ts and complex…
carlos-alm b4f4ce2
fix: correct misleading comments and cache role UPDATE stmts (#606)
carlos-alm 130697d
fix: resolve merge conflict with main in finalize.ts
carlos-alm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
perf(native): fix WASM fallback bypass and batch SQL inserts
Fix interface property signatures (dotted names, single-line spans) incorrectly triggering WASM tree creation on native builds across engine.ts, complexity.ts, and cfg.ts. Add statement caching and batch UPDATE optimizations for insert and role classification stages. Native full build: 2001ms vs WASM 3116ms (1.6x faster). Key wins: complexity 4.2x, cfg 3.2x, parse 2.4x faster. Impact: 26 functions changed, 25 affected
- Loading branch information
commit 9fb2e6bde1331d3b6213842ccef12a928026facb
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db.prepare(...)is called inside the loop, so for each chunk a new SQL string is parsed and a new prepared statement is compiled. This is inconsistent with the WeakMap-based caching introduced inhelpers.ts(getNodeStmt/getEdgeStmt), which was added specifically to avoid per-chunk recompilation.For a typical build the number of distinct chunk sizes is small (usually just 1 or 2), so the overhead is modest, but the inconsistency means this UPDATE still pays a preparation cost per batch iteration that the INSERT paths no longer do. Hoisting the statement cache outside the loop (or reusing the same pattern from
helpers.ts) would close the gap:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed — added a
Map<number, BetterSqlite3.Statement>cache (exportStmtCache) outside the loop body, keyed by chunk size. The prepared statement is now reused across iterations with the same chunk size, consistent with the WeakMap-based caching pattern inhelpers.ts.