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

perf(core): Remove usage of addNonEnumerableProperty from span utils #15765

Closed

Conversation

AbhiPrasad
Copy link
Member

ref #15725 (comment)

addNonEnumerableProperty is pretty expensive because of Object.defineProperty, so this changes usage of span utils (which are called frequently) to avoid usage of addNonEnumerableProperty.

addNonEnumerableProperty is replaced with weak maps, which has the added benefit of being more GC friendly (addNonEnumerableProperty causes hard references to be created between the objects).

The only downside of switching to this approach is that we lose the try catch built into addNonEnumerableProperty, but I think thats fine given the nature of the changed methods.

@AbhiPrasad AbhiPrasad requested review from mydea and a team March 21, 2025 01:18
@AbhiPrasad AbhiPrasad self-assigned this Mar 21, 2025
@AbhiPrasad AbhiPrasad requested review from andreiborza and removed request for a team March 21, 2025 01:18
Copy link
Contributor

github-actions bot commented Mar 21, 2025

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 23.2 KB -0.04% -8 B 🔽
@sentry/browser - with treeshaking flags 23.01 KB -0.03% -6 B 🔽
@sentry/browser (incl. Tracing) 36.6 KB -0.04% -12 B 🔽
@sentry/browser (incl. Tracing, Replay) 73.77 KB -0.03% -19 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.09 KB -0.04% -21 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 78.4 KB -0.03% -20 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 90.98 KB -0.02% -18 B 🔽
@sentry/browser (incl. Feedback) 40.33 KB -0.03% -10 B 🔽
@sentry/browser (incl. sendFeedback) 27.84 KB -0.04% -9 B 🔽
@sentry/browser (incl. FeedbackAsync) 32.62 KB -0.04% -12 B 🔽
@sentry/react 24.99 KB -0.03% -7 B 🔽
@sentry/react (incl. Tracing) 38.49 KB -0.06% -21 B 🔽
@sentry/vue 27.42 KB -0.07% -18 B 🔽
@sentry/vue (incl. Tracing) 38.28 KB -0.04% -15 B 🔽
@sentry/svelte 23.23 KB -0.04% -8 B 🔽
CDN Bundle 24.42 KB -0.06% -14 B 🔽
CDN Bundle (incl. Tracing) 36.59 KB -0.09% -33 B 🔽
CDN Bundle (incl. Tracing, Replay) 71.58 KB -0.04% -29 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 76.79 KB -0.04% -30 B 🔽
CDN Bundle - uncompressed 71.39 KB +0.01% +5 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 108.59 KB +0.01% +11 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.84 KB +0.01% +11 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 232.41 KB +0.01% +11 B 🔺
@sentry/nextjs (client) 39.79 KB -0.05% -20 B 🔽
@sentry/sveltekit (client) 37.01 KB -0.04% -15 B 🔽
@sentry/node 142.58 KB -0.02% -24 B 🔽
@sentry/node - without tracing 95.96 KB -0.03% -27 B 🔽
@sentry/aws-serverless 120.32 KB -0.02% -24 B 🔽

View base workflow run

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

AbhiPrasad added a commit that referenced this pull request Mar 21, 2025
ref
#15725 (comment)

Similar to the work done in
#15765 we can avoid
usage of `addNonEnumerableProperty` with usage of a `WeakSet`.
@AbhiPrasad
Copy link
Member Author

No clue why this is failing.

I'm going to open up individual PRs for this, perhaps that will help

@AbhiPrasad AbhiPrasad force-pushed the abhi-remove-addNonEnumerableProperty-from-span-utils branch from a87a0de to a416137 Compare March 24, 2025 17:15
@AbhiPrasad
Copy link
Member Author

Seems like #15811 is causing the issue. Reverting changes in packages/core/src/tracing/utils.ts.

@AbhiPrasad
Copy link
Member Author

nvm 😢

@AbhiPrasad AbhiPrasad closed this Mar 24, 2025
@AbhiPrasad AbhiPrasad deleted the abhi-remove-addNonEnumerableProperty-from-span-utils branch March 24, 2025 19:02
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.

2 participants