Skip to content

Conversation

@penberg
Copy link
Collaborator

@penberg penberg commented Nov 5, 2025

Cache the result of libsql_pager_has_codec() in Pager struct to avoid walking through all VFSes every time a page is read.

@penberg penberg force-pushed the optimize-libsql_pager_has_codec branch 3 times, most recently from d4e39ba to f249ae6 Compare November 6, 2025 14:36
@penberg penberg requested a review from Copilot November 6, 2025 14:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 hasCodec flag to the Pager struct to cache the codec state
  • Replaced runtime calls to libsql_pager_has_codec() with direct checks of the cached hasCodec field
  • 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.
@penberg penberg force-pushed the optimize-libsql_pager_has_codec branch from f249ae6 to 6d6ba1e Compare November 6, 2025 15:26
@penberg penberg added this pull request to the merge queue Nov 6, 2025
Merged via the queue into main with commit 84146a1 Nov 6, 2025
20 checks passed
@penberg penberg deleted the optimize-libsql_pager_has_codec branch November 6, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants