-
Notifications
You must be signed in to change notification settings - Fork 30k
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
tools: fix prof polyfill readline #18641
Conversation
node v9.4.0 and v9.5.0 may not print the full profile log file when use the |
|
||
const LOG_FILE = path.join(tmpdir.path, 'tick-processor.log'); | ||
const RETRY_TIMEOUT = 150; | ||
const BORKEN_PART = 'tick,0x100840650'; |
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.
typo s/BORKEN_PART/BROKEN_PART/
Also, could we just use const BROKEN_PART = 'tick,'/
instead? "0x100840650"
looks like a magic number here.
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.
yes,it's better.
7b4e27c
to
bfaee12
Compare
@mmarchini the magic number have been removed. |
common.isAIX || | ||
common.isLinuxPPCBE || | ||
common.isFreeBSD) | ||
common.skip('C++ symbols are not mapped for this os.'); |
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.
I'm not sure whether the linter (make lint
) will complain or not, but this is difficult to read. Please use braces here.
479f168
to
fd9baf5
Compare
lib/internal/v8_prof_polyfill.js
Outdated
@@ -93,7 +93,7 @@ function readline() { | |||
} | |||
const bytes = fs.readSync(fd, buf, 0, buf.length); | |||
line += dec.write(buf.slice(0, bytes)); | |||
if (line.length === 0) { | |||
if (line.length === 0 || bytes < buf.length) { |
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.
emit a warning while broken?
9b54b62
to
41f92a4
Compare
`node --prof foo.js` may not print the full profile log file, the last line will broken like `tick,` and not more blank line. `readline`will stuck in infinite loop, add `bytes === 0` will fix it.
41f92a4
to
33f4a51
Compare
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.
test/common/index.js
Outdated
@@ -802,3 +802,8 @@ exports.hijackStdout = hijackStdWritable.bind(null, 'stdout'); | |||
exports.hijackStderr = hijackStdWritable.bind(null, 'stderr'); | |||
exports.restoreStdout = restoreWritable.bind(null, 'stdout'); | |||
exports.restoreStderr = restoreWritable.bind(null, 'stderr'); | |||
exports.isSymbolAvailable = exports.isWindows || | |||
exports.isSunOS || |
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.
nit: align with exports
above.
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.
@XadillaX as you wish.
test/common/README.md
Outdated
@@ -243,6 +243,11 @@ Platform check for Windows. | |||
|
|||
Platform check for Windows 32-bit on Windows 64-bit. | |||
|
|||
### isSymbolAvailable |
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.
Can we use a more descriptive name than this please?
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.
my bad,it should be isCPPSymbolsNotMapped
. @cjihrig
test/common/README.md
Outdated
### isSymbolAvailable | ||
* [<Boolean>] | ||
|
||
Platform check for if symbol available. |
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.
Similarly, can you provide a more in depth description.
@cjihrig the property name,and readme have been changed to more descriptive. |
test/common/README.md
Outdated
* [<Boolean>] | ||
|
||
Platform check for if symbol available. | ||
Platform check for c++ symbols are mapped or not. |
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.
c++
=> C++
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.
tmpdir.refresh(); | ||
|
||
if (!common.enoughTestCpu) | ||
common.skip('test is CPU-intensive'); |
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.
Nit: would you be so kind and use a capital letter as first character? :-)
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.
In the node test,the first character in skip message is always lower case.
common.skip('test is CPU-intensive'); | ||
|
||
if (common.isCPPSymbolsNotMapped) { | ||
common.skip('C++ symbols are not mapped for this os.'); |
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.
Nit: Operating system should be upper cased as in OS
.
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 for the advice.It should be upper cased.
|
||
//This test will produce a broken profile log. | ||
//ensure prof-polyfill not stuck in infinite loop | ||
//and success process |
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.
Nit: please use a space at the beginning of each line in a comment.
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 for the advice.It should have a space at the beginning of each line.
this.ts = Date.now(); | ||
setImmediate(function() { new f(); }); | ||
}; | ||
f();`; |
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.
Nit: we have the unwritten rule not to use multi line template strings.
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 for the advice.I will split it to two lines.
'--prof-process', LOG_FILE | ||
]); | ||
assert(WARN_REG_EXP.test(child.stderr.toString())); | ||
assert.strictEqual(child.status, 0, 'broken file should success too'); |
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.
I personally would like to stick to the default message.
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.
The default message will be removed.
lib/internal/v8_prof_polyfill.js
Outdated
@@ -96,6 +96,13 @@ function readline() { | |||
if (line.length === 0) { | |||
return ''; | |||
} | |||
if (bytes === 0) { | |||
process.emitWarning('profile file is broken', { |
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.
Suggestion: you might just add the filename of the broken file? And please use a capital letter as first character.
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 for the advice.Add the filename is better.
fix warn message fix comment style
@BridgeAR Thank you for the advice.I have update the code.Please review it. |
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. PR-URL: #18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Landed in 38f04d4 😄 |
Should this be backported to |
@MylesBorins It should be backported to v9.x-staging,and I will raise a backport PR. |
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. PR-URL: nodejs#18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins I have raised a PR to backport it. BTW I have no permission for run the CI. If you can help me trigger the CI, you are so kind. |
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. PR-URL: nodejs#18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. Backport-PR-URL: #18901 PR-URL: #18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. Backport-PR-URL: #18901 PR-URL: #18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. PR-URL: nodejs#18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. Backport-PR-URL: #18901 PR-URL: #18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
`node --prof foo.js` may not print the full profile log file, leaving the last line broken (for example `tick,`. When that happens, `readline` will be stuck in an infinite loop. This patch fixes it. Also introduced `common.isCPPSymbolsNotMapped` to avoid duplicated code on tick-processor tests. Backport-PR-URL: #18901 PR-URL: #18641 Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
node --prof foo.js
may not print the full profile log file,the last line will broken like
tick,
and not more blank line.readline
will stuck in infinite loop, addbytes < buf.length
will fix it.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
@bnoordhuis