Open
Bug 1420440
Opened 7 years ago
Updated 2 years ago
Optimize the Function constructor
Categories
(Core :: JavaScript Engine, enhancement, P3)
Core
JavaScript Engine
Tracking
()
NEW
Performance Impact | low |
Tracking | Status | |
---|---|---|
firefox59 | --- | fix-optional |
People
(Reporter: jandem, Unassigned)
References
(Blocks 4 open bugs)
Details
On the UglifyJS test in V8's Web Tooling benchmark we spend a *lot* of time under CreateDynamicFunction. I think we end up parsing the same string over and over again.
For the micro-benchmark below I get:
SM: 820 ms
d8: 81 ms
If I add |+ i| at the end of the string, I get:
SM: 1043 ms
d8: 2123 ms
So we're actually faster at this but they seem to do some sort of caching. It probably makes sense to have a source-string -> JSScript* cache. Then when we have a hit, we only have to allocate a JSFunction and we're done.
Probably worth checking what V8/JSC/Chakra are doing exactly.
---
function f() {
var t = new Date;
for (var i = 0; i < 100000; i++) {
fun = Function('switch(str){case "(":case "[":case "+":case "*":case "/":case "-":case ",":case ".":case "`":return true}return false;');
}
print(new Date - t);
}
f();
Reporter | ||
Comment 1•7 years ago
|
||
FWIW, in Safari 11.0 I get 1665 ms. If I concatenate |i| to the string, I get 1242 ms... not sure why that's faster instead of slower. In any case, JSC doesn't cache this either.
Reporter | ||
Comment 2•7 years ago
|
||
V8 seems to call Compiler::GetFunctionFromString -> GetFunctionFromEval, where they use the eval cache.
So yeah, maybe we could just reuse the eval cache...
Updated•7 years ago
|
status-firefox59:
--- → fix-optional
Priority: -- → P3
Updated•6 years ago
|
Whiteboard: [qf:p3:f64]
Updated•6 years ago
|
Whiteboard: [qf:p3:f64] → [qf:p3:f67]
Updated•6 years ago
|
Whiteboard: [qf:p3:f67] → [qf:p3]
Reporter | ||
Updated•5 years ago
|
Updated•3 years ago
|
Performance Impact: --- → P3
Whiteboard: [qf:p3]
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•