Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #17981 > unrolled thread
| Started by | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| First post | 2013-01-06 15:12 +0100 |
| Last post | 2013-01-06 08:32 -0800 |
| Articles | 7 — 6 participants |
Back to article view | Back to comp.lang.javascript
Mysterious slowdown in Chromium Stefan Weiss <krewecherl@gmail.com> - 2013-01-06 15:12 +0100
Re: Mysterious slowdown in Chromium GGolf <invalid@invalid.com> - 2013-01-06 20:22 +0530
Re: Mysterious slowdown in Chromium Gregor Kofler <usenet@gregorkofler.com> - 2013-01-06 16:25 +0100
Re: Mysterious slowdown in Chromium Stefan Weiss <krewecherl@gmail.com> - 2013-01-06 17:33 +0100
Re: Mysterious slowdown in Chromium Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-01-06 23:44 +0100
Re: Mysterious slowdown in Chromium Scott Sauyet <scott.sauyet@gmail.com> - 2013-01-06 08:19 -0800
Re: Mysterious slowdown in Chromium Patricia Shanahan <pats@acm.org> - 2013-01-06 08:32 -0800
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2013-01-06 15:12 +0100 |
| Subject | Mysterious slowdown in Chromium |
| Message-ID | <kcc0nh$ckn$1@news.albasani.net> |
I was doing a quick benchmark in Chromium, when I noticed that
subsequent runs were getting slower and slower. Reduced to the minimal
case, the effect can be reproduced with this:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<script>
function bench() {
function test() {}
var runs = 10000000, // adjust as needed
t0 = +new Date();
while (runs--) test();
console.log((+new Date() - t0) + "ms");
}
</script>
<button onclick="bench()">bench()</button>
</body>
</html>
These are the times I get for the first 15 runs:
16ms
63ms
61ms
58ms
73ms
66ms
62ms
299ms
301ms
302ms
308ms
2681ms
2608ms
2596ms
2608ms
I would have expected no significant change, or maybe even a slight
speedup due to V8's JIT compiler.
Interestingly, when the test() function is moved outside of bench(), the
slowdown is much less pronounced:
13ms
20ms
18ms
18ms
17ms
23ms
21ms
297ms
301ms
(and stays at ~ 300ms after that)
Can anybody confirm this? This is on an older version of Chromium
("Version 20.0.1132.47 Ubuntu 12.04 (144678)"), so if it's a bug, it may
have been fixed in more recent versions.
- stefan
[toc] | [next] | [standalone]
| From | GGolf <invalid@invalid.com> |
|---|---|
| Date | 2013-01-06 20:22 +0530 |
| Message-ID | <kcc32m$n8q$1@speranza.aioe.org> |
| In reply to | #17981 |
On 1/6/2013 7:42 PM, Stefan Weiss wrote:
> I was doing a quick benchmark in Chromium, when I noticed that
> subsequent runs were getting slower and slower. Reduced to the minimal
> case, the effect can be reproduced with this:
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>Test</title>
> </head>
> <body>
> <script>
> function bench() {
> function test() {}
> var runs = 10000000, // adjust as needed
> t0 = +new Date();
> while (runs--) test();
> console.log((+new Date() - t0) + "ms");
> }
> </script>
> <button onclick="bench()">bench()</button>
> </body>
> </html>
>
> These are the times I get for the first 15 runs:
>
> 16ms
> 63ms
> 61ms
> 58ms
> 73ms
> 66ms
> 62ms
> 299ms
> 301ms
> 302ms
> 308ms
> 2681ms
> 2608ms
> 2596ms
> 2608ms
>
> I would have expected no significant change, or maybe even a slight
> speedup due to V8's JIT compiler.
>
> Interestingly, when the test() function is moved outside of bench(), the
> slowdown is much less pronounced:
>
> 13ms
> 20ms
> 18ms
> 18ms
> 17ms
> 23ms
> 21ms
> 297ms
> 301ms
> (and stays at ~ 300ms after that)
>
> Can anybody confirm this? This is on an older version of Chromium
> ("Version 20.0.1132.47 Ubuntu 12.04 (144678)"), so if it's a bug, it may
> have been fixed in more recent versions.
>
>
> - stefan
>
I don't have any explanation to offer, but the following were the
results on my system:
With the test() function inside of bench(), I got the following run
times for the first 12 runs:
38ms
56ms
97ms
82ms
72ms
96ms
90ms
96ms
97ms
78ms
86ms
131ms
Subsequent runs were between 94 to 144 ms each.
With the test() function moved outside of bench(), I get the following:
46ms
34ms
30ms
45ms
27ms
42ms
14ms
37ms
32ms
32ms
46ms
111ms
Subsequent runs took between 84 to 143 ms each.
I'm using Google Chrome Version 23.0.1271.97 m on Windows 7.
[toc] | [prev] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2013-01-06 16:25 +0100 |
| Message-ID | <kcc528$3m3$1@dont-email.me> |
| In reply to | #17981 |
Am 2013-01-06 15:12, Stefan Weiss meinte:
> I was doing a quick benchmark in Chromium, when I noticed that
> subsequent runs were getting slower and slower. Reduced to the minimal
> case, the effect can be reproduced with this:
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>Test</title>
> </head>
> <body>
> <script>
> function bench() {
> function test() {}
> var runs = 10000000, // adjust as needed
> t0 = +new Date();
> while (runs--) test();
> console.log((+new Date() - t0) + "ms");
> }
> </script>
> <button onclick="bench()">bench()</button>
> </body>
> </html>
Checked this on Chromium 22 (Ubuntu AMD64) in the web developer console
(function bench() {
function test() {}
var runs = 10000000, // adjust as needed
t0 = +new Date();
while (runs--) test();
console.log((+new Date() - t0) + "ms");
})();
Execution time stays constant with 90ms to 95ms.
Duplicating your test case I get
13ms
48ms
53ms
50ms
48ms
48ms
51ms
49ms
52ms
54ms
53ms
93ms
84ms
90ms
84ms
88ms
..
95ms (or less)
HTH, Gregor
[toc] | [prev] | [next] | [standalone]
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Date | 2013-01-06 17:33 +0100 |
| Message-ID | <kcc90f$tro$1@news.albasani.net> |
| In reply to | #17983 |
On 2013-01-06 16:25, Gregor Kofler wrote:
> Checked this on Chromium 22 (Ubuntu AMD64) in the web developer console
>
> (function bench() {
> function test() {}
> var runs = 10000000, // adjust as needed
> t0 = +new Date();
> while (runs--) test();
> console.log((+new Date() - t0) + "ms");
> })();
>
> Execution time stays constant with 90ms to 95ms.
Interesting. Running this here always takes around 2650ms. It appears
that function expressions and function declarations exhibit the problem
differently:
function bench2() { ... as before ... }
var bench3 = function () { ... as before ... };
bench3(); -> 2655ms
bench3(); -> 2652ms
bench2(); -> 18ms
bench2(); -> 59ms
bench2(); -> 64ms
bench2(); -> 62ms
bench2(); -> 60ms
bench2(); -> 57ms
bench2(); -> 61ms
bench2(); -> 303ms
bench2(); -> 303ms
bench2(); -> 300ms
bench2(); -> 301ms
bench2(); -> 301ms
bench2(); -> 2653ms
bench3(); -> 2648ms
bench3(); -> 2652ms
Must be an old bug in my Chromium version. I guess I won't be doing any
more benchmarks until I can find the time to upgrade my OS :)
Thank you (and GGolf and Scott) for testing!
- stefan
[toc] | [prev] | [next] | [standalone]
| From | Cezary Tomczyk <cezary.tomczyk@gmail.com> |
|---|---|
| Date | 2013-01-06 23:44 +0100 |
| Message-ID | <kccuo8$vbi$1@speranza.aioe.org> |
| In reply to | #17986 |
W dniu 2013-01-06 17:33, Stefan Weiss pisze:
> On 2013-01-06 16:25, Gregor Kofler wrote:
>> Checked this on Chromium 22 (Ubuntu AMD64) in the web developer console
>>
>> (function bench() {
>> function test() {}
>> var runs = 10000000, // adjust as needed
>> t0 = +new Date();
>> while (runs--) test();
>> console.log((+new Date() - t0) + "ms");
>> })();
>>
>> Execution time stays constant with 90ms to 95ms.
[...]
Interesting results:
function bench() {
function test() {};
var runs = 10000000, // adjust as needed
t0 = +new Date();
while (runs--) test();
console.log((+new Date() - t0) + "ms");
};
bench();
15ms
var bench = function () {
var test = function () {};
var runs = 10000000, // adjust as needed
t0 = +new Date();
while (runs--) test();
console.log((+new Date() - t0) + "ms");
};
bench();
136ms
function test() {};
function bench() {
var runs = 10000000, // adjust as needed
t0 = +new Date();
while (runs--) test();
console.log((+new Date() - t0) + "ms");
};
bench();
31ms
Tested on Google Chrome 23.0.1271.97, Windows 7 64bit.
Firefox 17.0.1 and Opera 12.12 was very slow in all above examples. More
or less ~ 3 to ~ 13 seconds, while IE9 ~ 440 ms.
--
Cezary Tomczyk
http://www.ctomczyk.pl/
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2013-01-06 08:19 -0800 |
| Message-ID | <6ed23b85-14a4-4f07-89ac-a2fcbe1142c3@d10g2000yqe.googlegroups.com> |
| In reply to | #17981 |
On Jan 6, 9:12 am, Stefan Weiss <krewech...@gmail.com> wrote:
> I was doing a quick benchmark in Chromium, when I noticed that
> subsequent runs were getting slower and slower. Reduced to the minimal
> case, the effect can be reproduced with this:
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>Test</title>
> </head>
> <body>
> <script>
> function bench() {
> function test() {}
> var runs = 10000000, // adjust as needed
> t0 = +new Date();
> while (runs--) test();
> console.log((+new Date() - t0) + "ms");
> }
> </script>
> <button onclick="bench()">bench()</button>
> </body>
> </html>
> [ ... ]
>
> I would have expected no significant change, or maybe even a slight
> speedup due to V8's JIT compiler.
>
> Interestingly, when the test() function is moved outside of bench(), the
> slowdown is much less pronounced:
Running on an older Win XP box with Chrome 23.0.1271.97, and `test()`
inside `bench()`, I get these results:
57ms
235ms
187ms
77ms
188ms
75ms
204ms
75ms
177ms
201ms
75ms
236ms
187ms
266ms
197ms
(150-250 thereafter)
With `test()` outside `base()`, I get this:
56ms
53ms
54ms
55ms
58ms
55ms
57ms
55ms
17ms
20ms
20ms
215ms
105ms
101ms
210ms
(180-220 thereafter)
I have no explanation for the differences, although they're not as
pronounced for me.
-- Scott
[toc] | [prev] | [next] | [standalone]
| From | Patricia Shanahan <pats@acm.org> |
|---|---|
| Date | 2013-01-06 08:32 -0800 |
| Message-ID | <UoudnfiQHeKLOnTNnZ2dnUVZ_qidnZ2d@earthlink.com> |
| In reply to | #17981 |
On 1/6/2013 6:12 AM, Stefan Weiss wrote: > I was doing a quick benchmark in Chromium, when I noticed that > subsequent runs were getting slower and slower. Reduced to the minimal > case, the effect can be reproduced with this: ... Many years ago, when I was working on paging in a virtual storage operating system, I gave priority to grabbing pages for the first second or so after an interactive job became runnable. The motivation was responsiveness to the users. If the nominally interactive job went on using CPU time and memory it dropped back to normal priority. Maybe Chronium is doing something similar, giving higher priority to a script that has not used much CPU time, and dropping its priority based on accumulated CPU time? Patricia
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web