Skip to content

Add dense components and benchmark#6776

Open
DrSmugleaf wants to merge 8 commits into
space-wizards:masterfrom
DrSmugleaf:refactor/dense-components
Open

Add dense components and benchmark#6776
DrSmugleaf wants to merge 8 commits into
space-wizards:masterfrom
DrSmugleaf:refactor/dense-components

Conversation

@DrSmugleaf

@DrSmugleaf DrSmugleaf commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Uses Arch.LowLevel.SparseJaggedArray so that Genaray lives on in the engine and because I'm not coding something that someone else already did twice

Also if we end up using it we need to add Arch.LowLevel to the external licenses file

Attribute is public so content can use it

Entity query enumerators do not use the array for all/most of their comp lookups yet, only the metadata component query does

// * Summary *

BenchmarkDotNet v0.15.8, Windows 10 (10.0.19045.6466/22H2/2022Update)
AMD Ryzen 9 9900X 4.40GHz, 1 CPU, 24 logical and 12 physical cores
.NET SDK 10.0.301
  [Host]     : .NET 10.0.9 (10.0.9, 10.0.926.27113), X64 RyuJIT x86-64-v4
  DefaultJob : .NET 10.0.9 (10.0.9, 10.0.926.27113), X64 RyuJIT x86-64-v4

Before

Method N Mean Error StdDev Allocated
GetEntityQuery 1 11.501 ns 0.2400 ns 0.3875 ns -
GetComponent 1 10.345 ns 0.1566 ns 0.1308 ns -
HasComponent 1 9.996 ns 0.2142 ns 0.3335 ns -
TryGetComponent 1 11.048 ns 0.1920 ns 0.1796 ns -
GetEntityQuery 10 28.262 ns 0.1948 ns 0.1626 ns -
GetComponent 10 93.344 ns 0.6418 ns 0.5359 ns -
HasComponent 10 89.547 ns 1.5452 ns 1.4454 ns -
TryGetComponent 10 95.554 ns 0.4721 ns 0.4185 ns -
GetEntityQuery 100 188.635 ns 1.0761 ns 0.8986 ns -
GetComponent 100 976.291 ns 19.3674 ns 49.6460 ns -
HasComponent 100 1,106.032 ns 22.1331 ns 51.2967 ns -
TryGetComponent 100 1,010.646 ns 20.0130 ns 49.0923 ns -
GetEntityQuery 1000 2,331.782 ns 46.4072 ns 104.7487 ns -
GetComponent 1000 9,885.056 ns 195.7707 ns 491.1503 ns -
HasComponent 1000 8,640.575 ns 171.9456 ns 358.9144 ns -
TryGetComponent 1000 10,054.008 ns 200.9216 ns 419.3983 ns -

After

Method N Mean Error StdDev Median Allocated
GetEntityQuery 1 9.054 ns 0.1000 ns 0.0835 ns 9.051 ns -
GetComponent 1 6.503 ns 0.0720 ns 0.0673 ns 6.476 ns -
HasComponent 1 7.196 ns 0.1622 ns 0.3491 ns 6.980 ns -
TryGetComponent 1 7.767 ns 0.0436 ns 0.0364 ns 7.759 ns -
GetEntityQuery 10 17.693 ns 0.1442 ns 0.1204 ns 17.637 ns -
GetComponent 10 58.170 ns 0.5472 ns 0.4569 ns 58.347 ns -
HasComponent 10 64.693 ns 0.1281 ns 0.1000 ns 64.692 ns -
TryGetComponent 10 82.084 ns 0.4280 ns 0.4004 ns 81.951 ns -
GetEntityQuery 100 100.406 ns 1.4315 ns 1.2690 ns 100.107 ns -
GetComponent 100 619.721 ns 2.3759 ns 2.1062 ns 618.691 ns -
HasComponent 100 523.987 ns 2.4733 ns 2.0654 ns 523.052 ns -
TryGetComponent 100 667.267 ns 2.5387 ns 2.1199 ns 667.794 ns -
GetEntityQuery 1000 1,319.189 ns 4.7558 ns 4.2159 ns 1,320.926 ns -
GetComponent 1000 6,750.258 ns 37.6469 ns 31.4369 ns 6,744.233 ns -
HasComponent 1000 5,222.566 ns 28.4585 ns 22.2185 ns 5,231.129 ns -
TryGetComponent 1000 7,128.651 ns 89.5417 ns 74.7713 ns 7,118.728 ns -

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