RFC: Performance improvement in `lean_mark_persistent` and `lean_mark_mt`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #16375 by @zgrannan — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- performance
Research direction
Start with src/runtime/object.cpp around lean_mark_persistent and inspect the corresponding lean_mark_mt implementation. Review the linked implementation and benchmark results, then check the existing runtime tests and benchmark suite for coverage of persistent marking. Done means both paths preserve correct object marking and the benchmark confirms the reported instruction reduction; linked pull request #16375 is closed and unmerged.
Written by the indexing model from the issue text.
Description
lean_mark_persistent implements a worklist loop where each iteration pops an object o and:
- checks
!lean_is_scalar(o) && lean_has_rc(o); - if the check succeeds, runs
lean_internal_set_rc(o, 0)and pushes all ofo's children onto the worklist.
I think we can improve performance by moving the check and the update to the push:
- only pushing a child
cif!lean_is_scalar(c) && lean_has_rc(c), and - calling
lean_internal_set_rc(c, 0)just before adding it to the worklist
This has two benefits:
- fewer buffer operations, since scalars and already-persistent objects are never added to the buffer;
- the worklist never holds the same object twice.
I've implemented this change here, applying the same restructuring to lean_mark_mt. Running the benchmark suite locally I get 0.96% drop in build//instructions.
- Dominant language
- Lean
- Stars
- 10.3k
- Forks
- 1.1k
- Avg merge
- 19h 8m
- Merged PRs (30d)
- 421
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from leanprover/lean4
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/lean4#16681 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
leanprover/lean4#16305 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
leanprover/lean4#16299 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
leanprover/lean4#16257 ·
Maintainers usually reply within 1 day
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
leanprover/lean4#15683 ·
Maintainers usually reply within 1 day
All issues in leanprover/lean4
Similar issues
-
sync cache dist/imgOpen
Difficulty 1/5 Under an hour Newbie friendliness 82/100
oleeskild/digitalgarden#435 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
TigreGotico/scriptconv#408 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sybrew/the-seo-framework#785 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
cytoscape/cytoscape.js#3599 ·
Maintainers usually reply within 5 days
-
performance
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
jjgroenendijk/opensky#2358 · 1 comment ·
Maintainers usually reply within 1 day