Minimal‐Core‐Guidelines - kirklasalle/SpaceEntropyCompression GitHub Wiki

Minimal-Core Guidelines & Code Redundancy Elimination

The SpaceEntropyCompression (SEC) codebase enforces an aggressive code-reduction and performance discipline. The engine avoids framework abstraction tax, eliminates unnecessary memory allocations, and ensures mathematical clarity remains directly verifiable.


1. Core Engineering Principles

  1. Zero Runtime Heap Allocation in Core Loops:

    • Memory must be pre-allocated via caller buffers, static arenas, or stack-allocated arrays.
    • Core compression and decompression loops (encode_chunk, decode_chunk) must never call malloc, free, new, or standard container resizers.
  2. Branchless State Transitions:

    • Inner decoding loops must use conditional arithmetic or bitmasking rather than unpredictable branches to avoid CPU instruction stalls.
    • Renormalization in the rANS decoder utilizes arithmetic masking to saturate superscalar execution pipelines.
  3. Explicit Data-Oriented Layout (SoA Over AoS):

    • Coordinates and tensor variables are stored as parallel contiguous arrays (x[], y[], z[], vci[]).
    • Enables direct vectorization via SIMD instruction sets (AVX2, AVX-512, NEON) without stride packing penalties.
  4. Deterministic Fixed-Point Encodings:

    • IEEE 754 floating-point numbers are converted to fixed-point integer grids immediately upon entering the pipeline.
    • Guarantees identical binary output across varying platforms and compiler optimization levels.

2. Style and Brevity Standards

  • Concise Implementations: Avoid layered class hierarchies, complex template metaprogramming, and deep object inheritance. Prefer pure functions operating on flat structs.
  • Bounded Headers: Public API headers must stay under 500 lines of code, isolating implementation details into private units.
  • Auditability: Every algorithm stage must directly map to an equation specified in the theoretical wiki documentation.