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

refactor(iroh-net): Store DerpNodes as Arcs inside DerpMap #1379

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

flub
Copy link
Contributor

@flub flub commented Aug 18, 2023

Description

The DerpMap is now immutable, storing the DerpNodes inside it as
Arc'ed structs directly saves a lot of copying and moving them into
Arcs at runtime for a bit more heap allocations up front.

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

The DerpMap is now immutable, storing the DerpNodes inside it as
Arc'ed structs directly saves a lot of copying and moving them into
Arcs at runtime for a bit more heap allocations up front.
@@ -137,7 +147,7 @@ pub struct DerpRegion {
/// A unique integer for a geographic region
pub region_id: u16,
/// A list of [`DerpNode`]s in this region
pub nodes: Vec<DerpNode>,
pub nodes: Vec<Arc<DerpNode>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to have DerpNode be a standalone type in this case? Can we just move the Arc into DerpNode instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean wrapping the DerpNode field inside an "inner"? Currently all the DerpNode fields (and DerpPregion and DerpMap) and pub and accessed directly everywhere. Making this change here means you only have to touch the creation of this but not the access. Doing it the other way around involves touching all the access places, probably changing the fields to methods.

I'm not strongly in favour of either, though I also don't think this version is so bad. The explicit Arc is pretty reasonable. Though if you have a strong preference I can change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

good enough for now

@flub flub added this pull request to the merge queue Aug 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 21, 2023
@flub flub added this pull request to the merge queue Aug 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 21, 2023
@flub flub enabled auto-merge August 22, 2023 08:36
@b5 b5 added this to the v0.6.0-alpha: Sync! milestone Aug 24, 2023
@flub flub added this pull request to the merge queue Aug 24, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 24, 2023
@flub flub added this pull request to the merge queue Aug 24, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 24, 2023
@flub flub added this pull request to the merge queue Aug 25, 2023
Merged via the queue into main with commit bcce8a0 Aug 25, 2023
15 checks passed
@flub flub deleted the flub/derpmap-derpnode-arc branch August 25, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants