Skip to content

Commit 00495a7

Browse files
authored
Merge pull request DeusData#1274 from DeusData/fix/arm64-pagecache-alignment
fix(store): drop the SQLite page-cache slab that faults on arm64
2 parents a388700 + 43fd203 commit 00495a7

2 files changed

Lines changed: 0 additions & 39 deletions

File tree

‎src/store/store.c‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -731,50 +731,19 @@ static cbm_store_t *store_open_internal(const char *path, bool in_memory, bool c
731731
* commit, which is the point: bounded beats unbounded.
732732
*
733733
* Must run before SQLite initialises, so it is done once on the first open. */
734-
enum {
735-
STORE_PAGECACHE_SLOT_BYTES = 4096 + 256, /* page + pcache1 header slack */
736-
STORE_PAGECACHE_SLOTS = 2048, /* ~8.7 MiB, shared by all connections */
737-
};
738-
739-
/* Must run before ANY sqlite3 call: SQLITE_CONFIG_PAGECACHE is refused once
740-
* sqlite3_initialize has run, and being refused is what left every request's
741-
* page cache coming from the general allocator (#581). Idempotent, so the
742-
* open paths can keep calling it as a backstop. */
743-
void cbm_store_configure_pagecache(void) {
744-
static atomic_int configured = ATOMIC_VAR_INIT(0);
745-
int expected = 0;
746-
if (!atomic_compare_exchange_strong(&configured, &expected, 1)) {
747-
return;
748-
}
749-
static char slab[STORE_PAGECACHE_SLOT_BYTES * STORE_PAGECACHE_SLOTS];
750-
int rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, slab, STORE_PAGECACHE_SLOT_BYTES,
751-
STORE_PAGECACHE_SLOTS);
752-
if (rc != SQLITE_OK) {
753-
/* Fail loud rather than silently reverting to per-connection cache
754-
* allocation, which is the behaviour that produced #581. Not fatal:
755-
* the store still works, it just fragments — so say so clearly. */
756-
cbm_log_warn("store.pagecache.config_failed", "rc",
757-
rc == SQLITE_MISUSE ? "misuse" : "error", "detail",
758-
"shared SQLite page-cache slab was refused (SQLite already initialised?); "
759-
"page cache will be served from the general allocator and may fragment");
760-
}
761-
}
762734

763735
cbm_store_t *cbm_store_open_memory(void) {
764-
cbm_store_configure_pagecache();
765736
return store_open_internal(":memory:", true, true);
766737
}
767738

768739
cbm_store_t *cbm_store_open_path(const char *db_path) {
769-
cbm_store_configure_pagecache();
770740
if (!db_path) {
771741
return NULL;
772742
}
773743
return store_open_internal(db_path, false, true);
774744
}
775745

776746
cbm_store_t *cbm_store_open_path_existing(const char *db_path) {
777-
cbm_store_configure_pagecache();
778747
if (!db_path) {
779748
return NULL;
780749
}
@@ -845,7 +814,6 @@ static bool build_immutable_uri(const char *path, char *out, size_t out_sz) {
845814
}
846815

847816
cbm_store_t *cbm_store_open_path_query(const char *db_path) {
848-
cbm_store_configure_pagecache();
849817
if (!db_path) {
850818
return NULL;
851819
}

‎src/store/store.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,6 @@ typedef struct {
208208
/* ── Lifecycle ──────────────────────────────────────────────────── */
209209

210210
/* Open an in-memory database (for testing). */
211-
/* Install the process-wide SQLite page-cache slab. Call once, as early in
212-
* process startup as possible — before any store is opened. SQLite refuses the
213-
* configuration after it initialises itself, and the fallback (a fresh page
214-
* cache per connection, from the general allocator) is what made a long-lived
215-
* Windows daemon ratchet committed memory (#581). Safe to call repeatedly. */
216-
void cbm_store_configure_pagecache(void);
217-
218211
cbm_store_t *cbm_store_open_memory(void);
219212

220213
/* Open a file-backed database at the given path. Creates if needed. */

0 commit comments

Comments
 (0)