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(PostCategory/PostTag): add binary relation index for performance #5605

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

D-Sketon
Copy link
Member

@D-Sketon D-Sketon commented Jan 5, 2025

What does it do?

#5604
To improve performance, I introduced indexes for binary relations to improve lookup speeds.

The overhead from find and findOne is now largely invisible on the flamegraph:
c056b048cd926cfbfa30878dcbaa2bac

Screenshots

8x many-posts
before
{C7212CF8-98E1-4DA2-A226-600C384C8BA6}
after
{593ECE99-E775-414E-BE3D-C8C319E1931E}

1x many-posts
before
{8DAD029C-5887-4141-8188-AB4C6707A77D}
after
{4DB12F93-ACD0-4D8F-8157-3DCA4FF23E8F}

This is a huge boost for blogs with a super large number of posts, but hopefully this won't have any side effects on the generation of the site.

Pull request tasks

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

Copy link

github-actions bot commented Jan 5, 2025

How to test

git clone -b perf/binary-relation-index https://github.com/D-Sketon/hexo.git
cd hexo
npm install
npm test

@D-Sketon D-Sketon requested a review from a team January 10, 2025 03:48
@coveralls
Copy link

Pull Request Test Coverage Report for Build 12703017965

Details

  • 145 of 148 (97.97%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 99.458%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/models/binary_relation_index.ts 88 91 96.7%
Totals Coverage Status
Change from base Build 12702421469: -0.02%
Covered Lines: 9539
Relevant Lines: 9591

💛 - Coveralls

SukkaW
SukkaW previously approved these changes Jan 10, 2025
@SukkaW SukkaW requested a review from a team January 10, 2025 10:05
renbaoshuo
renbaoshuo previously approved these changes Jan 10, 2025
@D-Sketon D-Sketon dismissed stale reviews from renbaoshuo and SukkaW via e2583ac January 12, 2025 03:40
@D-Sketon
Copy link
Member Author

No hook will be triggered during the warehouse import process, so we must manually trigger the saveHook after loading the db.json.

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.

5 participants