Skip to content

promise: optimize the performance on .then and static resolve#385

Merged
yorkie merged 2 commits intomasterfrom
optimize/promise-all
Oct 22, 2018
Merged

promise: optimize the performance on .then and static resolve#385
yorkie merged 2 commits intomasterfrom
optimize/promise-all

Conversation

@yorkie
Copy link
Copy Markdown
Member

@yorkie yorkie commented Oct 21, 2018

The optimized Promise comparison:

versions 1 2 3 4 5 Avg
before#then 2,500 2,189 2,560 2,716 2,191 2,431
after#then 3,056 3,149 3,383 3,270 3,694 3,310
before#resolve 1,717 1,589 1,744 1,684 1,770 1,700
after#resolve 2,848 2,764 3,433 2,622 3,023 2,938

The performance slots are:

  • then, removes to create duplicated empty function, and creates at start.
  • Promise.resolve:
    • skips doResolve, and immediately calls resolve(self, value) instead.
    • introduces freeze promise objects, currently for undefined, true and false.
Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added

@legendecas
Copy link
Copy Markdown
Contributor

Promise.resolve(null) shall be included in the freed list too.

@yorkie
Copy link
Copy Markdown
Member Author

yorkie commented Oct 21, 2018

The frozen Promise for null has been added @legendecas :)

@yorkie yorkie force-pushed the optimize/promise-all branch from 61d1188 to 3ff46af Compare October 22, 2018 07:51
@yorkie
Copy link
Copy Markdown
Member Author

yorkie commented Oct 22, 2018

The CI seems pass, but GitHub doesn't get correct state.

@yorkie yorkie merged commit 5647f86 into master Oct 22, 2018
@yorkie yorkie deleted the optimize/promise-all branch October 22, 2018 20:07
qile222 pushed a commit that referenced this pull request Oct 27, 2018
* master:
  build: use CMAKE_INSTALL_PREFIX instead of custom install command (#391)
  child_process: introduce binary protocol to optimizing performance (#393)
  iotjs: cache parsed dump table for error.stack at runtime (#392)
  jerry: merge a59cf4f from upstream to optimize the function call (#381)
  promise: optimize the performance on .then and static resolve (#385)
  jerry: set prototype/constructor for external functions (#386)
  process: add shebang parser supports (#379)
  napi: fix complete callback segv/ticks on async-work (#380)
  jerry: pass regression-test-issue-2105 for heapdump (#382)
  tls, mqtts: fix connection not be actively disconnected (#375)
  websocket: fix the crash due to http exception (#376)
  process: add signal events support (#372)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants