Skip to content

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Sep 19, 2025

Description

Currently, fmt_short allocates a String. It is used quite a few times in trace! statements. This makes it not allocate.

Not sure if it is worth it.

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.
    • List all breaking changes in the above "Breaking Changes" section.
    • Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are:

Copy link

github-actions bot commented Sep 19, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3460/docs/iroh/

Last updated: 2025-09-22T09:28:03Z

Copy link

github-actions bot commented Sep 19, 2025

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 5388c35

@n0bot n0bot bot added this to iroh Sep 19, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Sep 19, 2025
pub const LENGTH: usize = ed25519_dalek::PUBLIC_KEY_LENGTH;
}

struct PublicKeyShort(PublicKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

The old code used space for 10 bytes on the heap. This version uses 32 bytes on the stack?

I think it's a great idea to try and get rid of the heap allocation. But maybe you can give PublicKeyShort only the 5 bytes needed for the display?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you could do that easily. PublicKeyShort is not part of the public API, so you can optimize it.

Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

Thanks! I think the optimisation of only copying 5 bytes is worth it here.

@rklaehn rklaehn added this pull request to the merge queue Sep 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 22, 2025
@rklaehn rklaehn added this pull request to the merge queue Sep 22, 2025
Merged via the queue into main with commit 5285cc0 Sep 22, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants