You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now for handling doubles prometheus.erl uses gen_server (because there is no ets:update_counter for doubles). This PR intended to provide nif based alternative for gen_server.
So there is no big speed difference, and in theory dincs can be removed entirely.
OTOH doubles are finite on both ERTS and C sides while int counters currently not.
And we going NIF-way inc can be implemented with fetch_and_add.
However:
CAS loop can be very long - we can block scheduler.
Current NIF benchmark doesn't perform counter resolving - this has to be done as ETS lookup
with possible optimization (like Benoit does) - provide with wrapper and store resource in process-dict.
Also on lookups - first metric use looks now like this:
inc -> badarg -> insert_metric, Next call: just inc (ets:update_counter)
first call when using nif:
inc -> no_resource -> create_resource -> insert to ets -> increment
Next call -> ets:lookup -> increment.
And with replaces ets:lookup with get and adds put to the first call.
This file contains hidden or 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
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.
Now for handling doubles prometheus.erl uses gen_server (because there is no ets:update_counter for doubles). This PR intended to provide nif based alternative for gen_server.
Benchmark for ets:update_counter-based counter:
Results for dinc (without call_timeout adjusted):
Results for double + atomic_compare_exchange_strong
cc @benoitc