Finding better implementations of PostTag and PostCategory #5604
Open
Description
Check List
- I have already read Docs page.
- I have already searched existing issues.
Feature Request
I was analysing the flame graph and noticed that PostTag has a lot of overheads.
In fact, we can optimise these simple sets of binary relations with map and set.
I wrote a simple demo for this, and this is what I got by rewriting the PostTag:
8x many-posts
before
Cold processing
┌──────────────────────────────┬───────────────┐
│ (index) │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │ '0.25s' │
│ Process Source │ '10.79s' │
│ Render Posts │ '13.49s' │
│ Render Files │ '13.64s' │
│ Save Database │ '1.21s' │
│ Total time │ '39.38s' │
└──────────────────────────────┴───────────────┘
Hot processing
┌──────────────────────────────┬───────────────┐
│ (index) │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │ '2.14s' │
│ Process Source │ '7.03s' │
│ Render Files │ '11.60s' │
│ Save Database │ '1.08s' │
│ Total time │ '21.85s' │
└──────────────────────────────┴───────────────┘
Another Cold processing
┌──────────────────────────────┬───────────────┐
│ (index) │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │ '0.24s' │
│ Process Source │ '11.27s' │
│ Render Posts │ '13.32s' │
│ Render Files │ '13.74s' │
│ Save Database │ '1.00s' │
│ Total time │ '39.56s' │
└──────────────────────────────┴───────────────┘
after
Cold processing
┌──────────────────────────────┬───────────────┐
│ (index) │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │ '0.25s' │
│ Process Source │ '6.50s' │
│ Render Posts │ '9.32s' │
│ Render Files │ '13.79s' │
│ Save Database │ '1.02s' │
│ Total time │ '30.88s' │
└──────────────────────────────┴───────────────┘
Hot processing
┌──────────────────────────────┬───────────────┐
│ (index) │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │ '2.11s' │
│ Process Source │ '2.40s' │
│ Render Files │ '8.04s' │
│ Save Database │ '1.01s' │
│ Total time │ '13.56s' │
└──────────────────────────────┴───────────────┘
Another Cold processing
┌──────────────────────────────┬───────────────┐
│ (index) │ Cost time (s) │
├──────────────────────────────┼───────────────┤
│ Load Plugin/Scripts/Database │ '0.24s' │
│ Process Source │ '6.44s' │
│ Render Posts │ '9.20s' │
│ Render Files │ '13.82s' │
│ Save Database │ '1.04s' │
│ Total time │ '30.75s' │
Others
No response
Metadata
Assignees
Labels
No labels