-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Performance regression for ets:select/3
with a map in the keys
#8469
Comments
Thanks for your report, I hate to say it but this is roughly the performance difference I’d expect. The partially matching nature of maps ( I will look into adding a way to match maps exactly, but that will not make it in before OTP 27.1 at the earliest. |
Thanks for the quick reply. The performance difference makes sense when you consider that it's a linear scan, which also explains the difference between I've worked around the issue on my side for now, but I suspect this could trip up other applications. |
I think this somewhat comes from the ETS interface completely intertwining access by patterns and access by key. In my opinion the proper, long-term solution would be to separate the two. They have very different performance characteristics where a difference between key lookup vs linear scan can be very subtle and unexpected - they should be separate APIs. |
Aren't they separated already? |
@jhogberg right, but with no In OpenTelemetry we, for now, not sure what long term will look like, do |
For the metrics mentioned above I switched to |
@ferd had a similar idea. Though his was to still have the map in the key and use an ordered set. Since wouldn't you need to use a But I guess if you are already using |
Oh I missed this:
Yaya! Solves my request for |
The key is itself a tuple of a series name, a hash of the labels, and a timestamp. The table is an |
Describe the bug
There is a severe performance regression for
ets:select/3
when keys contain a map.To Reproduce
This benchmark (in Elixir, sorry) reproduces the issue and demonstrates the difference between OTP 26.2.4 and 26.2.5.
Here's the relevant portion of the benchmark for OTP 26.2.5:
Removing the map portion of the key alleviates the issue, and adds a nice speed boost for all operations:
Expected behavior
There shouldn't be such an extreme difference in performance.
Affected versions
OTP 26.2.5
Additional context
Originally reported in this oban issue.
The text was updated successfully, but these errors were encountered: