Skip to content

Extend rust-performance with concurrency patterns (crossbeam, rayon, atomics) #65

@AlexMikhalev

Description

@AlexMikhalev

Parent Epic: #62

What

Add concurrency primitive patterns to rust-performance SKILL.md. Currently covers async but not lower-level concurrency.

Sections to Add

  1. Lock-Free Data Structures -- crossbeam epoch-based reclamation, concurrent queues
  2. Data Parallelism with Rayon -- par_iter(), parallel chunking, custom thread pools
  3. Atomic Operations -- Ordering levels (Relaxed/Acquire/Release/SeqCst), when to use each
  4. Thread Pool Configuration -- Custom stack sizes, thread naming, affinity
  5. Cache Locality in Concurrent Code -- Avoiding false sharing, padding for cache lines

Source Reference

Section 8 (Concurrency Patterns) from RUST_SYSTEM_PROGRAMMING_BEST_PRACTICES.md

Disciplined Engineering Alignment

Phase Skill Concurrency Relevance
Research disciplined-research Profile existing code for parallelism opportunities; identify shared-state contention points
Design disciplined-design Specify concurrency strategy (rayon vs crossbeam vs atomics); document memory ordering requirements; design cache-friendly layouts
Implementation disciplined-implementation Implement lock-free structures with safety invariants per step; rayon integration as separate step from correctness
Verification disciplined-verification ThreadSanitizer on all concurrent paths; stress tests with loom for atomic ordering; benchmark parallel vs sequential
Validation disciplined-validation Validate throughput under production load patterns; verify no deadlocks/livelocks under sustained stress

The SKILL.md should note:

  • During research: profile for Amdahl's law -- identify serial bottlenecks before parallelizing
  • During design: specify memory ordering rationale for every atomic operation
  • During verification: loom and TSan are mandatory for lock-free code

Relevance to Terraphim

Terraphim uses Aho-Corasick automata with parallel text processing. crossbeam and rayon patterns are directly applicable to search pipeline performance.

Acceptance Criteria

  • SKILL.md updated with concurrency section including code examples
  • crossbeam and rayon added to crate recommendations
  • Benchmark template extended for concurrent workloads
  • Disciplined workflow integration notes included

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions