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

deps,profiler: parse Windows' "%p" in processor #14510

Closed

Conversation

jaimecbernardo
Copy link
Contributor

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 the 0x prefix. The profiler processor expects a format that is recognized by parseInt.

Example line from profiler output on Linux:

code-creation,Builtin,5,0x12e0553593e0,327,"MathMax"

Example line from profiler output on Windows:

code-creation,Builtin,5,000000BABADD9640,304,"MathMax"

While the 0x12e0553593e0 address string from Linux will be correctly parsed by parseInt in the profiler processor, the 000000BABADD9640 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 and v8/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), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

deps,v8,win

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
@nodejs-github-bot nodejs-github-bot added the v8 engine Issues and PRs related to the V8 dependency. label Jul 27, 2017
*/
TickProcessor.prototype.parseIntAddressFormat = function(s, radix) {
var re = /^([0-9A-Fa-f]{8}|[0-9A-Fa-f]{16})$/g
if(s.match(re)) {
Copy link
Member

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

Copy link
Contributor Author

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.

if(s.match(re)) {
return parseInt(s,16)
} else {
return parseInt(s,radix)
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor

@XadillaX XadillaX left a 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.

@XadillaX
Copy link
Contributor

@addaleax
Copy link
Member

Sorry, I’m just now realizing that this only changes files in deps/v8

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.

@jaimecbernardo
Copy link
Contributor Author

@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 node/master is 5.8 and that V8 upstream seems to be in major version 6 already, so the adoption of the patch could take a while.

Thanks for your help. I've already made a change upstream once.
I'll post a link here once I've sent this upstream as well.

@addaleax
Copy link
Member

I also took into account that the current V8 in node/master is 5.8 and that V8 upstream seems to be in major version 6 already, so the adoption of the patch could take a while.

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 master already and are hoping to upgrade to V8 6.0 until next week. Also, floating patches gets a bit easier/meets less resistance when it’s a cherry-pick from upstream that we don’t have to manage ourselves.

@Trott
Copy link
Member

Trott commented Jul 27, 2017

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?

@Trott Trott added the blocked PRs that are blocked by other issues or PRs. label Jul 27, 2017
@Trott
Copy link
Member

Trott commented Jul 27, 2017

(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.)

@addaleax
Copy link
Member

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.

@jaimecbernardo
Copy link
Contributor Author

I've submitted it upstream here:
https://chromium-review.googlesource.com/c/590234/

Added @addaleax in CC as well.

@jaimecbernardo
Copy link
Contributor Author

Another change was made upstream to make the ouput from the profiler be the same in Windows. https://chromium-review.googlesource.com/c/591373
It seems to have landed here: https://chromium.googlesource.com/v8/v8/+/4229ca207e1d139d57cd9c2e72c6174d4c81878c

So, I guess this PR can be discarded.

@tniessen
Copy link
Member

Yes, this was fixed upstream in v8/v8@4229ca2. Feel free to open a cherry-pick PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked PRs that are blocked by other issues or PRs. v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

32bit address given for 64bit builds using --prof on Windows
6 participants