Generator functions are too slow: Baseline compile generators
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
Tracking | Status | |
---|---|---|
relnote-firefox | --- | 36+ |
People
(Reporter: georgir, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Keywords: dev-doc-needed)
Updated•11 years ago
|
Comment 4•11 years ago
|
||
Updated•11 years ago
|
Comment 5•11 years ago
|
||
Comment 9•11 years ago
|
||
Comment 10•11 years ago
|
||
Comment 11•11 years ago
|
||
Comment 12•11 years ago
|
||
Comment 13•11 years ago
|
||
Comment 14•11 years ago
|
||
Comment 15•11 years ago
|
||
Comment 16•11 years ago
|
||
Comment 17•11 years ago
|
||
Comment 18•11 years ago
|
||
Comment 19•11 years ago
|
||
Comment 20•11 years ago
|
||
Comment 21•11 years ago
|
||
Comment 22•11 years ago
|
||
Comment 23•11 years ago
|
||
Comment 24•11 years ago
|
||
Comment 25•11 years ago
|
||
Updated•11 years ago
|
Comment 26•11 years ago
|
||
Comment 27•11 years ago
|
||
Comment 28•11 years ago
|
||
Comment 29•11 years ago
|
||
Comment 30•11 years ago
|
||
Comment 31•10 years ago
|
||
Comment 32•10 years ago
|
||
Updated•10 years ago
|
Comment 33•6 years ago
|
||
Removing myself as owner as I haven't worked in this area for some time :)
Comment 34•4 years ago
|
||
In Firefox 89, generators are about 10x slower than iterators or callbacks. Both in V8 and Webkit, generators are way faster.
In Firefox, I see about 10 ops/s. V8 does 44 ops/s (also a known issue). Webkit about 100 ops/s.
function* iterator() {
for (let i = 0; i < 1e9; i++) {
yield i;
}
}
let sum = 0;
// timed code:
for (const i of iterator()) {
sum += i;
}
Iterators and callbacks get about 100-300 ops/s (depending on the browser engine) for doing the sum. Is this an issue with the js execution engine or is the benchmark not realistic so that the optimized code paths are not taken?
Comment 35•4 years ago
|
||
There are still things we could do to improve generator performance, but we're not aware of any real-world code for which generator performance is a bottleneck, so it's not our highest priority. We would welcome any examples you can provide from actual websites.
(In particular, resuming into a Warp-compiled generator is currently implemented by resuming in baseline and doing OSR, which imposes some overhead. That overhead will be most significant in cases where the body of the generator is trivial, so this microbenchmark is pretty close to the worst-case scenario for us.)
Updated•2 years ago
|
Description
•