Skip to content

Optimize attaching the debug probes - #4619

Open
dkhalanskyjb wants to merge 2 commits into
developfrom
dkhalanskyjb/optimize-debug-probes-attach
Open

Optimize attaching the debug probes#4619
dkhalanskyjb wants to merge 2 commits into
developfrom
dkhalanskyjb/optimize-debug-probes-attach

Conversation

@dkhalanskyjb

@dkhalanskyjb dkhalanskyjb commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

I see a notable speed improvement even without any benchmarks, simply by running DebugProbes.withDebugProbes { } in a loop.

As I see, the change should be completely transparent for the user. Class.forName used to run with the class loader of the ByteBuddyDynamicAttach class, which itself is loaded by ByteBuddyDynamicAttach. This hasn't changed—there is still no other code that can access ByteBuddyDynamicAttach, and transitively, the AttachKt fields.

@dkhalanskyjb
dkhalanskyjb force-pushed the dkhalanskyjb/optimize-debug-probes-attach branch from 0d30d40 to 95460b5 Compare June 2, 2026 12:27
I see a notable speed improvement even without any benchmarks,
simply by running `DebugProbes.withDebugProbes { }` in a loop.
@dkhalanskyjb
dkhalanskyjb force-pushed the dkhalanskyjb/optimize-debug-probes-attach branch from 95460b5 to 57c7902 Compare June 2, 2026 12:55
@dkhalanskyjb
dkhalanskyjb marked this pull request as ready for review June 2, 2026 12:59
@fzhinkin
fzhinkin self-requested a review June 12, 2026 19:15
@qwwdfsad
qwwdfsad self-requested a review June 25, 2026 09:44

@qwwdfsad qwwdfsad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch!

Nit -- please consider explaining what has been done in the commit message

Comment thread kotlinx-coroutines-debug/src/Attach.kt Outdated
}
}

private val targetClassLoader = Class.forName(classNameToOverride).classLoader

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These things probably belong to ByteBuddyDynamicAttach's companion, potentially as @JvmStatic encapsulation-wise.

Beware of targetClassLoader computed eagerly in that case though

@dkhalanskyjb
dkhalanskyjb force-pushed the dkhalanskyjb/optimize-debug-probes-attach branch from edd5ade to fb09810 Compare July 13, 2026 11:04
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