From 68ab8797b5820b578085d3f247fb2ea0d513f624 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 16 May 2025 13:16:18 +0200 Subject: [PATCH] libstore: remove unused realisation disk caching we don't need to touch the schema of the cache here. keeping the table around doesn't hurt (and avoids cppnix breakage) thanks to foreign key constraints and the ca bits of the schema being independent enough for us to just ignore them (and not having to do any maintenance on them). Change-Id: Ib5d8eb1cd838826d88eb65bbf8f245703a2482da --- lix/libstore/nar-info-disk-cache.cc | 96 +---------------------------- lix/libstore/nar-info-disk-cache.hh | 9 --- 2 files changed, 1 insertion(+), 104 deletions(-) diff --git a/lix/libstore/nar-info-disk-cache.cc b/lix/libstore/nar-info-disk-cache.cc index 6ded35634..c4ddbda55 100644 --- a/lix/libstore/nar-info-disk-cache.cc +++ b/lix/libstore/nar-info-disk-cache.cc @@ -43,15 +43,6 @@ create table if not exists NARs ( foreign key (cache) references BinaryCaches(id) on delete cascade ); -create table if not exists Realisations ( - cache integer not null, - outputId text not null, - content blob, -- Json serialisation of the realisation, or null if the realisation is absent - timestamp integer not null, - primary key (cache, outputId), - foreign key (cache) references BinaryCaches(id) on delete cascade -); - create table if not exists LastPurge ( dummy text primary key, value integer @@ -81,8 +72,7 @@ public: { SQLite db; SQLiteStmt insertCache, queryCache, insertNAR, insertMissingNAR, - queryNAR, insertRealisation, insertMissingRealisation, - queryRealisation, purgeCache; + queryNAR, purgeCache; std::map caches; }; @@ -116,26 +106,6 @@ public: state->queryNAR = state->db.create( "select present, namePart, url, compression, fileHash, fileSize, narHash, narSize, refs, deriver, sigs, ca from NARs where cache = ? and hashPart = ? and ((present = 0 and timestamp > ?) or (present = 1 and timestamp > ?))"); - state->insertRealisation = state->db.create( - R"( - insert or replace into Realisations(cache, outputId, content, timestamp) - values (?, ?, ?, ?) - )"); - - state->insertMissingRealisation = state->db.create( - R"( - insert or replace into Realisations(cache, outputId, timestamp) - values (?, ?, ?) - )"); - - state->queryRealisation = state->db.create( - R"( - select content from Realisations - where cache = ? and outputId = ? and - ((content is null and timestamp > ?) or - (content is not null and timestamp > ?)) - )"); - /* Periodically purge expired entries from the database. */ retrySQLite([&]() { auto now = time(0); @@ -282,37 +252,6 @@ public: }, always_progresses); } - std::pair> lookupRealisation( - const std::string & uri, const DrvOutput & id) override - { - return retrySQLite([&]() -> std::pair> { - auto state(_state.lock()); - - auto & cache(getCache(*state, uri)); - - auto now = time(0); - - auto queryRealisation(state->queryRealisation.use() - (cache.id) - (id.to_string()) - (now - settings.ttlNegativeNarInfoCache) - (now - settings.ttlPositiveNarInfoCache)); - - if (!queryRealisation.next()) - return {oUnknown, 0}; - - if (queryRealisation.isNull(0)) - return {oInvalid, 0}; - - auto realisation = - std::make_shared(Realisation::fromJSON( - json::parse(queryRealisation.getStr(0), "a nar cache entry"), - "Local disk cache")); - - return {oValid, realisation}; - }, always_progresses); - } - void upsertNarInfo( const std::string & uri, const std::string & hashPart, std::shared_ptr info) override @@ -352,39 +291,6 @@ public: } }, always_progresses); } - - void upsertRealisation( - const std::string & uri, - const Realisation & realisation) override - { - retrySQLite([&]() { - auto state(_state.lock()); - - auto & cache(getCache(*state, uri)); - - state->insertRealisation.use() - (cache.id) - (realisation.id.to_string()) - (realisation.toJSON().dump()) - (time(0)).exec(); - }, always_progresses); - - } - - virtual void upsertAbsentRealisation( - const std::string & uri, - const DrvOutput & id) override - { - retrySQLite([&]() { - auto state(_state.lock()); - - auto & cache(getCache(*state, uri)); - state->insertMissingRealisation.use() - (cache.id) - (id.to_string()) - (time(0)).exec(); - }, always_progresses); - } }; ref getNarInfoDiskCache() diff --git a/lix/libstore/nar-info-disk-cache.hh b/lix/libstore/nar-info-disk-cache.hh index a41e3bcca..4fa7e8a99 100644 --- a/lix/libstore/nar-info-disk-cache.hh +++ b/lix/libstore/nar-info-disk-cache.hh @@ -32,15 +32,6 @@ public: virtual void upsertNarInfo( const std::string & uri, const std::string & hashPart, std::shared_ptr info) = 0; - - virtual void upsertRealisation( - const std::string & uri, - const Realisation & realisation) = 0; - virtual void upsertAbsentRealisation( - const std::string & uri, - const DrvOutput & id) = 0; - virtual std::pair> lookupRealisation( - const std::string & uri, const DrvOutput & id) = 0; }; /**