Skip to content

p2p/enode: fix FairMix timer handling#18732

Merged
anacrolix merged 1 commit intoerigontech:mainfrom
MozirDmitriy:fix/fairmix-timer-stop
Jan 22, 2026
Merged

p2p/enode: fix FairMix timer handling#18732
anacrolix merged 1 commit intoerigontech:mainfrom
MozirDmitriy:fix/fairmix-timer-stop

Conversation

@MozirDmitriy
Copy link
Copy Markdown
Contributor

FairMix.Next created a new timer on each loop iteration and deferred timer.Stop() until the function returned. When multiple iterations occurred (e.g., sources ended or Next waited on fromAny), timers accumulated unnecessarily and stayed alive longer than needed.
Stop timers explicitly per-iteration inside FairMix.Next to avoid accumulating deferred timers and reduce redundant allocations.

@anacrolix anacrolix merged commit d787868 into erigontech:main Jan 22, 2026
16 checks passed
@anacrolix
Copy link
Copy Markdown
Contributor

In hindsight, since Go 1.23, the only thing that was actually needed here was to remove the defer. In #18754 I've also avoided the extra timer allocations too.

taratorio pushed a commit that referenced this pull request Jan 22, 2026
#18732 correctly identifies timer cleanup defers stacking unnecessarily.
This handles the cleanup and channel management per Go 1.23.
Copy link
Copy Markdown

@angelsmia777-milionz angelsmia777-milionz left a comment

Choose a reason for hiding this comment

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

Process difficulty was extremely a lot.

Copy link
Copy Markdown

@angelsmia777-milionz angelsmia777-milionz left a comment

Choose a reason for hiding this comment

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

I did not know about the timers did this change the information

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.

3 participants