Skip to content

Conversation

@mitikov
Copy link
Contributor

@mitikov mitikov commented Jul 28, 2025

The goal is to draw a base line for these ops. Despite vectorization seem possible, it may not be worth it since arrays might be too small.

These tests will be a base line for us to measure.

Local (dev) machine results:

BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.4652)
AMD Ryzen 7 6800H with Radeon Graphics, 1 CPU, 16 logical and 8 physical cores
.NET SDK 9.0.200
[Host] : .NET 8.0.13 (8.0.1325.6609), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.13 (8.0.1325.6609), X64 RyuJIT AVX2

Method Size Mean Error StdDev Allocated
Or 1000 131.29 us 2.522 us 2.359 us 445.31 KB
Xor 1000 129.00 us 2.352 us 2.200 us 445.31 KB
And 1000 78.00 us 0.887 us 0.786 us 250 KB
AndNot 1000 105.83 us 1.315 us 1.230 us 250 KB

Monster dev machine:

BenchmarkDotNet v0.14.0, Windows 10 (10.0.19045.6093/22H2/2022Update)
AMD Ryzen 9 3900XT, 1 CPU, 24 logical and 12 physical cores
.NET SDK 9.0.100
[Host] : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.7 (8.0.724.31311), X64 RyuJIT AVX2

Method Size Mean Error StdDev Allocated
Or 1000 134.52 us 2.532 us 2.487 us 445.31 KB
Xor 1000 119.92 us 2.008 us 1.878 us 445.31 KB
And 1000 70.56 us 1.791 us 5.168 us 250 KB
AndNot 1000 117.32 us 2.273 us 3.332 us 250 KB

Moster should be ~10% faster for single-core ops & have ~10 % better memory -> only 'AND & XOr' are affected:

https://cpu.userbenchmark.com/Compare/AMD-Ryzen-9-3900XT-vs-AMD-Ryzen-7-6800H/m1202614vsm1786492

@mitikov
Copy link
Contributor Author

mitikov commented Jul 28, 2025

Spoiler alert: After multiple cycles of attempts to apply vectorization, it seem not to breeze in more speed, at best stays on same level:

| OrScalar | 1000 | 34.62 ms |
| OrVector | 1000 | 34.94 ms |
| XorScalar | 1000 | 32.84 ms |
| XorVector | 1000 | 34.87 ms |
| AndNotScalar | 1000 | 32.46 ms |
| AndNotVector | 1000 | 34.63 ms |

It seem the reason is - vectorization shines out on large data scales (aka slow-start), while current use-case is pushed-to-the-ground (finite data).

That is why this PR is only about setting the base line.

@ogxd ogxd merged commit 0663031 into equativ:main Jul 31, 2025
1 check passed
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.

2 participants