Skip to content

perf(storage): read the vanished flag without the LMDB writer (#1312) - #1389

Merged
chappie-daemon merged 1 commit into
rewrite/mainfrom
factory/049-vanish-read-path
Dec 4, 2026
Merged

chappie-daemon merged 1 commit into
rewrite/mainfrom
factory/049-vanish-read-path

Conversation

@chappie-daemon

Copy link
Copy Markdown
Collaborator

Issue: #1312 (closed by hand with the merge sha after merge).

The cost

LmdbBackend::is_vanished took self.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 at 7019957a: the empty commit does not move last_txn_id (nothing to write), but it holds me_wmutex from 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_pubkey returns the stored flag without a writer. Only when no row exists does the call take the write, whose body is the existing re-loading users::is_vanished (re-load, then the kind-62 scan and upsert), so a set_vanished(true) committed between the read and the write is not overwritten.

The held-writer case proves the property: one create future, held writer, is_vanished on a present pubkey answers within the timeout, then the writer is dropped and the same future is re-polled and succeeds (no second create; a duplicate event_id returns 0). Inverted at base with the implementation reverted: Elapsed(()) after 10.21 s.

parity_lmdb 52 passing unchanged, nostream-storage lib 151 passing, fmt and clippy clean. The workspace suite and release build are CI's (Rust Checks).

@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1cfb2785-034d-481f-924f-505f1fdda095

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@changeset-bot

changeset-bot Bot commented Dec 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bb8e70a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@greptile-apps

greptile-apps Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge.

Summary

LmdbBackend::is_vanished now reads existing user flags without taking LMDB’s single writer.

  • Saved vanish flags no longer wait for the LMDB writer.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["is_vanished(pubkey)"] --> B["Read user row"]
  B --> C{"Row exists?"}
  C -- Yes --> D["Return stored flag"]
  C -- No --> E["Open write transaction"]
  E --> F{"Reload finds row?"}
  F -- Yes --> D
  F -- No --> G["Scan kind-62 events and store flag"]
  G --> H["Commit and return flag"]
Loading

Reviews (1) · Last reviewed commit: "fix(storage): answer the vanish read fro..." · Reviewed by Greptile

@chappie-daemon
chappie-daemon merged commit a70e108 into rewrite/main Dec 4, 2026
19 checks passed
@chappie-daemon
chappie-daemon deleted the factory/049-vanish-read-path branch December 4, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant