Regression in performance of Function.prototype.bind and calling bound functions

NEW
Unassigned

Status

()

Core
JavaScript Engine: JIT
P2
normal
11 months ago
10 months ago

People

(Reporter: till, Unassigned)

Tracking

(Blocks: 1 bug, {perf, regression})

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

11 months ago
Created attachment 8856523 [details]
Revised benchmark with more cases

The benchmark in bug 1000780 used to show us with little or no overhead for bound functions that can use the fast-path - those with fewer than 3 bound arguments and fewer than 6 call args. This was true for both the call and construct case. Now, we're at least 2x as slow on the call case - with no bound or call args - and 3x as slow for 2 bound and 3 call args.

We're also *much* slower on the slow path:
~ 32x for calling a bound function vs an unbound one with 10 args
~ 47x for constructing a bound function vs an unbound one with 10 args
~ 16x for calling a function with 3 bound args with 2 call args vs calling an unbound function with 5 args
~ 33x for constructing a function with 3 bound args with 2 call args vs constructing an unbound function with 5 args

Additionally, v8 got much faster on all of this, including the performance of Function.prototype.bind itself: they're now either roughly as fast as us in call/construct perf (when we hit the fast path) or much faster (when we don't). And calling bind itself is 5-7x as fast as for us.

Detailed results for SpiderMonkey:
--- binding performance ---
Self-h bind, 0 args: 540
Self-h bind, 2 args: 625
Self-h bind, 3 args: 639
Self-h bind, 5 args: 657
--- calling performance ---
call unbound, 0,0 args: 28
call   bound, 0,0 args: 49
call   bound, 2,0 args: 62
call   bound, 5,0 args: 101
call   bound, 2,3 args: 87
call   bound, 2,7 args: 656
call   bound, 2,8 args: 844
call   bound, 3,2 args: 449
call unbound, 0,5 args: 27
call unbound, 0,10 args: 29
call   bound, 0,5 args: 81
call   bound, 0,10 args: 949
--- constructing performance ---
construct unbound, 0,0 args: 14
construct   bound, 0,0 args: 185
construct   bound, 2,0 args: 200
construct   bound, 5,0 args: 266
construct   bound, 2,3 args: 230
construct   bound, 2,7 args: 875
construct   bound, 3,2 args: 594
construct unbound, 0,5 args: 18
construct unbound, 0,10 args: 23
construct   bound, 0,5 args: 232
construct   bound, 0,10 args: 1074


Detailed results for node 7.5.0:
--- binding performance ---
Self-h bind, 0 args: 82
Self-h bind, 2 args: 112
Self-h bind, 3 args: 105
Self-h bind, 5 args: 128
--- calling performance ---
call unbound, 0,0 args: 53
call   bound, 0,0 args: 69
call   bound, 2,0 args: 84
call   bound, 5,0 args: 93
call   bound, 2,3 args: 108
call   bound, 2,7 args: 157
call   bound, 2,8 args: 164
call   bound, 3,2 args: 90
call unbound, 0,5 args: 97
call unbound, 0,10 args: 113
call   bound, 0,5 args: 77
call   bound, 0,10 args: 99
--- constructing performance ---
construct unbound, 0,0 args: 31
construct   bound, 0,0 args: 120
construct   bound, 2,0 args: 131
construct   bound, 5,0 args: 187
construct   bound, 2,3 args: 172
construct   bound, 2,7 args: 253
construct   bound, 3,2 args: 179
construct unbound, 0,5 args: 30
construct unbound, 0,10 args: 32
construct   bound, 0,5 args: 158
construct   bound, 0,10 args: 214

Comment 1

11 months ago
Fixing this bug should include putting a benchmark on AWFY so we don't regress this again.

Updated

11 months ago
Blocks: 1307062
Priority: -- → P2
See Also: → bug 1355056
You need to log in before you can comment on or make changes to this bug.