Repository navigation
perf(storage): read the vanished flag without the LMDB writer (#1312) - #1389
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
🦋 Changeset detectedLatest commit: bb8e70a The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge.
|
Issue: #1312 (closed by hand with the merge sha after merge).
The cost
LmdbBackend::is_vanishedtookself.write(...)for every call, and the relay asks per event: one write transaction per event from a non-relay pubkey, on the single LMDB writer. Measured at7019957a: the empty commit does not movelast_txn_id(nothing to write), but it holdsme_wmutexfrom begin to commit, and with a writer held the call did not return in three of three runs.The fix
Read first —
self.read+users::find_by_pubkeyreturns the stored flag without a writer. Only when no row exists does the call take the write, whose body is the existing re-loadingusers::is_vanished(re-load, then the kind-62 scan and upsert), so aset_vanished(true)committed between the read and the write is not overwritten.The held-writer case proves the property: one
createfuture, held writer,is_vanishedon a present pubkey answers within the timeout, then the writer is dropped and the same future is re-polled and succeeds (no secondcreate; a duplicateevent_idreturns 0). Inverted at base with the implementation reverted:Elapsed(())after 10.21 s.parity_lmdb52 passing unchanged,nostream-storagelib 151 passing, fmt and clippy clean. The workspace suite and release build are CI's (Rust Checks).