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

server: fix timer leak #900

Merged
merged 1 commit into from
Jul 21, 2014
Merged

server: fix timer leak #900

merged 1 commit into from
Jul 21, 2014

Conversation

yichengq
Copy link
Contributor

@xiangli-cmu @bmizerany

@yichengq
Copy link
Contributor Author

@bmizerany finds out that there's tons of Timer that that are not recycled, which is because the timer vars used in defer in monitor functions are always referred. Big thank to @bmizerany and @xiangli-cmu !
This could leak 9MB in one hour, which is a quite severe bug.

@bmizerany
Copy link
Contributor

I'm still waiting on the profiler to finish. This could be awhile.

@bmizerany
Copy link
Contributor

Okay. After 2e6 inserts with this patch, all timers previously left on the heap are now gone. Great job! LGTM.

@bmizerany
Copy link
Contributor

NOTE: There is memory growth as the indexes get larger. This is believed to be due to the index being stored as a string in the log entries. This bloat is only noticable in the early life of etcd and smooths out pretty quick since it takes longer to crank it up an extra digit.

xiang90 added a commit that referenced this pull request Jul 21, 2014
@xiang90 xiang90 merged commit bdeb96b into etcd-io:master Jul 21, 2014
@@ -772,9 +772,9 @@ func (s *PeerServer) startRoutine(f func()) {
func (s *PeerServer) monitorSnapshot() {
for {
timer := time.NewTimer(s.snapConf.checkingInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to jump in, but wondering why a timer here instead of a ticker outside of the loop?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. @unihorn, can you take a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aybabtme I thought snapshot may take rather long time compared to checkingInterval, and this could cache many ticks. But actually ticker drops these if there is an appending one.
I think it should be better to use ticker now.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants