fix(grouping): Only collect metadata timing metric when actually getting metadata #81252
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.
In #81070, a metric was added to time the gathering of grouphash metadata. Unfortunately, it's also timing all the cases in which we don't have to gather such data as well (which are the vast, vast majority of cases - for example, in the last 24 hours, we’ve hit roughly 2.5 million cases where the function it's timing has no-opped and only about 400 in which the function's actually had to do any work). As a result, the actual timing data we care about is being utterly drowned out.
This fixes that by moving the timer from timing
create_or_update_grouphash_metadata
to timing it's helper,get_hash_basis_and_metadata
, which only runs when the calculation is needed. It also renames the function we have been timing fromcreate_or_update_grouphash_metadata
tocreate_or_update_grouphash_metadata_if_needed
, to make it clearer that it's just a wrapper which may no-op. (It's this unclear naming on my part which led to the confusion in the first place.)