Skip to content

Fold the rebind counter and traffic flags into one atomic word - #1820

Open
nbrownus wants to merge 2 commits into
masterfrom
rebind-epoch
Open

Fold the rebind counter and traffic flags into one atomic word#1820
nbrownus wants to merge 2 commits into
masterfrom
rebind-epoch

Conversation

@nbrownus

@nbrownus nbrownus commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Reduces the size of the HostInfo struct (shaved 24 bytes off on my computer) and fixes a known/accepted data race with rebindCount which is more interesting now that we are using it on more than just iOS.

The HostInfo reduction comes about by turning many atomic.Bools into a single atomic.Uint32 (which is what an atomic.Bool is under the hood) and ordering the struct to reduce padding. rebindCount safety comes about because 29 bits of the atomic.Uint32 are allocated for it instead of the old raw uint8 via lastRebindCount, and it becomes an atomic for free.

The rebind counter comparison is handled in ConnectionManager.Out now in the same atomic operation that records outbound traffic.

There was no change in throughput or CPU in my linux perf tests (a c8a.16xlarge server with 16 c8a.xlarge clients running iperf/reverse iperf for 5 minutes. I do expect some memory savings on highly connected hosts.

@nbrownus nbrownus added this to the v1.12.0 milestone Jul 24, 2026
@JackDoan
JackDoan self-requested a review July 24, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant