Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call GetGenesis only once #13796

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Call GetGenesis only once #13796

merged 1 commit into from
Mar 26, 2024

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Mar 25, 2024

What type of PR is this?

Other

What does this PR do? Why is it needed?

Throughout the whole time while the validator client is running, it is connected to a beacon node from one and the same network. Although the genesis time of this network is fixed, we request it from the beacon node many times over and over again, which is wasteful, This PR uses a sync primitive called Once to make sure that we perform only one API request (allowing another call if the previous failed). We then store the result of this request in a struct field and return it immediately from further invocations of GetGenesis.

The result of this change is clearly visible in the below picture, The blue line marks the point at which a validator client running 32 keys was restarted with this PR's changes. For 1024 keys we currently make as many as 7 requests per second. After the change, assuming no errors when executing the API call, the number of requests is always 1 regardless of the number of keys.

image

@rkapka rkapka added API Api related tasks Validator Client labels Mar 25, 2024
@rkapka rkapka requested a review from a team as a code owner March 25, 2024 13:40
@rkapka rkapka requested review from kasey, rauljordan and nisdas March 25, 2024 13:40
@rkapka rkapka added the Ready For Review A pull request ready for code review label Mar 25, 2024
Copy link
Contributor

@saolyn saolyn left a comment

Choose a reason for hiding this comment

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

Nice!

@rkapka rkapka added this pull request to the merge queue Mar 26, 2024
Merged via the queue into develop with commit 6de7df6 Mar 26, 2024
16 of 17 checks passed
@rkapka rkapka deleted the GetGenesis-once branch March 26, 2024 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Ready For Review A pull request ready for code review Validator Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants