Sinon: 7.2.4 is significant slower than 7.2.3

Created on 22 Feb 2019  路  10Comments  路  Source: sinonjs/sinon

Describe the bug
For some reason my testsuite runs significant slower with 7.2.4 compared to 7.2.3.

7.2.3:

real    0m14,750s
user    0m17,557s
sys 0m1,412s
````

7.2.4

real 0m54,398s
user 1m0,317s
sys 0m3,563s
```

To Reproduce
Execute unittests using mocha framework.

Expected behavior
No significant difference degrade between 7.2.4 compared to 7.2.3

Context (please complete the following information):

  • Library version: 7.2.4
  • Environment: windows and linux
  • Example URL:
  • Other libraries you are using: mocha

Additional context
It's a closed source project therefore I can't share my tests. If you have any pointers what other info I should provide or what to test let me know.

Most helpful comment

Looks like @mantoni was correct. I digged a little deeper and it seems that the change in spy#resetHistory is the main contributor of the degradation in my setup.

I have two solutions in mind here:

  1. initialize all spy properties already at creation time (spy#createProxy()) - as a result no extend.nonEnum() is needed in resetHistory() as no new properties will be added there
  2. reset only properties which are actually present in resetHistory() instead all of them

I think (1) would be the cleaner approach with an additional benefit to have always the same object layout which helps v8 to create better assembly code.

All 10 comments

My first guess is this change. Can you investigate a little?

Sure, I will take a closer look during the next days.

While I think it might be due to upping the lolex version (or some other package): https://github.com/sinonjs/sinon/commit/1431c78cc3ffc0c13bbb8155080ccf14d42af4a0

Looks like @mantoni was correct. I digged a little deeper and it seems that the change in spy#resetHistory is the main contributor of the degradation in my setup.

I have two solutions in mind here:

  1. initialize all spy properties already at creation time (spy#createProxy()) - as a result no extend.nonEnum() is needed in resetHistory() as no new properties will be added there
  2. reset only properties which are actually present in resetHistory() instead all of them

I think (1) would be the cleaner approach with an additional benefit to have always the same object layout which helps v8 to create better assembly code.

I created #1984 with a fix proposal.

Sorry for the regression introduced by my PR, thanks for fixing it and also adding some tests!

@Flarna for completeness, would you mind posting some numbers using the new [email protected]?

Here are the results of the day, sinon 7.2.5 seems to be not available yet on NPM so I used SHA d0c073c2aeaebab276094600d76d178d52158500 which should be the same:

7.2.3
real    0m15,699s
user    0m18,323s
sys 0m1,731s

real    0m15,932s
user    0m18,427s
sys 0m1,669s

7.2.4
real    0m54,554s
user    1m0,454s
sys 0m3,466s

real    0m54,659s
user    1m0,806s
sys 0m3,292s

sinonjs/sinon#d0c073c2aeaebab276094600d76d178d52158500
real    0m16,752s
user    0m19,516s
sys 0m1,767s

real    0m16,460s
user    0m19,514s
sys 0m1,676s

sinon 7.2.5 seems to be not available yet on NPM

I've published it now :)

Thank you for the update. Those results look to be well enough in the same ballpark for be usable 馃憤

Was this page helpful?
0 / 5 - 0 ratings