Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

shrinks size of Packet.Meta#22224

Merged
behzadnouri merged 3 commits intosolana-labs:masterfrom
behzadnouri:packet-meta-lite
Jan 4, 2022
Merged

shrinks size of Packet.Meta#22224
behzadnouri merged 3 commits intosolana-labs:masterfrom
behzadnouri:packet-meta-lite

Conversation

@behzadnouri
Copy link
Copy Markdown
Contributor

@behzadnouri behzadnouri commented Jan 2, 2022

Problem

Tons of packets are continuously on the fly. Some are garbage collected by the recycler and stay in memory; and some are pinned to cuda. So it is necessary to keep their memory footprint small.

Summary of Changes

  • Removed unused Packet.Meta.{seed,slot}.
  • Changed Meta.addr field type to std::net::IpAddr. v6 field so becomes redundant and is dropped.
  • Switched to bitflags instead of separate bool type for each flag.
  • This reduces the struct size from 80 bytes to 32 bytes.
  • There is a #[repr(C)] but to my knowledge this is not used in any of the bindings. So I guess the changes should not cause compatibility issues.

Instead of a separate bool type for each flag, all the flags can be
encoded in a type-safe bitflags encoded in a single u8:
https://github.com/solana-labs/solana/blob/d6ec103be/sdk/src/packet.rs#L19-L31
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 3, 2022

Codecov Report

Merging #22224 (5545d0e) into master (d6ec103) will increase coverage by 0.0%.
The diff coverage is 88.7%.

@@           Coverage Diff           @@
##           master   #22224   +/-   ##
=======================================
  Coverage    81.0%    81.0%           
=======================================
  Files         523      523           
  Lines      146497   146484   -13     
=======================================
+ Hits       118741   118748    +7     
+ Misses      27756    27736   -20     

@behzadnouri behzadnouri marked this pull request as ready for review January 3, 2022 13:19
Copy link
Copy Markdown
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

Nice! 45B/per savings?

Copy link
Copy Markdown
Contributor

@sakridge sakridge left a comment

Choose a reason for hiding this comment

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

lgtm

@behzadnouri behzadnouri merged commit 01a096a into solana-labs:master Jan 4, 2022
@behzadnouri behzadnouri deleted the packet-meta-lite branch January 4, 2022 13:53
mergify Bot added a commit that referenced this pull request Jan 4, 2022
* removes seed and slot fields from Packet.Meta

507367e
updated window-service to send shreds (as opposed to packets) to
retransmit-stage and so seed and slot fields in Packet.Meta are unused:
https://github.com/solana-labs/solana/blob/d6ec103be/sdk/src/packet.rs#L27-L28

(cherry picked from commit aa9f7ed)

* uses std::net::IpAddr type for Packet.Meta.addr

(cherry picked from commit 73a7741)

# Conflicts:
#	streamer/src/streamer.rs

* adds bitflags to Packet.Meta

Instead of a separate bool type for each flag, all the flags can be
encoded in a type-safe bitflags encoded in a single u8:
https://github.com/solana-labs/solana/blob/d6ec103be/sdk/src/packet.rs#L19-L31

(cherry picked from commit 01a096a)

# Conflicts:
#	sdk/Cargo.toml

* removes backport merge conflicts

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
@brooksprumo brooksprumo mentioned this pull request Jan 5, 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.

4 participants