Skip to content

perf: attribute read_join's ~78ns/row SeekRowid gap vs oracle (needs profiling) #677

Description

@iheitlager

Description

Follow-up to #673. Reprofiling disproved that ticket's stated root cause
(Value::clone() is already cheap -- Rc-backed -- and read_full_scan
proves the shared column-decode path is at parity with oracle). The real
gap is isolated to read_join's inner-loop SeekRowid probes: roughly
78ns/row extra vs oracle for an identical join plan (SCAN bench_data /
SEARCH bench_lookup USING INTEGER PRIMARY KEY (rowid=?), verified via
EXPLAIN QUERY PLAN on both engines).

btree.rs::seek() was checked and already binary-searches within each
page, so the b-tree seek algorithm itself is not the gap. Two unconfirmed
candidates remain, both requiring actual measurement to distinguish:

  1. VDBE per-opcode dispatch overhead -- the join's inner loop runs more
    opcodes per row (SeekRowid, ON-condition compare, jumps) than
    read_full_scan's linear Next loop.
  2. Page-cache lookup overhead on the repeated per-seek page reads
    (src/pager.rs:1221, RefCell<HashMap>-based cache) vs SQLite's
    array-indexed pcache.

No profiler (perf/cargo-flamegraph) is available in the current
sandboxed dev environment, so this ticket's first deliverable is getting
one of those (or an equivalent manual instrumentation/counter-based
micro-benchmark) working, then using it to attribute the ~78ns/row gap
before proposing any fix.

Complexity

Estimate: small-medium
Reasoning: Mostly measurement/instrumentation work to attribute a
small per-iteration cost; only becomes a real implementation ticket once
the dominant cause is confirmed, at which point it may need re-scoping
again with its own estimate.

Acceptance Criteria

  • A profiler or instrumented micro-benchmark is working locally (or
    documented as unavailable, with a fallback measurement approach)
  • The ~78ns/row read_join gap vs oracle is attributed to a specific
    call site (opcode dispatch vs page-cache lookup vs something else),
    with numbers to back it
  • Findings posted as a comment; if a concrete fix is identified, it is
    re-scoped as its own ticket with its own complexity estimate rather
    than implemented inline here

Refs: follow-up to #673

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions