-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Lazy uuid generation for SentryId and SpanId #3770
Conversation
|
Hey @lbloder, I was wondering on how did you test this part? It's not included in the PR. |
@Angelodaniel do you expect problems somewhere? If so, what areas? |
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
081906a | 544.44 ms | 604.34 ms | 59.90 ms |
e2e56a0 | 417.82 ms | 484.86 ms | 67.04 ms |
234085b | 560.06 ms | 587.22 ms | 27.16 ms |
2601edf | 472.73 ms | 518.83 ms | 46.10 ms |
ab1b958 | 427.50 ms | 489.06 ms | 61.56 ms |
5132e04 | 431.47 ms | 443.96 ms | 12.49 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
081906a | 1.70 MiB | 2.35 MiB | 665.19 KiB |
e2e56a0 | 1.70 MiB | 2.36 MiB | 670.59 KiB |
234085b | 1.70 MiB | 2.36 MiB | 670.52 KiB |
2601edf | 1.70 MiB | 2.35 MiB | 669.02 KiB |
ab1b958 | 1.70 MiB | 2.36 MiB | 670.54 KiB |
5132e04 | 1.70 MiB | 2.36 MiB | 670.58 KiB |
} | ||
|
||
@Override | ||
public String toString() { | ||
return StringUtils.normalizeUUID(uuid.toString()).replace("-", ""); | ||
return StringUtils.normalizeUUID(lazyValue.getValue().toString()).replace("-", ""); |
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.
This toString is called from multiple places. since uuid wont be changes. it is good to cache that. but also this toString will do unnecessary calculations.
Please consider holding toString value instead of uuid similar to SpanId or also cache the toString 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.
It is more related to #3772
But if toString is called right after creating SentryId, it wont help much of delaying this UUID cost.
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.
@adinauer -> Please see comment from @kozaxinan
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.
Yeah, we should measure impact of this PR. I'm afraid this doesn't have the desired effect due to toString()
, hashCode
and equals
being called early. Caching the value for toString()
might have a bigger impact, thanks for the suggestion.
Changing how we use IDs (i.e. only generate them when sending) will be a bigger change and I'm not entirely certain it's possible. Offering a configurable ID generation mechanism might be the better approach. We'll discuss internally and update once we know more.
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.
@kozaxinan Good point, I'll rework SentryId
to cache the resulting String
instead of the UUID
object.
As mentioned by @adinauer, measuring the performance impact of this change has yet to be done.
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.
Nice this will allow more improvement. Will this be ported to version 7?
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.
@kozaxinan we're planning to explore multiple options to improve the SDK. We can check which of those make sense to port to v7 when we know which ones we'll keep.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
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.
just some cleanup, but looks good!
do we already know the impact of this change?
Co-authored-by: Stefano <[email protected]>
Co-authored-by: Stefano <[email protected]>
Co-authored-by: Stefano <[email protected]>
Co-authored-by: Stefano <[email protected]>
Co-authored-by: Stefano <[email protected]>
…e difference of .equals if objects are not the same
…va into feat/lazy-span-id-v8
@stefanosiano I did some tests regarding performance of this change and found another issue, that i fixed in a new commit, if you could take another look that would be great. The It does not change much in terms of startup time (as reported by Sentry) on a Motorola moto e22 low-end device with Android 12. However, most of the calls that lead to UUID generation is now done on backround Threads: 8.x.x branch:
Lazy branch:
|
Will this be cheery picked to the current version? |
@kozaxinan we're working on releasing another beta for v8 and plan to have it GA soonish so we'd rather focus on v8 than backporting to v7 unless this is a blocking problem for someone. |
I understand the process. But it is not clear when 8 will be available and when the general audience will migrate. |
v8 GA is planned for mid of December and upgrading should be straight forward. We've just released |
📜 Description
Use LazyEvaluator to generate UUID on demand in
💡 Motivation and Context
Fixes #3325
💚 How did you test it?
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps