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

Test memory allocations for overwhelmed Tailer. #5996

Closed
wants to merge 2 commits into from

Conversation

jeschkies
Copy link
Contributor

This draft is investigating the memory consumption of the Tailer when the client cannot keep up.

Run tests with

go test -mod=vendor ./pkg/ingester/ -run ^Test_Allocations$ -benchmem -memprofile memprofile.out -cpuprofile cpuprofile.out

View profile with

go tool pprof -source_path=$(pwd) -http :9403 memprofile.out

The Source view is interesting:

github.com/grafana/loki/pkg/ingester.(*tailer).send

/home/karsten/src/loki/pkg/ingester/tailer.go

  Total:           0   198.01MB (flat, cum)  8.17%
    119            .          .           		} 
    120            .          .           		t.dropStream(stream) 
    121            .          .           		return 
    122            .          .           	} 
    123            .          .            
    124            .   198.01MB           	streams := t.processStream(stream, lbs) 
    125            .          .           	if len(streams) == 0 { 
    126            .          .           		return 
    127            .          .           	} 
    128            .          .           	for _, s := range streams { 
    129            .          .           		select { 

Ideally there would be little memory consumed.

@@ -113,7 +113,7 @@ func (t *tailer) send(stream logproto.Stream, lbs labels.Labels) {

// if we are already dropping streams due to blocked connection, drop new streams directly to save some effort
if blockedSince := t.blockedSince(); blockedSince != nil {
if blockedSince.Before(time.Now().Add(-time.Second * 15)) {
if blockedSince.Before(time.Now().Add(-time.Millisecond * 100)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would expect to hit this more often.

@jeschkies
Copy link
Contributor Author

@jeschkies jeschkies closed this May 3, 2022
@jeschkies jeschkies deleted the karsten/tailer-memory branch May 3, 2022 11:47
@dannykopping
Copy link
Contributor

FWIW, I still think this is necessary given #6063 doesn't contain any tests

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

Successfully merging this pull request may close these issues.

2 participants