Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

predicates/host: add HostAny benchmark #3239

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

AlexanderYastrebov
Copy link
Member

Current implementation uses linear probe that works well for small number of hosts.

I thought about implementing it using map lookup but that is slower for less than 50 hosts so I propose to only keep the benchmark that may be used for future improvements.

Here is comparison with map-based implementation for reference:

              │    HEAD~1    │                 HEAD                  │
              │    sec/op    │    sec/op      vs base                │
HostAny/1-8      3.738n ± 3%    5.844n ±  3%  +56.36% (p=0.000 n=10)
HostAny/2-8      7.728n ± 4%    9.274n ±  2%  +20.02% (p=0.000 n=10)
HostAny/5-8      11.32n ± 4%    13.09n ±  4%  +15.63% (p=0.000 n=10)
HostAny/10-8     22.35n ± 3%    11.86n ± 15%  -46.94% (p=0.000 n=10)
HostAny/20-8     7.684n ± 2%   11.310n ±  9%  +47.19% (p=0.000 n=10)
HostAny/50-8     66.75n ± 4%    12.10n ± 12%  -81.87% (p=0.000 n=10)
HostAny/100-8   161.80n ± 1%    11.92n ± 13%  -92.63% (p=0.000 n=10)
geomean          17.98n         10.46n        -41.79%

              │    HEAD~1    │                HEAD                 │
              │     B/op     │    B/op     vs base                 │
HostAny/1-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/2-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/5-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/10-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/20-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/50-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/100-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

              │    HEAD~1    │                HEAD                 │
              │  allocs/op   │ allocs/op   vs base                 │
HostAny/1-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/2-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/5-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/10-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/20-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/50-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/100-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

Current implementation uses linear probe that works well for small number
of hosts.

I thought about implementing it using map lookup but that is slower for
less than 50 hosts so I propose to only keep the benchmark that may be used
for future improvements.

Here is comparison with map-based implementation for reference:
```
              │    HEAD~1    │                 HEAD                  │
              │    sec/op    │    sec/op      vs base                │
HostAny/1-8      3.738n ± 3%    5.844n ±  3%  +56.36% (p=0.000 n=10)
HostAny/2-8      7.728n ± 4%    9.274n ±  2%  +20.02% (p=0.000 n=10)
HostAny/5-8      11.32n ± 4%    13.09n ±  4%  +15.63% (p=0.000 n=10)
HostAny/10-8     22.35n ± 3%    11.86n ± 15%  -46.94% (p=0.000 n=10)
HostAny/20-8     7.684n ± 2%   11.310n ±  9%  +47.19% (p=0.000 n=10)
HostAny/50-8     66.75n ± 4%    12.10n ± 12%  -81.87% (p=0.000 n=10)
HostAny/100-8   161.80n ± 1%    11.92n ± 13%  -92.63% (p=0.000 n=10)
geomean          17.98n         10.46n        -41.79%

              │    HEAD~1    │                HEAD                 │
              │     B/op     │    B/op     vs base                 │
HostAny/1-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/2-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/5-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/10-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/20-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/50-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/100-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

              │    HEAD~1    │                HEAD                 │
              │  allocs/op   │ allocs/op   vs base                 │
HostAny/1-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/2-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/5-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/10-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/20-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/50-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/100-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

Signed-off-by: Alexander Yastrebov <[email protected]>
@AlexanderYastrebov AlexanderYastrebov added the minor no risk changes, for example new filters label Sep 19, 2024
@MustafaSaber
Copy link
Member

👍

1 similar comment
@AlexanderYastrebov
Copy link
Member Author

👍

@AlexanderYastrebov AlexanderYastrebov merged commit 7f6f037 into master Sep 19, 2024
14 checks passed
@AlexanderYastrebov AlexanderYastrebov deleted the predicates/host/hostany-benchmark branch September 19, 2024 17:47
Pushpalanka pushed a commit that referenced this pull request Oct 11, 2024
Current implementation uses linear probe that works well for small number
of hosts.

I thought about implementing it using map lookup but that is slower for
less than 50 hosts so I propose to only keep the benchmark that may be used
for future improvements.

Here is comparison with map-based implementation for reference:
```
              │    HEAD~1    │                 HEAD                  │
              │    sec/op    │    sec/op      vs base                │
HostAny/1-8      3.738n ± 3%    5.844n ±  3%  +56.36% (p=0.000 n=10)
HostAny/2-8      7.728n ± 4%    9.274n ±  2%  +20.02% (p=0.000 n=10)
HostAny/5-8      11.32n ± 4%    13.09n ±  4%  +15.63% (p=0.000 n=10)
HostAny/10-8     22.35n ± 3%    11.86n ± 15%  -46.94% (p=0.000 n=10)
HostAny/20-8     7.684n ± 2%   11.310n ±  9%  +47.19% (p=0.000 n=10)
HostAny/50-8     66.75n ± 4%    12.10n ± 12%  -81.87% (p=0.000 n=10)
HostAny/100-8   161.80n ± 1%    11.92n ± 13%  -92.63% (p=0.000 n=10)
geomean          17.98n         10.46n        -41.79%

              │    HEAD~1    │                HEAD                 │
              │     B/op     │    B/op     vs base                 │
HostAny/1-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/2-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/5-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/10-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/20-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/50-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/100-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

              │    HEAD~1    │                HEAD                 │
              │  allocs/op   │ allocs/op   vs base                 │
HostAny/1-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/2-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/5-8     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/10-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/20-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/50-8    0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
HostAny/100-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                    ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

Signed-off-by: Alexander Yastrebov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor no risk changes, for example new filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants