This experimental package demonstrates compile-time chain composition (StaticChain) as outlined in ../cpp/CHAIN_PERFORMANCE_OPTIMIZATION.md.
- Show conceptual and empirical difference between:
- Direct inline function pipeline
StaticChain(compile-time tuple of operations)- Dynamic
Chainwith virtual dispatch + coroutine awaitable
include/codeuchain_opt/static_chain.hpp: Header-onlyStaticChain<Ops...>template and example stateless ops.
cd packages/cpp/build # assuming core library already configured
cmake --build . --target static_chain_demo -j
./packages/cpp_opt/static_chain_demoIf not yet configured, do:
cd packages/cpp
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ../.. # top-level if aggregated, else adjust
cmake --build . --target static_chain_demo -jStaticChain Demo (ns/op)
direct : <baseline arithmetic>
static : <near-baseline if state overhead dominates>
dynamic : <higher due to virtual + coroutine + map copies>
static should be closer to direct than dynamic. Remaining gap is dominated by state mutation + variant access.
For guidance on when to apply advanced optimizations (StaticChain vs dynamic chain, mutability, slot caching, hybrid state) versus leaving code in the default dynamic form, see:
OPTIMIZATION_DECISION_GUIDE.md
Highlights:
- Do NOT optimize unless profiling shows micro-scale hot spots.
- Prefer dynamic chains for clarity and observability.
- Escalate to StaticChain + mutability + slot caching only in high-frequency trivial workloads.
- HybridState + interning (planned) targets memory + lookup churn for further reductions.
This README remains focused on the prototype mechanics; the decision guide captures strategy.
- Hybrid state prototype (
HybridState) with inline storage - Key interning & slot caching toggles
- JSON metrics export integration with main benchmark harness
Prototype code intended for design exploration; APIs may change or be removed.