Skip to content

perf(autofile): Regex should be only compiled once + RW Lock - #3424

Merged
melekes merged 8 commits into
cometbft:mainfrom
berachain:fix-group
Jul 8, 2024
Merged

melekes merged 8 commits into
cometbft:mainfrom
berachain:fix-group

Conversation

@itsdevbear

@itsdevbear itsdevbear commented Jul 4, 2024 •

Copy link
Copy Markdown

Re-compiling the regex was allocating
188mb per hour.

image

@itsdevbear
itsdevbear requested a review from a team as a code owner July 4, 2024 19:49
@itsdevbear
itsdevbear requested a review from a team July 4, 2024 19:49
@ValarDragon

ValarDragon commented Jul 4, 2024 •

Copy link
Copy Markdown
Contributor

Id remove the RWmutex here personally (but I dont think it matters/am fine either way). This is for the most part only called from single threaded contexts, so your paying extra overhead to have an RWMutex over a standard mutex. (I'd be shocked if a blocking profile showed anytime under this mutex)

Only compiling once is great!

@melekes melekes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @itsdevbear ❤️

Comment thread internal/autofile/group.go Outdated
type GroupReader struct {
*Group
mtx sync.Mutex
mtx sync.RWMutex

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
mtx sync.RWMutex

@melekes
melekes added this pull request to the merge queue Jul 8, 2024
Merged via the queue into cometbft:main with commit 56bc713 Jul 8, 2024
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.

4 participants