libsql-sqlite3: Optimize libsql_pager_has_codec() function#2185
Merged
Conversation
d4e39ba to
f249ae6
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes database encryption codec checks by caching the result during pager initialization instead of performing expensive VFS stack traversals on every page read operation.
Key changes:
- Added a
hasCodecflag to thePagerstruct to cache the codec state - Replaced runtime calls to
libsql_pager_has_codec()with direct checks of the cachedhasCodecfield - Initialize the cache once during
sqlite3PagerOpen()with an explanatory comment about the optimization
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| libsql-sqlite3/src/pager.c | Added hasCodec field to Pager struct, cached codec check result during initialization, replaced function calls with field access |
| libsql-ffi/bundled/src/sqlite3.c | Same changes as pager.c in bundled SQLite amalgamation |
| libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c | Same changes as pager.c in SQLite3MultipleCiphers amalgamation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cache the result of libsql_pager_has_codec() in Pager struct to avoid walking through all VFSes every time a page is read.
f249ae6 to
6d6ba1e
Compare
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.
Cache the result of libsql_pager_has_codec() in Pager struct to avoid walking through all VFSes every time a page is read.