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

Enable V8 Precise Coverage #2065

Open
pfumagalli opened this issue Apr 26, 2024 · 0 comments
Open

Enable V8 Precise Coverage #2065

pfumagalli opened this issue Apr 26, 2024 · 0 comments
Labels
feature request Request for Workers team to add a feature

Comments

@pfumagalli
Copy link

V8 allows to take precise coverage via the Chrome DevTools Protocol, but for some reason unknown to me, workerd prevents the standard CPU profiler to work, intercepting calls to Profiler.enable, Profiler.start and Profiler.stop.

Started digging, and from the V8 sources I saw that Profile.startPreciseCoverage is tied behind a flag (m_enabled) here.

Digging through the sources, I noticed that workerd intercepts most of the Profiler calls here.

I tried a simple patch (inspired by @jasnell's #329) to restore the full Profile set of calls, and, to my amazement, it worked perfectly and was able to capture the full precise coverage.

Not knowing the rationale behind intercepting these calls, I'm unsure as to whether to create a PR, but all tests are passing, and having code coverage in tests is fantastic.

(For the records, I'm the author of a tool that analyzes code coverage from V8, so, obviously, I'm biased and would love to have this working)

Attached is a simple patch to showcase the feature: profile.patch

@jasnell jasnell added the feature request Request for Workers team to add a feature label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for Workers team to add a feature
Projects
None yet
Development

No branches or pull requests

2 participants