Skip to content

Shrink TransposeDecoder failure sentinel padding and use inline node storage - #49

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1011381055
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1011381055

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Shrink TransposeDecoder failure sentinel padding and use inline node storage

Reduces per-chunk setup overhead in riegeli::TransposeDecoder::Parse:

  1. Shrinks the failure sentinel padding from 255 to
    kNumFailureSentinelNodes = 64 nodes (the maximum transition step offset is
    0xff >> 2 == 63, checked by a static_assert).
  2. Replaces the heap-allocated std::vector<StateMachineNode> with inline
    storage in Context (inline_nodes[128]: up to 64 active nodes plus 64
    sentinels, ~3 KiB on Decode's stack), falling back to
    std::unique_ptr<StateMachineNode[]> for larger schemas, and deletes
    Context copy/move because state_machine_nodes may point into
    inline_nodes.
  3. Explicitly initializes tag_data_size (and is_implicit on sentinels),
    which std::vector::resize previously value-initialized.
  4. Passes absl::Span<const StateMachineNode> (active nodes only) to
    ContainsImplicitLoop and replaces its std::vector<size_t> with
    absl::FixedArray<uint32_t, Context::kInlineActiveNodes>.

@google-cla

google-cla Bot commented Nov 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service copybara-service Bot changed the title Shrink TransposeDecoder failure sentinel padding from 255 to 64 Shrink TransposeDecoder failure sentinel padding and use inline node storage Nov 3, 2026
…storage

Reduces per-chunk setup overhead in `riegeli::TransposeDecoder::Parse`:
1. Shrinks the failure sentinel padding from 255 to
   `kNumFailureSentinelNodes = 64` nodes (the maximum transition step offset is
   `0xff >> 2 == 63`, checked by a `static_assert`).
2. Replaces the heap-allocated `std::vector<StateMachineNode>` with inline
   storage in `Context` (`inline_nodes[128]`: up to 64 active nodes plus 64
   sentinels, ~3 KiB on `Decode`'s stack), falling back to
   `std::unique_ptr<StateMachineNode[]>` for larger schemas, and deletes
   `Context` copy/move because `state_machine_nodes` may point into
   `inline_nodes`.
3. Explicitly initializes `tag_data_size` (and `is_implicit` on sentinels),
   which `std::vector::resize` previously value-initialized.
4. Passes `absl::Span<const StateMachineNode>` (active nodes only) to
   `ContainsImplicitLoop` and replaces its `std::vector<size_t>` with
   `absl::FixedArray<uint32_t, Context::kInlineActiveNodes>`.

PiperOrigin-RevId: 1011381055
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.

0 participants