Skip to content

perf(lockfree): remove unused sequence_ array from lockfree_spsc_queue #533

Description

@kcenon

What

lockfree_spsc_queue in src/impl/async/lockfree_queue.h:191 declares a separate alignas(cache_line_size) std::array<std::atomic<size_t>, Size> sequence_ array. However, each cell struct (L:157) already contains its own std::atomic<size_t> sequence field. The standalone sequence_ array is initialized but never referenced in enqueue/dequeue operations.

Why

  • With default Size = 1024, the unused array wastes ~8KB of memory
  • The array also increases cache footprint, potentially evicting useful data from L1/L2 cache

Where

  • src/impl/async/lockfree_queue.h:191 — unused sequence_ array declaration
  • src/impl/async/lockfree_queue.h:157cell::sequence already provides per-slot sequencing

How

Acceptance Criteria

  • sequence_ array removed
  • Enqueue/dequeue logic verified to use cell::sequence exclusively
  • All existing tests pass
  • Memory footprint reduced by ~8KB per queue instance

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore functionalityperformancePerformance improvementspriority:highHigh priority issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions