Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

txpool: sync.Mutex instead of RWMutex #735

Merged
merged 3 commits into from
Nov 14, 2022
Merged

txpool: sync.Mutex instead of RWMutex #735

merged 3 commits into from
Nov 14, 2022

Conversation

yperbasis
Copy link
Collaborator

@yperbasis yperbasis commented Nov 14, 2022

simplelru is not thread safe. During the Get operation, the recentness of the accessed item is updated, so it is not a pure read-operation. Therefore, the mutex we need to protect the LRUs in txpool is a full mutex, not RLock. See erigontech/erigon#4679 (comment) and ethereum/go-ethereum#26164.

Also, RWMutex has a performance overhead compared with the vanilla one (see, for example, golang/go#38813).

Kudos to Martin Swende for pointing to the issue.

@yperbasis yperbasis merged commit 10e8428 into main Nov 14, 2022
@yperbasis yperbasis deleted the lru_lock branch November 14, 2022 10:59
yperbasis added a commit to erigontech/erigon that referenced this pull request Nov 14, 2022
michaelneuder pushed a commit to michaelneuder/erigon that referenced this pull request Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant