Repository navigation
Avoid allocating a row array when a statement is done - #758
Merged
flavorjones merged 4 commits intoOct 26, 2026
Merged
flavorjones merged 4 commits into
flavorjones merged 4 commits into
Conversation
Member
|
Thank you for this contribution! If it goes green, I'll merge 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.
Statement#stepallocates a row array before handlingSQLITE_DONE, then discards it. Handle completion after the suppressed-callback exception check but beforesqlite3_column_count/rb_ary_new2. Row conversion, freezing, and the error/reset paths are unchanged.This saves one array per completed statement, not per row. A warmed 10,000-iteration
GC.stat(:total_allocated_objects)probe on Ruby 4.0.7 measured 2 → 1 objects for an empty SELECT, 4 → 3 for a one-row SELECT, and 2 → 1 for an empty UPDATE. Stepping an already-done statement remains at zero allocations. This is an allocation-only improvement; no speed, latency, or CPU no-regression claim is made.Validation on the PR head (Ruby 4.0.7):
bundle exec rake: RuboCop clean; 379 tests / 772 assertions, no failures or skips (vendored SQLite 3.54.1).SQLITE3_TEST_GC_LEVEL=verify bundle exec rake test: 379 / 772, no failures or skips.bundle exec rake compile test:valgrind: 379 / 749, no failures or memory errors; 7 test-defined skips.Before/after behavior probes also agree for retained frozen rows, Unicode/blob/null values, reset/repeated DONE, constraint and callback exceptions, compaction, BUSY/LOCKED retries, and statement lifetime after closing the database.