Created
June 26, 2018 15:15
-
-
Save Dieterbe/b0f013ec06a9dff26feb218f43d8d3ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pprof) list getSeriesCachedStore | |
Total: 11.87GB | |
ROUTINE ======================== github.com/grafana/metrictank/api.(*Server).getSeriesCachedStore in /go/src/github.com/grafana/metrictank/api/dataprocessor.go | |
0 3.73GB (flat, cum) 31.38% of Total | |
. . 498:} | |
. . 499: | |
. . 500:// will only fetch until until, but uses ctx.To for debug logging | |
. . 501:func (s *Server) getSeriesCachedStore(ctx *requestContext, until uint32) ([]chunk.Iter, error) { | |
. . 502: var iters []chunk.Iter | |
. 512.03kB 503: var prevts uint32 | |
. . 504: | |
. . 505: _, span := tracing.NewSpan(ctx.ctx, s.Tracer, "getSeriesCachedStore") | |
. . 506: defer span.Finish() | |
. . 507: span.SetTag("key", ctx.AMKey) | |
. . 508: span.SetTag("from", ctx.From) | |
. . 509: span.SetTag("until", until) | |
. . 510: | |
. . 511: reqSpanBoth.ValueUint32(ctx.To - ctx.From) | |
. . 512: logLoad("cassan", ctx.AMKey, ctx.From, ctx.To) | |
. . 513: | |
. . 514: log.Debug("cache: searching query key %s, from %d, until %d", ctx.AMKey, ctx.From, until) | |
. 512.22kB 515: cacheRes, err := s.Cache.Search(ctx.ctx, ctx.AMKey, ctx.From, until) | |
. . 516: if err != nil { | |
. . 517: return iters, err | |
. . 518: } | |
. . 519: log.Debug("cache: result start %d, end %d", len(cacheRes.Start), len(cacheRes.End)) | |
. . 520: | |
. . 521: // check to see if the request has been canceled, if so abort now. | |
. . 522: select { | |
. . 523: case <-ctx.ctx.Done(): | |
. . 524: //request canceled | |
. . 525: return iters, nil | |
. . 526: default: | |
. . 527: } | |
. . 528: | |
. . 529: for _, itgen := range cacheRes.Start { | |
. . 530: iter, err := itgen.Get() | |
. . 531: prevts = itgen.Ts | |
. . 532: if err != nil { | |
. . 533: // TODO(replay) figure out what to do if one piece is corrupt | |
. . 534: tracing.Failure(span) | |
. . 535: tracing.Errorf(span, "itergen: error getting iter from Start list %+v", err) | |
. . 536: return iters, err | |
. 2.42GB 537: } | |
. . 538: iters = append(iters, *iter) | |
. . 539: } | |
. . 540: | |
. . 541: // check to see if the request has been canceled, if so abort now. | |
. . 542: select { | |
. . 543: case <-ctx.ctx.Done(): | |
. . 544: //request canceled | |
. . 545: return iters, nil | |
. . 546: default: | |
. . 547: } | |
. . 548: | |
. . 549: // the request cannot completely be served from cache, it will require store involvement | |
. . 550: if !cacheRes.Complete { | |
. . 551: if cacheRes.From != cacheRes.Until { | |
. . 552: storeIterGens, err := s.BackendStore.Search(ctx.ctx, ctx.AMKey, ctx.Req.TTL, cacheRes.From, cacheRes.Until) | |
. . 553: if err != nil { | |
. . 554: return iters, err | |
. . 555: } | |
. . 556: // check to see if the request has been canceled, if so abort now. | |
. . 557: select { | |
. . 558: case <-ctx.ctx.Done(): | |
. 1.30GB 559: //request canceled | |
. . 560: return iters, nil | |
. . 561: default: | |
. . 562: } | |
. . 563: | |
. . 564: for i, itgen := range storeIterGens { | |
(pprof) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment