Skip to content
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

Open
wants to merge 8 commits into
base: 8.x.x
Choose a base branch
from

Conversation

lbloder
Copy link
Collaborator

@lbloder lbloder commented Oct 7, 2024

📜 Description

Use LazyEvaluator to generate UUID on demand in

  • SpanId
  • SentryId

💡 Motivation and Context

Fixes #3325

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link
Contributor

github-actions bot commented Oct 7, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f2fba85

@lbloder lbloder marked this pull request as ready for review October 7, 2024 11:59
@Angelodaniel
Copy link
Member

Hey @lbloder, I was wondering on how did you test this part? It's not included in the PR.

@adinauer
Copy link
Member

adinauer commented Oct 9, 2024

@Angelodaniel do you expect problems somewhere? If so, what areas?

Copy link
Contributor

github-actions bot commented Oct 9, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 427.50 ms 489.06 ms 61.56 ms
Size 1.70 MiB 2.36 MiB 670.54 KiB

Previous results on branch: feat/lazy-span-id-v8

Startup times

Revision Plain With Sentry Diff
2601edf 472.73 ms 518.83 ms 46.10 ms
234085b 560.06 ms 587.22 ms 27.16 ms
081906a 544.44 ms 604.34 ms 59.90 ms

App size

Revision Plain With Sentry Diff
2601edf 1.70 MiB 2.35 MiB 669.02 KiB
234085b 1.70 MiB 2.36 MiB 670.52 KiB
081906a 1.70 MiB 2.35 MiB 665.19 KiB

}

@Override
public String toString() {
return StringUtils.normalizeUUID(uuid.toString()).replace("-", "");
return StringUtils.normalizeUUID(lazyValue.getValue().toString()).replace("-", "");

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.

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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Collaborator Author

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.

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?

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants