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

Fix Ingester Stutter #449

Merged
merged 8 commits into from
Jan 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/ingester/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ func (i *instance) tracesToCut(cutoff time.Duration, immediate bool) []*trace {
i.tracesMtx.Lock()
defer i.tracesMtx.Unlock()

now := time.Now()
cutoffTime := time.Now().Add(cutoff)
tracesToCut := make([]*trace, 0, len(i.traces))

for key, trace := range i.traces {
if now.Add(cutoff).After(trace.lastAppend) || immediate {
if cutoffTime.After(trace.lastAppend) || immediate {

Choose a reason for hiding this comment

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

if you move immediate to the front, it will short circuit the cutoffTime calculation. this may reduce the amount of time tracesMtx is held

Copy link
Member Author

Choose a reason for hiding this comment

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

immediate is almost never true. it only occurs when the ingester is shutting down to force flush traces from the active trace map to disk. i think this ordering is fine.

Choose a reason for hiding this comment

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

fair enough, thanks for considering it.

tracesToCut = append(tracesToCut, trace)
delete(i.traces, key)
}
Expand Down