-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
deps,profiler: parse Windows' "%p" in processor #14510
Conversation
Running the profiler processor (--prof-process) with a profiler output file generated on Windows (with --prof) results in "UNKNOWN" code dominating the statistics. This is caused by the processor not correctly parsing the output of the "%p" format specifier on Windows, which prints 8 (in 32 bits) or 16 (in 64 bits) hexadecimal characters without the "0x" prefix. The profiler processor expects a format that is recognized by parseInt. This commit creates a thin layer on top of parseInt to parse the Windows "%p" format for memory addresses correctly. Fixes: nodejs#8221 Refs: v8/v8@9041833#diff-738e87867268a7b9c90329adc160855cR167
deps/v8/tools/tickprocessor.js
Outdated
*/ | ||
TickProcessor.prototype.parseIntAddressFormat = function(s, radix) { | ||
var re = /^([0-9A-Fa-f]{8}|[0-9A-Fa-f]{16})$/g | ||
if(s.match(re)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: space after if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Added a fixup commit.
deps/v8/tools/tickprocessor.js
Outdated
if(s.match(re)) { | ||
return parseInt(s,16) | ||
} else { | ||
return parseInt(s,radix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, nits: space after the ,
here and in the if
branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Added a fixup commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green.
Sorry, I’m just now realizing that this only changes files in Did you try upstreaming these changes to V8? We usually aren’t very keen on floating our own patches. Also, we’d be glad to help you bring this patch into V8, I know it can be a bit difficult to get used to their process. |
@addaleax I'm preparing to upstream the change to V8 as well. I decided to open a PR here first since it was ready and the changes were in response to #8221 , so the current issue can also be understood. I also took into account that the current V8 in Thanks for your help. I've already made a change upstream once. |
Just in case it helps avoid confusion, V8 doesn’t use semver and major versions go 5.8, 5.9, 6.0, 6.1, etc. without a huge difference between 5.9 and 6.0. We’re actually using V8 5.9 in |
So this should be closed and redirected to the V8 repository? And re-opened if V8 rejects it but we decide we want/need it? |
(Adding blocked label based on my above comment, but feel free to remove it or request that it be removed if I'm misguided here.) |
We can leave this PR open until there’s some upstream decision and turn it into a cherry-pick PR if we like. We can also close it for now, I guess, as long as we don’t forget about it. |
I've submitted it upstream here: Added @addaleax in CC as well. |
Another change was made upstream to make the ouput from the profiler be the same in Windows. https://chromium-review.googlesource.com/c/591373 So, I guess this PR can be discarded. |
Yes, this was fixed upstream in v8/v8@4229ca2. Feel free to open a cherry-pick PR. |
When V8 was updated to 5.4, the output format for memory addresses was changed from
0x%x
to%p
. The%p
format specified is implementation specific and behaves differently on Windows.Running the profiler processor (
--prof-process
) with a profiler output file generated on Windows (with--prof
) results in "UNKNOWN" code dominating the statistics. This is caused by the processor not correctly parsing the output of the%p
format specifier on Windows, which prints 8 (in 32 bits) or 16 (in 64 bits) hexadecimal characters without the0x
prefix. The profiler processor expects a format that is recognized byparseInt
.Example line from profiler output on Linux:
Example line from profiler output on Windows:
While the
0x12e0553593e0
address string from Linux will be correctly parsed byparseInt
in the profiler processor, the000000BABADD9640
address string from Windows will not.The commit on this PR creates a thin layer on top of
parseInt
to parse the Windows%p
format for memory addresses correctly.I've tried building V8 from source on windows to test the profiler behavior using
d8
andv8/tools/windows-tick-processor.bat
and confirmed this profiler issue is also currently present on Windows in V8's master branch.Fixes: #8221
Refs: #8317
Refs:
v8/v8@9041833#diff-738e87867268a7b9c90329adc160855cR167
/cc @nodejs/v8
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
deps,v8,win