-
Notifications
You must be signed in to change notification settings - Fork 15
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
simplify the query
implementation
#121
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Krastanov
added
Skip-Changelog
label for control of CI: skips the changelog check
completed experiment
testing an approach to do something (but different approach taken at the end)
labels
Jun 4, 2024
some more microbenchmarks showing more clearly the order-of-magnitude difference:
|
``` reg = Register(5) tag!(reg[3], EntanglementCounterpart, 1, 10) tag!(reg[3], EntanglementCounterpart, 2, 21) tag!(reg[3], EntanglementCounterpart, 3, 30) tag!(reg[3], EntanglementCounterpart, 2, 22) tag!(reg[3], EntanglementCounterpart, 1, 10) tag!(reg[3], EntanglementCounterpart, 6, 60) tag!(reg[3], EntanglementCounterpart, 2, 23) tag!(reg[3], EntanglementCounterpart, 1, 10) @benchmark QuantumSavory._query(reg, Val{false}(), Val{true}(), EntanglementCounterpart, 6, ❓) BenchmarkTools.Trial: 10000 samples with 9 evaluations. Range (min … max): 2.281 μs … 511.600 μs ┊ GC (min … max): 0.00% … 98.50% Time (median): 2.343 μs ┊ GC (median): 0.00% Time (mean ± σ): 2.505 μs ± 7.238 μs ┊ GC (mean ± σ): 4.67% ± 1.70% ▂▆██▆▅▄▃▂▂▁▁ ▂ ██████████████▇▆▆▆▅▅▄▆▆▅▆▇▆▅▆▆▆▄▅▁▄▃▅▆▆▆▆▆▅▄▃▅▅▆▅▄▄▆▄▄▅▄▅▄▄ █ 2.28 μs Histogram: log(frequency) by time 3.46 μs < Memory estimate: 2.64 KiB, allocs estimate: 67. after new: vararg union BenchmarkTools.Trial: 10000 samples with 10 evaluations. Range (min … max): 1.239 μs … 181.067 μs ┊ GC (min … max): 0.00% … 98.00% Time (median): 1.315 μs ┊ GC (median): 0.00% Time (mean ± σ): 1.491 μs ± 3.010 μs ┊ GC (mean ± σ): 3.41% ± 1.69% ▄▇█▇▆▅▃▂▂▁▁ ▁ ▂▃▂ ▁▂▂▁ ▁▁ ▂ ▇███████████▇▅▆▄▃▄▃▄▄▃▅▂▄▄▆▆███▇▇▆█████████████████▇▇███▇▆▆ █ 1.24 μs Histogram: log(frequency) by time 2.26 μs < Memory estimate: 2.34 KiB, allocs estimate: 63. after new vararg union n BenchmarkTools.Trial: 10000 samples with 129 evaluations. Range (min … max): 734.426 ns … 16.797 μs ┊ GC (min … max): 0.00% … 92.30% Time (median): 772.566 ns ┊ GC (median): 0.00% Time (mean ± σ): 844.180 ns ± 737.678 ns ┊ GC (mean ± σ): 4.46% ± 4.87% ▁▅██▆▃▃▂▂▂▂▁▁▁ ▁▁ ▂ ▄████████████████▇▇▇▇▇▆▆▆▆▆▅▅▄▅▄▅▄▄▄▂▂▄▃▄▂▂▄▄▄▄▄▇██████▇▇▅▅▆▄ █ 734 ns Histogram: log(frequency) by time 1.26 μs < Memory estimate: 1.44 KiB, allocs estimate: 38. after cleaning up the `good` loop BenchmarkTools.Trial: 10000 samples with 238 evaluations. Range (min … max): 315.601 ns … 13.549 μs ┊ GC (min … max): 0.00% … 93.98% Time (median): 344.792 ns ┊ GC (median): 0.00% Time (mean ± σ): 410.885 ns ± 537.236 ns ┊ GC (mean ± σ): 6.80% ± 5.07% ▄▆▇██▆▆▅▄▃▂▂▁▁▁ ▂▃▃▃▄▃▂▁▁ ▂ ███████████████████▇▇█▇▇▆▇▆▅▅▅▃▅▄▅▅▄▃▂▃▃▄▆▇███████████▇▇▇▇▆▅▆ █ 316 ns Histogram: log(frequency) by time 640 ns < Memory estimate: 864 bytes, allocs estimate: 19. after cleaning up the `good` loop and ending it early and adding inbounds BenchmarkTools.Trial: 10000 samples with 250 evaluations. Range (min … max): 319.484 ns … 12.822 μs ┊ GC (min … max): 0.00% … 95.55% Time (median): 339.724 ns ┊ GC (median): 0.00% Time (mean ± σ): 407.820 ns ± 559.269 ns ┊ GC (mean ± σ): 7.25% ± 5.18% ▃▆██▇▅▅▄▃▃▂▁ ▁▁▃▃▃▃▃▂▂▁▁▁ ▂ █████████████▇▇▇▆▇▆▆▆▇▆▆▇▅▅▆▆▃▅▅▄▄▁▃▁▃▃▁▄▃▆██████████████▇▇▆▆ █ 319 ns Histogram: log(frequency) by time 642 ns < Memory estimate: 864 bytes, allocs estimate: 19. after adding @propagate_inbounds BenchmarkTools.Trial: 10000 samples with 318 evaluations. Range (min … max): 271.113 ns … 8.674 μs ┊ GC (min … max): 0.00% … 92.87% Time (median): 287.305 ns ┊ GC (median): 0.00% Time (mean ± σ): 330.077 ns ± 403.618 ns ┊ GC (mean ± σ): 7.28% ± 5.74% ▁▅██▇▅▄▃▂▂▁▁ ▂▂▂▁▁ ▂ ████████████████████▆█▇▇▇▇▄▆▆▅▅▅▄▄▄▅▅▄▅▅▃▄▅▁▄▅▄▄▄▃▁▄▆███████▆ █ 271 ns Histogram: log(frequency) by time 544 ns < Memory estimate: 864 bytes, allocs estimate: 19. after removing the `reverse` BenchmarkTools.Trial: 10000 samples with 359 evaluations. Range (min … max): 254.019 ns … 6.402 μs ┊ GC (min … max): 0.00% … 93.36% Time (median): 261.972 ns ┊ GC (median): 0.00% Time (mean ± σ): 300.217 ns ± 314.340 ns ┊ GC (mean ± σ): 5.90% ± 5.42% ▃██▅▄▄▃▃▂▁ ▁▃▄▃▁▁ ▂ ████████████▇▆▇▆▆▄▆▄▄▁▄▄▃▁▄██▅▅▆▄▁▃▃▃▄▃▅▅▃▁▄▁▃▄▁▅▇████████▇▆▆ █ 254 ns Histogram: log(frequency) by time 468 ns < Memory estimate: 672 bytes, allocs estimate: 18. ```
after removing the `reverse` BenchmarkTools.Trial: 10000 samples with 359 evaluations. Range (min … max): 254.019 ns … 6.402 μs ┊ GC (min … max): 0.00% … 93.36% Time (median): 261.972 ns ┊ GC (median): 0.00% Time (mean ± σ): 300.217 ns ± 314.340 ns ┊ GC (mean ± σ): 5.90% ± 5.42% ▃██▅▄▄▃▃▂▁ ▁▃▄▃▁▁ ▂ ████████████▇▆▇▆▆▄▆▄▄▁▄▄▃▁▄██▅▅▆▄▁▃▃▃▄▃▅▅▃▁▄▁▃▄▁▅▇████████▇▆▆ █ 254 ns Histogram: log(frequency) by time 468 ns < Memory estimate: 672 bytes, allocs estimate: 18. factoring out a single `query_good(N::Int, tag::Tag, queryargs...)` BenchmarkTools.Trial: 10000 samples with 390 evaluations. Range (min … max): 248.241 ns … 6.743 μs ┊ GC (min … max): 0.00% … 93.44% Time (median): 257.900 ns ┊ GC (median): 0.00% Time (mean ± σ): 278.917 ns ± 294.070 ns ┊ GC (mean ± σ): 4.95% ± 4.51% ▁▄▆██▅▃▃▃▂▁ ▁▁▁▁▁ ▂ █████████████▆▇▇▇▆▆▇▆▆▄▇▅▅▅▃▄▄▄▃▁▃▄▁▃▃▄▅▄▄▁▄▁▁▃▄▁▄▃▃▄▄▇██████ █ 248 ns Histogram: log(frequency) by time 395 ns < Memory estimate: 448 bytes, allocs estimate: 11. factoring out many macro-generated `query_good(n::Int, tag::Tag, a, ...)` BenchmarkTools.Trial: 10000 samples with 839 evaluations. Range (min … max): 149.449 ns … 5.746 μs ┊ GC (min … max): 0.00% … 96.28% Time (median): 155.396 ns ┊ GC (median): 0.00% Time (mean ± σ): 187.805 ns ± 199.312 ns ┊ GC (mean ± σ): 7.36% ± 6.75% ▃▇█▆▅▄▃▁▁ ▂▄▄▃▃▂▁▁ ▂ █████████████▇▅▆▆▃▅▄▄▄▃▄▃▃▃▃▄▄▃▃▄▁▄▄▃▁▄▃▄▁▃▄▁▄▁▄▇████████████ █ 149 ns Histogram: log(frequency) by time 288 ns < Memory estimate: 448 bytes, allocs estimate: 11.
…d avoiding Vararg) same benchmark as previous commit factoring out many macro-generated `query_good(n::Int, tag::Tag, a, ...)` BenchmarkTools.Trial: 10000 samples with 839 evaluations. Range (min … max): 149.449 ns … 5.746 μs ┊ GC (min … max): 0.00% … 96.28% Time (median): 155.396 ns ┊ GC (median): 0.00% Time (mean ± σ): 187.805 ns ± 199.312 ns ┊ GC (mean ± σ): 7.36% ± 6.75% ▃▇█▆▅▄▃▁▁ ▂▄▄▃▃▂▁▁ ▂ █████████████▇▅▆▆▃▅▄▄▄▃▄▃▃▃▃▄▄▃▃▄▁▄▄▃▁▄▃▄▁▃▄▁▄▁▄▇████████████ █ 149 ns Histogram: log(frequency) by time 288 ns < Memory estimate: 448 bytes, allocs estimate: 11. using @Cases in the macro-generated `query_good` BenchmarkTools.Trial: 10000 samples with 962 evaluations. Range (min … max): 83.297 ns … 4.867 μs ┊ GC (min … max): 0.00% … 97.14% Time (median): 87.609 ns ┊ GC (median): 0.00% Time (mean ± σ): 93.590 ns ± 67.695 ns ┊ GC (mean ± σ): 2.36% ± 4.16% ▃█▆▆▇▄▃▂▂ ▁ ▁▁▁▁▁▁ ▂ ███████████████▇▇▇▇▇▆▆▆▅▅▆▆███████▇▇▇▆▆▆▇▇▆▄▆▅▃▄▄▃▄▅▁▄▄▃▄▁▄ █ 83.3 ns Histogram: log(frequency) by time 156 ns < Memory estimate: 128 bytes, allocs estimate: 1.
Krastanov
removed
completed experiment
testing an approach to do something (but different approach taken at the end)
Skip-Changelog
label for control of CI: skips the changelog check
labels
Jun 5, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #121 +/- ##
==========================================
- Coverage 73.62% 73.45% -0.18%
==========================================
Files 38 38
Lines 1695 1695
==========================================
- Hits 1248 1245 -3
- Misses 447 450 +3 ☔ View full report in Codecov by Sentry. |
Krastanov
force-pushed
the
simplifyquery
branch
2 times, most recently
from
June 5, 2024 04:40
e4bb649
to
634daa3
Compare
…than the original, chiefly by avoiding varargs (thanks to macro-expanding separate methods for each number of arguments)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This code is drastically simpler than the original implementation, but also much slower:
Kept here as a reference and for potential future work that might be both simpler and faster.