-
Notifications
You must be signed in to change notification settings - Fork 10
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
Track PostingsForMatchers cached promise completion timestamp in trace #825
Track PostingsForMatchers cached promise completion timestamp in trace #825
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - feedback below is not blocking if you're happy with this as-is.
However, there's a small performance regression because
attribute.Stringer()
is not lazily evaluated, so the timestamp get stringified for every single call, even if that call is not traced.
What if we passed the timestamp as an integer (in seconds / milliseconds / whatever since the epoch), and used 0 to indicate "not completed"? Then we'd avoid the string conversion.
tsdb/postings_for_matchers_cache.go
Outdated
@@ -257,6 +262,7 @@ func (c *PostingsForMatchersCache) postingsForMatchersPromise(ctx context.Contex | |||
|
|||
c.metrics.hits.Inc() | |||
span.AddEvent("using cached postingsForMatchers promise", trace.WithAttributes( | |||
attribute.Stringer("cached promise evaluation completed at", evaluationCompletedAtTime(oldPromiseEvaluationCompletedAt)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be really nice if we were able to always include the timestamp somewhere, as that will make it much easier to confirm exactly which cache entry is being used.
Perhaps we could log evaluationCompletedAt
in postingsForMatchersPromise.result()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to result()
. There's still a regression using epoch, but a smaller one (I've updated the benchmark in the PR description).
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
353a544
to
8982998
Compare
@charleskorn I'm merging this after having addressed your comment. If you have any other (post-merge) comment, I will promptly address it. |
In #822 @charleskorn suggested to log the
PostingsForMatchers
cache promise completion timestamp in the trace. I'm doing it in this PR. However, there's a small performance regression introduced by the extra span event (using epoch timestamp to reduce the regression):