Skip to content

Performance critical tracing code has high overhead due to the use of the Stream API #46838

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
wants to merge 1 commit into from

Conversation

shakuzen
Copy link
Member

Injection or extraction of the tracing context happens on each request. For example, on each call with an HTTP client or handled by a Controller that's instrumented. The Stream API used here was showing up on CPU profiling under heavy load. With these changes, the CPU profiling looks better while maintaining the same behavior as before.

Before (Stream API highlighted)
image

After
image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 14, 2025
@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 14, 2025
@mhalbritter mhalbritter added this to the 3.4.x milestone Aug 14, 2025
Injection and extraction of the tracing context happens on each request. For example, on each call to a Controller or HTTP client.
The Stream API used here was showing up on CPU profiling under heavy load. With these changes, the CPU profiling looks better.
@philwebb philwebb self-assigned this Aug 14, 2025
@philwebb philwebb modified the milestones: 3.4.x, 3.4.9 Aug 14, 2025
philwebb pushed a commit that referenced this pull request Aug 14, 2025
Update composite tracing support to remove Stream API calls from
injection and extraction methods which happen on each request.

See gh-46838
@philwebb philwebb closed this in aab5641 Aug 14, 2025
@philwebb
Copy link
Member

Thanks @shakuzen!

@wilkinsona wilkinsona changed the title Avoid Stream API in performance critical tracing code Performance critical tracing code has high overhead due to the use of the Stream API Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants