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

feat: cumulative pprof merge for pull mode #1794

Merged
merged 9 commits into from
Dec 16, 2022

Conversation

korniltsev
Copy link
Collaborator

@korniltsev korniltsev commented Dec 7, 2022

Do the same thing as in client grafana/pyroscope-go#24 for scrape and before ingestion

@codecov
Copy link

codecov bot commented Dec 7, 2022

Codecov Report

Base: 66.47% // Head: 66.47% // No change to project coverage 👍

Coverage data is based on head (b559891) compared to base (dcfd695).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1794    +/-   ##
========================================
  Coverage   66.47%   66.47%            
========================================
  Files         172      172            
  Lines        5594     5594            
  Branches     1260     1506   +246     
========================================
  Hits         3718     3718            
  Misses       1867     1867            
  Partials        9        9            

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2022

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
webapp/public/assets/app.js 502.06 KB (0%) 10.1 s (0%) 3.2 s (-27.55% 🔽) 13.2 s
webapp/public/assets/app.css 19.69 KB (0%) 394 ms (0%) 0 ms (+100% 🔺) 394 ms
webapp/public/assets/styles.css 9.58 KB (0%) 192 ms (0%) 0 ms (+100% 🔺) 192 ms
packages/pyroscope-flamegraph/dist/index.js 129.99 KB (0%) 2.6 s (0%) 1.2 s (-42.97% 🔽) 3.8 s
packages/pyroscope-flamegraph/dist/index.node.js 130.72 KB (0%) 2.7 s (0%) 634 ms (+57.94% 🔺) 3.3 s
packages/pyroscope-flamegraph/dist/index.css 7.97 KB (0%) 160 ms (0%) 0 ms (+100% 🔺) 160 ms

@korniltsev korniltsev marked this pull request as ready for review December 14, 2022 13:02
Comment on lines +92 to +95
p.Profile = mergedProfileBytes.Bytes()
p.PreviousProfile = nil
p.SampleTypeConfig = stConfig
p.RawData = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note: I might be mistaken but this means we will deserialize pprof protobuf bytes again in parser down the data flow, although we already have merged: as far as I understand we can't use it directly because it is github.com/google/pprof/profile.Profile – which is very sad

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is a different type.
Maybe we should do the new merge only for remote write case? and let the parser do the merge(diff)

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should do the new merge only for remote write case? and let the parser do the merge(diff)

yeah this makes sense to me

@@ -67,6 +68,33 @@ func (p *RawProfile) Push(profile []byte, cumulative bool) *RawProfile {
return p.next
}

func (p *RawProfile) MergeCumulative(ms *cumulativepprof.Mergers) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should return an error

Comment on lines 432 to 440
sl.scraper.profile = profile.Push(buf.Bytes(), sl.scraper.cumulative)
if !sl.disableCumulativeMerge {
if sl.scraper.cumulative && profile.SampleTypeConfig != nil {
if sl.scraper.mergers == nil {
sl.scraper.mergers = cumulativepprof.NewMergers()
}
profile.MergeCumulative(sl.scraper.mergers)
}
}
Copy link
Collaborator

@kolesnikovae kolesnikovae Dec 14, 2022

Choose a reason for hiding this comment

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

I don't fully understand why we do this check: profile.SampleTypeConfig != nil. Above I see

	if sl.scraper.profile == nil {
		sl.scraper.profile = &pprof.RawProfile{
			SampleTypeConfig: sl.scraper.config.SampleTypes,
		}
	}

I must be missing something, but it does not seem there is a case when profile.SampleTypeConfig != nil evaluates as false.

A nit: consider moving the logic to Push (moving sl.scraper.mergers as well). The initial idea was that this method is a bridge between pull and push modes. But now it looks like a caller should know too much about RawProfile internals.

Also, I can't remember why we need this sl.scraper.cumulative outside the profile – it seems it is not used there and should be moved to RawProfile as well

@kolesnikovae
Copy link
Collaborator

Looks very good and promising!

@@ -201,7 +201,8 @@ func newServerService(c *config.Server) (*serverService, error) {
svc.scrapeManager = scrape.NewManager(
svc.logger.WithField("component", "scrape-manager"),
ingester,
defaultMetricsRegistry)
defaultMetricsRegistry,
svc.config.DisableCumulativeMerge || !svc.config.RemoteWrite.Enabled)
Copy link
Member

Choose a reason for hiding this comment

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

@korniltsev I have a question about this.

First of all, I rewrote the original boolean logic, because it was too confusing.

So this is what we have now:
Screenshot 2022-12-15 at 4 21 43 PM

But even after doing that I don't think I understand why if remote write is enabled we should be doing force merges. Could you explain?

Copy link
Member

@petethepig petethepig left a comment

Choose a reason for hiding this comment

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

Everything makes sense but I want to chat about remote write / no remote write cases

@petethepig petethepig merged commit 89265cd into main Dec 16, 2022
@petethepig petethepig deleted the feat/scrape_cumulative_profiles branch December 16, 2022 06:48
korniltsev added a commit that referenced this pull request Jan 18, 2023
korniltsev added a commit that referenced this pull request Jan 18, 2023
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.

3 participants