Skip to content

perf(internal/bits): Speedup extended commit.BitArray() (backport #2959)#2981

Merged
melekes merged 2 commits intov1.xfrom
mergify/bp/v1.x/pr-2959
May 2, 2024
Merged

perf(internal/bits): Speedup extended commit.BitArray() (backport #2959)#2981
melekes merged 2 commits intov1.xfrom
mergify/bp/v1.x/pr-2959

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented May 2, 2024

Speedup ExtendedCommit.BitArray() by making a direct constructor that does not go through mutexes. I expect this to be a 10x performance improvement. (It also removes the duffcopies and reduces setIndex proportion of time here)

This removes this time (which is mostly coming from mutex calls):
image

Later on we should instead make an API that lets us randomly sample from a bit array with no bit array copying needed. (But that makes the interface messier)


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

This is an automatic backport of pull request #2959 done by [Mergify](https://mergify.com).

Speedup ExtendedCommit.BitArray() by making a direct constructor that
does not go through mutexes. I expect this to be a 10x performance
improvement. (It also removes the duffcopies and reduces setIndex
proportion of time here)

This removes this time (which is mostly coming from mutex calls):

![image](https://github.com/cometbft/cometbft/assets/6440154/da11d57d-6bea-40ea-a0fa-9209ea3e22f8)

Later on we should instead make an API that lets us randomly sample from
a bit array with no bit array copying needed. (But that makes the
interface messier)

---

#### PR checklist

- [x] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [x] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit edb297b)
@mergify mergify bot requested a review from a team as a code owner May 2, 2024 13:23
@mergify mergify bot requested a review from a team May 2, 2024 13:23
@melekes melekes merged commit 96f4f95 into v1.x May 2, 2024
@melekes melekes deleted the mergify/bp/v1.x/pr-2959 branch May 2, 2024 13:39
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.

2 participants