Skip to content

run_command sits at an inlining edge: unrelated changes move 10-15 instructions per GET #867

Open

Description

@murtazayusuf

Seen twice on 2026-11-17, on two unrelated PRs (#864, #866) that each added a few lines to run_command away from the read path: per GET on io_uring, about 13 instructions leave execute_command (slice compare) and 13-14 appear in Option<Vec<u8>>::or_else::<run_command::{closure}> (the dispatch_command_handlers(ctx, name).or_else(|| lua::handle(ctx, name)) chain near the end of run_command), with a net of +10 to +12 instructions per GET and +5 per SET. #845 hit the same kind of thing harder (+50 per GET from a closure that stopped being inlined).

run_command is large enough that the compiler's inlining choices inside it flip with small changes, so every PR that touches it has to be measured, and some pay a cost that is not theirs.

To do:

  • find which call flips (per-function callgrind diff of master against a build with a no-op line added to run_command), and pin it: #[inline(always)] / #[cold] where the intent is known, or split the cold parts of run_command (cluster routing, replica checks, keyspace-event watch, error accounting) into #[cold] #[inline(never)] functions so the hot path is small and stable;
  • measure GET/SET at 100 B and 1 KB on both I/O models before and after (scripts/perf/run.sh); the goal is the same or fewer instructions than today and no movement when a line is added elsewhere in the function;
  • add the "no-op line" stability check to the notes in scripts/perf.

Default variant and lua both (the closure only exists with lua; check what the default build does at the same place).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceThroughput and latency

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions