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

perf: use NodeContact instead of Enr for sending talk_req() #279

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

KolbyML
Copy link
Contributor

@KolbyML KolbyML commented Feb 12, 2025

Description

    pub fn try_from_enr(enr: Enr, ip_mode: IpMode) -> Result<Self, NonContactable> {
        let socket_addr = match ip_mode.get_contactable_addr(&enr) {
            Some(socket_addr) => socket_addr,
            None => return Err(NonContactable { enr }),
        };

        Ok(NodeContact {
            public_key: enr.public_key(),
            socket_addr,
            enr: Some(enr),
        })
    }

Every time we were sending a talk request we were converting the Enr to NodeContact. In doing this operation we call public_key() or in other terms we are recovering the public key every time we send a talk request, in Portal we send all our messages over TalkRequests, currently public_key() is taking over 8.7% of the samples I get from running my benchmark ethereum/trin#1660, by reusing the NodeContact we can avoid repetitively recovering the public key every time

In the benchmark I am sending 6.7GB of block history, so 8.7 percent is fairly significant

image

Notes & open questions

@jxs @AgeManning @ackintosh ping for review

Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Yep. Typically we know an ENR rather than a NodeContact, which I imagine is why this was the API.

The TalkReq feature as far as I know is mainly used by you guys, so feel free to change the public API.

We will have to make this change with a new version however as it changes the public facing API.

@AgeManning AgeManning merged commit e2ac53b into sigp:master Feb 12, 2025
6 checks passed
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