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

Reuse timers with sync.Pool #31

Merged
merged 1 commit into from
May 30, 2024
Merged

Reuse timers with sync.Pool #31

merged 1 commit into from
May 30, 2024

Conversation

millfort
Copy link
Contributor

@millfort millfort commented May 22, 2024

Here is the top out for alloc space of heap profile:

      flat  flat%   sum%        cum   cum%
 5845.32MB 42.91% 42.91%  5845.32MB 42.91%  github.com/sasha-s/go-deadlock.callers (inline)
 2851.22MB 20.93% 63.84%  2851.22MB 20.93%  time.NewTimer
 2243.68MB 16.47% 80.32%  8089.69MB 59.39%  github.com/sasha-s/go-deadlock.lock

I haven't figured out how to optimize callers. But for time.NewTimer the change seemed to be quite simple. So I made it.


This change is Reviewable

Copy link
Owner

@sasha-s sasha-s left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @millfort)


deadlock.go line 207 at r1 (raw file):

func releaseTimer(t *time.Timer) {
	if !t.Stop() {
		<-t.C

Would
for range t.C {}

be cleaner here?

@millfort
Copy link
Contributor Author

Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @millfort)

deadlock.go line 207 at r1 (raw file):

func releaseTimer(t *time.Timer) {
	if !t.Stop() {
		<-t.C

Would for range t.C {}

be cleaner here?

Stop does not close the channel

Copy link
Owner

@sasha-s sasha-s left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 2 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @millfort)


deadlock.go line 207 at r1 (raw file):

Previously, millfort (Igor Ermakov) wrote…

Stop does not close the channel

LGTM

@sasha-s sasha-s merged commit ed6f7f6 into sasha-s:master May 30, 2024
2 checks passed
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.

2 participants