Skip to content

Perf/p1 add zero alloc - #35

Merged
ragoune merged 1 commit into
masterfrom
perf/p1-add-zero-alloc
Sep 18, 2026
Merged

ragoune merged 1 commit into
masterfrom
perf/p1-add-zero-alloc

Conversation

@ragoune

@ragoune ragoune commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Zero-allocation single-component add

AddComponent, the config-based add and AddTag resolved their destination archetype through getNextArchetype, whose variadic slice escapes to the heap (the multi-component branch may keep it as an archetype type). For a single component that function only forwards to archetypeAfterAdd: call it directly.

BenchmarkAddVolt (5800X): 6.40 ms, 200 000 allocs → 4.03 ms, 0 allocs.

AddComponent, the non-generic config path and AddTag resolved their
destination through getNextArchetype with a one-element variadic slice, after
boxing the component into ComponentInterface to read its id: two heap
allocations per add (the variadic slice escapes because the multi-component
branch may retain it as an archetype Type). They now read the id from the
typed value and hop the archetype graph directly (archetypeAfterAdd).

BenchmarkAddVolt (5800X): 6.27 ms/op, 200000 allocs/op → 4.0 ms/op, 0 allocs/op.
@ragoune
ragoune force-pushed the perf/p1-add-zero-alloc branch from db6fd2c to 28a44c3 Compare September 18, 2026 14:00
@ragoune
ragoune merged commit 8e60db1 into master Sep 18, 2026
3 checks passed
@ragoune
ragoune deleted the perf/p1-add-zero-alloc branch September 18, 2026 14:01
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
component.go 74.77% <100.00%> (ø)
register.go 85.71% <100.00%> (ø)
tag.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant