Skip to content

Remove extern crate alloc from logfwd-core (allocation-free kernel) #358

Closed

Description

@strawgate

Summary

After the sequential scanner migration, remove all heap allocation from logfwd-core. The kernel becomes mathematically impossible to OOM — all buffers are stack-local or caller-provided.

What allocates today

  • `StructuralIndex`: stores `Vec` for real_quotes and in_string
  • `StructuralIndex::new()`: returns `Vec<(usize, usize)>` line ranges
  • `CriAggregator`: `pending: Vec` for partial line assembly
  • `compute_real_quotes`: no allocation (pure u64 ops)

How to remove allocations

  • StructuralIndex → streaming: scanner processes per-block, never stores bitmask vectors. Caller provides iteration context.
  • Line ranges: caller (logfwd-arrow) collects, or lines processed inline during SIMD pass
  • CriAggregator: caller provides buffer (BytesMut from logfwd-input)

Constraint

`#![no_std]` without `extern crate alloc` means: no Vec, String, Box, Arc, or any heap type. Only stack, references, and caller-provided slices.

Dependencies

Why

Allocation-safe verification: if the kernel can't allocate, it can't OOM. Combined with Kani proofs for no-panic, the kernel is provably crash-free for all inputs.

Activity

  1. strawgate commented on Apr 4, 2026

    @strawgate
    OwnerAuthor

    Status update (2026-04-04 audit)

    extern crate alloc is heavily used — 109 occurrences of Vec/String/Box/Arc across 9 files in logfwd-core. Major allocating code: StructuralIndex bitmask Vecs, json_scanner scratch buffers, CriReassembler pending buffer, OTLP encoder buffer, ScanConfig field specs.

    This is a multi-PR architecture change requiring all allocations to move to caller-provided buffers. The streaming scanner (json_scanner.rs) is a step toward this but still allocates. Scope: large, not suitable for a single work-unit.

  2. added
    research-neededNeeds investigation before implementation can be scheduled
    on Apr 6, 2026
  3. strawgate commented on Apr 24, 2026

    @strawgate
    OwnerAuthor

    Closing as won't-fix: extern crate alloc is required in no_std crates that need heap-allocated types (Vec, String, BTreeMap). This is working as intended — it's the only way to access the alloc crate without std. The issue description was based on a misunderstanding of Rust's no_std model.

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

    research-neededNeeds investigation before implementation can be scheduled

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions