|
|
Description[promises] Avoid creating resolving functions in
Promise.resolve
Instead of creating resolve and reject closures, directly
call ResolvePromise after creating the promise.
Using the following as a microbenchmark --
```
var b = 0;
var start = performance.now();
for (var i = 0; i < 1000000; i++) {
Promise.resolve(1).then((val) => {
b += val;
if (b == 1000000) print(performance.now() - start)
});
}
```
I see a 16.01% improvement over 5 runs with this patch.
BUG=v8:5046
Committed: https://crrev.com/140b8980915b966e88283c42f22d212a9fab1455
Cr-Commit-Position: refs/heads/master@{#38318}
Patch Set 1 #Patch Set 2 : update comment #Messages
Total messages: 25 (18 generated)
The CQ bit was checked by gsathya@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Description was changed from ========== Promise: Avoid creating extra closures in Promise.resolve BUG=v8:5046 ========== to ========== Promise: Avoid creating resolving functions in Promise.resolve BUG=v8:5046 ==========
Description was changed from ========== Promise: Avoid creating resolving functions in Promise.resolve BUG=v8:5046 ========== to ========== Promise: Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. BUG=v8:5046 ==========
Description was changed from ========== Promise: Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. BUG=v8:5046 ========== to ========== Promise: Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. BUG=v8:5046 ==========
The CQ bit was checked by gsathya@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
gsathya@chromium.org changed reviewers: + adamk@chromium.org, littledan@chromium.org
Description was changed from ========== Promise: Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. BUG=v8:5046 ========== to ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. BUG=v8:5046 ==========
lgtm Looks like a good and correct optimization; I'm surprised that we didn't already do this when we do it for Promise.reject. If you have a microbenchmark that shows improvements, then that could be nice to brag about in the commit message.
Description was changed from ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. BUG=v8:5046 ========== to ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 ==========
Description was changed from ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 ========== to ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 ==========
On 2016/08/03 22:29:31, Dan Ehrenberg wrote: > lgtm > > Looks like a good and correct optimization; I'm surprised that we didn't already > do this when we do it for Promise.reject. If you have a microbenchmark that > shows improvements, then that could be nice to brag about in the commit message. Thanks! Updated.
lgtm
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by gsathya@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 ========== to ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 ==========
Message was sent while issue was closed.
Committed patchset #2 (id:20001)
Message was sent while issue was closed.
Description was changed from ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 ========== to ========== [promises] Avoid creating resolving functions in Promise.resolve Instead of creating resolve and reject closures, directly call ResolvePromise after creating the promise. Using the following as a microbenchmark -- ``` var b = 0; var start = performance.now(); for (var i = 0; i < 1000000; i++) { Promise.resolve(1).then((val) => { b += val; if (b == 1000000) print(performance.now() - start) }); } ``` I see a 16.01% improvement over 5 runs with this patch. BUG=v8:5046 Committed: https://crrev.com/140b8980915b966e88283c42f22d212a9fab1455 Cr-Commit-Position: refs/heads/master@{#38318} ==========
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/140b8980915b966e88283c42f22d212a9fab1455 Cr-Commit-Position: refs/heads/master@{#38318} |