First last key#6183
Conversation
Instruction Count Benchmark Results
Warning 5 instruction-count regression(s) detected (>1% threshold):
Deterministic metrics — reproducible across runs (34 benchmarks)
Cache-dependent metrics — expect fluctuations between runs (34 benchmarks)
|
| rpc ProcessDeleteNamespace (RequestDeleteNamespace) returns (google.protobuf.Empty) {} | ||
| rpc ProcessListAll (google.protobuf.Empty) returns (ReplyListAll) {} | ||
| rpc ProcessListRootKeys (RequestListRootKeys) returns (ReplyListRootKeys) {} | ||
| rpc ProcessDeleteAll (google.protobuf.Empty) returns (google.protobuf.Empty) {} |
There was a problem hiding this comment.
(Why the Process prefix everywhere?)
| let response = response.into_inner(); | ||
| let ReplyFindLastKeyByPrefix { key } = response; | ||
| Ok(key) | ||
| } |
There was a problem hiding this comment.
These methods share a lot of code; can that be deduplicated? Maybe they'd just pass in one or two closures to the same general method: what method to call on the client, and possibly what to do with the result?
| .find_last_key_value_by_prefix(key_prefix) | ||
| .await | ||
| .map_err(DualStoreError::Second), | ||
| } |
There was a problem hiding this comment.
It seems this could also be deduplicated with a single generic method that does the matching and map_err?
Motivation
This is a continuation of the existing PR #6171
by implementing the corrections that I asked.
Proposal
Add find_first_key_by_prefix, find_last_key_by_prefix, and the value variants to ReadableKeyValueStore, with default impls falling back to find_keys_by_prefix(...).first()/.last(). Native overrides:
For the wrappers:
linera-storage-serviceis also straightforward.find_keys_by_prefix,find_key_values_by_prefixto return result when possible.For the
ValueSplittingthis is harder since we can split some keys and anyway the remaining key could be leftover from previous big values that were deleted:find_first_key_by_prefixreturns a key that has index 0, we know it is ok, and we return. Otherwise, we do afind_keys_by_prefixwhich is expensive but should be very rare.find_first_key_value_by_prefix, if the obtained key has index 0 and the obtained value a count of 1, we know it is a legitimate one and we can return. Otherwise, we do an expensive but rarefind_key_values_by_prefix.Test Plan
CI
The test
map_view_mutabilitywas modified to use a Value splitting store. The way the keys are used has changed, but this is only because the generated key-set should be prefix-free.Release Plan
Can be backported to
testnet_conway.Links
None