You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Concurrent lookups in an encrypted dictionary pack read by range contend in the leaflet cache #2146
P2Scheduled: real but not urgentarea:storageStorage backends, nameservice, ledger lifecycle, index storage, cachesperformancePerformance improvement (release notes: Performance)
Found while fixing #2130's review: on encrypted local storage, lookups in a forward dictionary pack that is read by range slow down sharply as threads are added.
A pack is read by range until it is promoted into the dictionary allowance, and for good if it is larger than the allowance or the working set doesn't fit. Each lookup reads its two offsets and its value through the leaflet cache's decrypted segments (CachedUnits::extend_into → LeafletCache::try_get_or_load_source_unit).
Wall time per lookup per thread, one pack, dev-fast, on a laptop:
threads
read by range
promoted (for comparison)
1
160–230 ns
10 ns
2
350–430 ns
10 ns
4
670–1,050 ns
11 ns
8
2,700–2,900 ns
11 ns
10
3,600–4,200 ns
12 ns
Not profiled yet. The likely cost is that every segment read is a moka get on a key all threads share: it clones the segment's Arc<[u8]>, which writes its reference count, and records a read op. A miss also updates the pack's MissMeter.
UnitMemoScope serves repeated segments from a thread-local memo, but only the result formatters open it. Decode loops elsewhere (filters, ORDER BY and GROUP BY over strings) take the shared path on every lookup.
When it matters: concurrent queries over an encrypted store while packs warm up, and in steady state when the working set is larger than the allowance or a pack is larger than it. On next, an encrypted pack was decrypted whole, so these lookups didn't contend, at the memory cost #2130 removes.
Directions, to be chosen after a profile:
Open UnitMemoScope around the remaining per-row decode loops.
Read a cached segment without cloning its Arc under concurrency.
Acceptance: lookups by range on 8 threads stay within a small factor of one thread, pinned by a test like lookups_in_a_promoted_pack_scale_across_threads (dict/pack_reader.rs).
P2Scheduled: real but not urgentarea:storageStorage backends, nameservice, ledger lifecycle, index storage, cachesperformancePerformance improvement (release notes: Performance)
Activity