Skip to content

perf(core): Remove addNonEnumerableProperty from packages/core/src/tracing/utils.ts #15811

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

Closed

Conversation

AbhiPrasad
Copy link
Member

Extracted from #15765

resolves #15810

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.

`packages/core/src/tracing/utils.ts`
@AbhiPrasad AbhiPrasad requested a review from a team March 24, 2025 16:55
@AbhiPrasad AbhiPrasad self-assigned this Mar 24, 2025
@AbhiPrasad AbhiPrasad requested review from mydea and s1gr1d and removed request for a team March 24, 2025 16:55
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.2 KB -0.04% -8 B 🔽
@sentry/browser - with treeshaking flags 23.01 KB -0.02% -4 B 🔽
@sentry/browser (incl. Tracing) 36.61 KB -0.01% -3 B 🔽
@sentry/browser (incl. Tracing, Replay) 73.78 KB -0.02% -9 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.1 KB -0.02% -11 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 78.41 KB -0.02% -10 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 90.99 KB -0.02% -10 B 🔽
@sentry/browser (incl. Feedback) 40.33 KB -0.02% -6 B 🔽
@sentry/browser (incl. sendFeedback) 27.84 KB -0.03% -8 B 🔽
@sentry/browser (incl. FeedbackAsync) 32.62 KB -0.03% -9 B 🔽
@sentry/react 25 KB -0.02% -5 B 🔽
@sentry/react (incl. Tracing) 38.5 KB -0.02% -7 B 🔽
@sentry/vue 27.43 KB -0.02% -5 B 🔽
@sentry/vue (incl. Tracing) 38.29 KB -0.01% -3 B 🔽
@sentry/svelte 23.24 KB -0.03% -5 B 🔽
CDN Bundle 24.42 KB -0.03% -7 B 🔽
CDN Bundle (incl. Tracing) 36.62 KB -0.02% -6 B 🔽
CDN Bundle (incl. Tracing, Replay) 71.61 KB -0.01% -6 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 76.82 KB -0.01% -6 B 🔽
CDN Bundle - uncompressed 71.38 KB -0.01% -7 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 108.57 KB -0.01% -5 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.83 KB -0.01% -5 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 232.39 KB -0.01% -5 B 🔽
@sentry/nextjs (client) 39.8 KB -0.02% -7 B 🔽
@sentry/sveltekit (client) 37.02 KB -0.03% -8 B 🔽
@sentry/node 142.6 KB -0.01% -7 B 🔽
@sentry/node - without tracing 95.98 KB -0.02% -11 B 🔽
@sentry/aws-serverless 120.34 KB -0.01% -8 B 🔽

View base workflow run

@AbhiPrasad
Copy link
Member Author

So it seems this is the one that CI does not like.

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

Remove addNonEnumerableProperty from packages/core/src/tracing/utils.ts
1 participant