Uh oh!
There was an error while loading. Please reload this page.
events: add type check for event name - #31428
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
legendecas
commented
Jan 21, 2020
Will this be semver-minor or semver-major for the possible breaking changes on existing codes? |
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2238/ (queued) |
This comment has been minimized.
This comment has been minimized.
Trott
commented
Jan 23, 2020
/ping @nodejs/tsc This is a straightforward change, but it is semver-major so will need TSC reviews. |
jasnell
commented
Jan 23, 2020
This needs to be thoroughly benchmarked before it can land. This is one of the single most performance sensitive apis in core. |
mcollina
commented
Jan 23, 2020
I’m +1 if it does not cause a perf regression to the eventemitter, http, and streams benchmarks. |
Flarna
commented
Jan 23, 2020
rebased/squashed and updated commit message |
tniessen
left a comment
There was a problem hiding this comment.
Is there any risk of breaking existing code? If so, would a deprecation cycle be better?
Uh oh!
There was an error while loading. Please reload this page.
jasnell
commented
Jan 27, 2020
Benchmark run (may take a while for the link to be good while jenkins spins up the job): https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/514/ |
jasnell
commented
Jan 28, 2020
Results of the benchmark run: The significant slow down in |
jasnell
left a comment
There was a problem hiding this comment.
Making -1 explicit until benchmark results can be looked at.
According to docs only string/symbol are allowed but the checks done are more relaxed and allow additionally number/bigint as it seems they are used in user land modules.
Flarna
commented
Jan 28, 2020
Seems using an if instead a switch is significant faster. |
jasnell
commented
Jan 28, 2020
I'll kick off another CI benchmark run to double check :-) |
jasnell
commented
Jan 28, 2020
Flarna
commented
Jan 28, 2020
@jasnell Seems you accidentally started benchmarks for category assert instead event |
jasnell
commented
Jan 28, 2020
Sigh lol ok. Will restart soon |
jasnell
commented
Jan 28, 2020
Flarna
commented
Jan 28, 2020
new benchmark results: |
jasnell
commented
Jan 28, 2020
Still a bit of a concern. It's interesting that the ee-add-remove shows a significant regression in the second run but not the first. I think that's just really showing the performance sensitivity in this part. I guess I can't really come up with a great argument not to add this but I'm also not really seeing much of a benefit to adding this check. @addaleax and @mcollina, what do you think? |
addaleax
commented
Jan 28, 2020
I’m personally good with not adding typechecking if it affects performance – for events, it wouldn’t be a need-to-have anyway (and I’ve never seen non-string/symbol values being passed as event names in the wild, too). |
According to docs only
string/symbolare allowed but the checks are more relaxed to allow alsonumber/bigintas it seems they are used in user land modules.There were already checks in place in the past and they have been removed have been removed.
Another try to add them again was done but never finished (#21007).
Therefore I'm not sure if this should be added or not. As I had most of the changes already in place once I noticed this I think it's better to discuss this in a PR.
Fixes: #31331
Refs: 0468861
Refs: #21007
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesEdit: Removed
nullas it was removed during review phase.