Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: avoid using delete operator #4711

Merged
merged 1 commit into from
Jun 3, 2021

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Jun 2, 2021

What does it do?

https://v8.dev/blog/fast-properties

In short, the delete operator has a potential performance impact (related with v8 hidden class, and delete could cause v8 to degrade object process). By replacing delete operator it could gain performance.

Screenshots

Benchmark result:

master branch

Cold processing
┌──────────────────────────────┬───────────────┐
│           (index)            │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │    '0.41s'    │
│        Process Source        │    '3.60s'    │
│         Render Posts         │    '3.36s'    │
│         Render Files         │    '7.27s'    │
│        Save Database         │    '0.35s'    │
│          Total time          │   '14.99s'    │
└──────────────────────────────┴───────────────┘
Hot processing
┌──────────────────────────────┬───────────────┐
│           (index)            │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │    '1.20s'    │
│        Process Source        │    '1.41s'    │
│         Render Files         │    '7.23s'    │
│        Save Database         │    '0.35s'    │
│          Total time          │   '10.20s'    │
└──────────────────────────────┴───────────────┘
Another Cold processing
┌──────────────────────────────┬───────────────┐
│           (index)            │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │    '0.41s'    │
│        Process Source        │    '3.43s'    │
│         Render Posts         │    '3.31s'    │
│         Render Files         │    '7.38s'    │
│        Save Database         │    '0.34s'    │
│          Total time          │   '14.87s'    │
└──────────────────────────────┴───────────────┘

After the PR:

Cold processing
Cold processing
┌──────────────────────────────┬───────────────┐
│           (index)            │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │    '0.36s'    │
│        Process Source        │    '3.32s'    │
│         Render Posts         │    '3.22s'    │
│         Render Files         │    '6.94s'    │
│        Save Database         │    '0.33s'    │
│          Total time          │   '14.17s'    │
└──────────────────────────────┴───────────────┘
Hot processing
┌──────────────────────────────┬───────────────┐
│           (index)            │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │    '1.07s'    │
│        Process Source        │    '1.38s'    │
│         Render Files         │    '6.80s'    │
│        Save Database         │    '0.34s'    │
│          Total time          │    '9.59s'    │
└──────────────────────────────┴───────────────┘
Another Cold processing
┌──────────────────────────────┬───────────────┐
│           (index)            │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │    '0.38s'    │
│        Process Source        │    '3.32s'    │
│         Render Posts         │    '3.14s'    │
│         Render Files         │    '6.82s'    │
│        Save Database         │    '0.35s'    │
│          Total time          │   '14.01s'    │
└──────────────────────────────┴───────────────┘

Performance improved by 7% after the PR.

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 98.282% when pulling 9170b79 on SukkaW:perf-avoid-using-delete-operator into eef2eac on hexojs:master.

Copy link
Member

@jiangtj jiangtj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@SukkaW SukkaW merged commit fc2979a into hexojs:master Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants