Skip to content

perf(pools): various performance improvements and cleanups in certification and consensus pools - #11953

Draft
pierugo-dfinity wants to merge 13 commits into
masterfrom
pierugo/certification-pool/improvs
Draft

pierugo-dfinity wants to merge 13 commits into
masterfrom
pierugo/certification-pool/improvs

Conversation

@pierugo-dfinity

@pierugo-dfinity pierugo-dfinity commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
  • In the certification pool, stop erasing the type of unvalidated_{share/cert}_index and split unvalidated into shares and full certs, both to leverage the type system more and avoid potential bugs (f.ex. we remove a panic).
  • Make HeightIndex::remove_all_below return the removed artifacts: this simplify and improves the performance of both consensus' purge_below and certification's remove_all_unvalidated_below by avoiding an additional iteration.
  • Instead of providing HeightIndex::heights, provide min_height and max_height, since this is only what the production callers care for. It avoids iterating and sometimes collecting.
  • Move CertificationPoolImpl::all_heights_with_artifacts to test-only and remove it from the trait since it was not used in production.
  • Misc: avoid some clones and stop allocating into vectors in a few places inside inmemory_pool.rs and lmdb_pool.rs (i.e. consensus pools).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused refactor preserves hashing, index consistency, ordering, and purge boundaries, with no blocking issues identified.

No open issues 🎉

What changed in this PR

This PR reduces allocation, cloning, and height-scanning overhead in the certification and in-memory consensus pools while simplifying their internal APIs.

Changes:

  • Purge indexed artifacts below a height directly and streamline range queries.
  • Store unvalidated certifications and shares in separate, typed maps.
  • Move the artifact-height helper out of the public interface and into test-only code, updating consistency assertions.
File Description
rs/​interfaces/​src/​certification.rs Removes the artifact-height helper from the public pool trait.
rs/​artifact_pool/​src/​inmemory_pool.rs Streamlines purging, artifact retrieval, and height queries.
rs/​artifact_pool/​src/​height_index.rs Adds draining purge iteration and direct height-bound accessors.
rs/​artifact_pool/​src/​certification_pool.rs Splits unvalidated storage by artifact type and updates tests.

Review effort: Balanced

@pierugo-dfinity pierugo-dfinity changed the title perf(pools): various performance improvements and cleanups in certification and in-memory consensus pools perf(pools): various performance improvements and cleanups in certification and consensus pools Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants