Skip to content

Keep the NBCROW null bitmap on the stack (row decode perf, axis: precomputation) #255

Description

Sub-issue of #247 (axis: Precomputation). ⚠️ Overlaps #197 — coordinate before starting.

Problem statement

The hot TokenType::NbcRow arm does vec![0u8; bitmap_len] per row. On the PoC benchmark that is ~1M allocate/free pairs for a value that is 6 bytes (48 columns → ceil(48/8)).

Proposed solution

Read the bitmap into a fixed-size stack array, with a heap fallback for oversized (malformed) COLMETADATA.

Feasibility: ✅ proven. Prototyped in 56a836f6, green on all six configs in #247. This is by far the cheapest item in the set.

Findings

Affected crate

mssql-tds

Alternatives considered

SmallVec. Adds a dependency for something a plain array plus a fallback handles.

Reuse a per-result-set scratch buffer. Needs plumbing and lifetime management for zero benefit over a stack array of a statically known maximum.

Additional context

Related but separate, and more expensive on the cursor path: read_row_header does columns.to_vec() per paused row, cloning every column_name: String. Tracked as a cleanup in #247 — far larger than the 6 bytes this item saves, though it is on the pause/resume path rather than the bulk-scan path.

Nothing here is benchmarked. This PR must carry its own measurement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions