diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-08 01:27:58 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-08 01:27:58 +0200 |
| commit | c27e04c88557716bbe8e42b9174ba9b07f90facf (patch) | |
| tree | a1a56edbede2bba9bb0cc99b81b98570b8313915 /packages/meshbay-node/src/meshbay_node/indexer/cache.py | |
| parent | cdd5fd52e981c4c59643e7dee705b6c55acae68e (diff) | |
| download | meshbay-c27e04c88557716bbe8e42b9174ba9b07f90facf.tar.gz | |
perf(node): sample 9 MB with the size above 9 MB, keep known ids0.19
hash_version 3: size + first 4 MB + last 4 MB + 1 MB at the middle,
5.5x faster cold on a USB disk than the 45 MB sample. The cache now
serves a hit under whatever version it holds, so no existing id moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/indexer/cache.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/indexer/cache.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/indexer/cache.py b/packages/meshbay-node/src/meshbay_node/indexer/cache.py index 5e328ef..afa4f85 100644 --- a/packages/meshbay-node/src/meshbay_node/indexer/cache.py +++ b/packages/meshbay-node/src/meshbay_node/indexer/cache.py @@ -112,17 +112,16 @@ class IndexCache: async def __aexit__(self, *_): await self.close() - async def lookup(self, path: str, size: int, mtime: float, - hash_version: int = 1) -> CachedEntry | None: + async def lookup(self, path: str, size: int, mtime: float) -> CachedEntry | None: """ - A cache hit requires an EXACT match on size, mtime AND hash_version. - A v1 cached hash won't serve a v2 lookup for the same path — the file - is re-hashed with the new algorithm instead. + A cache hit requires an EXACT match on size and mtime, and serves the + hash under whatever hash_version it was computed: a scheme change must + not change the id of a file the node already knows. """ async with self._db.execute( "SELECT hash, type, added_at, hash_version FROM files " - "WHERE path = ? AND size = ? AND mtime = ? AND hash_version = ?", - (path, size, mtime, hash_version)) as cur: + "WHERE path = ? AND size = ? AND mtime = ?", + (path, size, mtime)) as cur: row = await cur.fetchone() return CachedEntry(hash=row[0], type=row[1], added_at=row[2], hash_version=row[3]) if row else None |