Skip to content

Investigate flamegraph coloring #1330

@eh-am

Description

@eh-am

Point of having colors per package is to be able to easily distinguish what package a stacktrace belongs to.
But apparently either there's an error with the hash calculation, or there's an edge case where adjacent nodes (packages) resolve to the same color:

image
https://demo-dev.pyroscope.io/?query=rideshare-app-golang.alloc_space%7B%7D

We should investigate this, and maybe overwrite the calculated color in edge cases like this?
Idea: https://en.wikipedia.org/wiki/Graph_coloring

Data for local reproduction:

{"version":1,"flamebearer":{"names":["total","runtime/pprof.profileWriter","runtime/pprof.newProfileBuilder","runtime/pprof.(*profileBuilder).readMapping","runtime/pprof.parseProcSelfMaps","runtime/pprof.elfBuildID","os.Open","os.OpenFile","os.openFileNolog","os.newFile","fmt.Sprintf","fmt.newPrinter","sync.(*Pool).Get","fmt.glob..func1","runtime/pprof.(*profileBuilder).addMapping","runtime/pprof.(*profileBuilder).addMappingEntry","os.ReadFile","runtime/pprof.(*profileBuilder).build","runtime/pprof.(*protobuf).strings","runtime/pprof.(*protobuf).string","runtime/pprof.(*profileBuilder).pbSample","runtime/pprof.(*protobuf).uint64s","runtime/pprof.(*protobuf).varint","runtime/pprof.(*protobuf).int64s","runtime/pprof.(*protobuf).int64","runtime/pprof.(*protobuf).uint64","runtime/pprof.(*profileBuilder).flush","compress/gzip.(*Writer).Write","compress/flate.NewWriter","compress/flate.(*compressor).init","compress/flate.newDeflateFast","runtime/pprof.(*profileBuilder).build.func1","runtime/pprof.(*profileBuilder).pbLabel","runtime/pprof.(*protobuf).endMessage","runtime/pprof.(*protobuf).length","runtime/pprof.(*profileBuilder).stringIndex","runtime/pprof.(*profileBuilder).pbMapping","runtime/pprof.(*protobuf).uint64Opt","runtime/pprof.(*protobuf).int64Opt","runtime/pprof.(*profileBuilder).appendLocsForStack","runtime/pprof.allFrames","runtime/pprof.(*profileBuilder).emitLocation","runtime/pprof.(*profileBuilder).pbLine","compress/flate.newHuffmanBitWriter","compress/flate.newHuffmanEncoder","compress/gzip.(*Writer).Close","compress/flate.(*Writer).Close","compress/flate.(*compressor).close","compress/flate.(*compressor).encSpeed","compress/flate.(*huffmanBitWriter).writeBlockDynamic","compress/flate.(*huffmanEncoder).generate","compress/flate.(*huffmanBitWriter).indexTokens","runtime/pprof.(*profileBuilder).addCPUData","runtime/pprof.(*profMap).lookup","runtime.main","main.main","net/http.ListenAndServe","net/http.(*Server).ListenAndServe","net/http.(*Server).Serve","net/http.(*Server).newConn","net.(*TCPListener).Accept","net.(*TCPListener).accept","net.(*netFD).accept","syscall.Getsockname","syscall.anyToSockaddr","net.sockaddrToTCP","net/http.(*http2clientStream).doRequest","net/http.(*http2clientStream).writeRequest","net/http.(*http2clientStream).writeRequestBody","sync.(*Pool).pin","sync.(*Pool).pinSlow","net/http.(*http2Framer).WriteData","net/http.(*http2Framer).WriteDataPadded","net/http.(*http2Framer).endWrite","bufio.(*Writer).Write","net/http.http2stickyErrWriter.Write","crypto/tls.(*Conn).Write","crypto/tls.(*Conn).writeRecordLocked","crypto/tls.(*halfConn).encrypt","crypto/tls.(*prefixNonceAEAD).Seal","crypto/aes.(*gcmAsm).Seal","crypto/aes.sliceForAppend","bufio.(*Writer).Flush","net/http.(*http2clientStream).encodeAndWriteHeaders","net/http.(*http2ClientConn).writeHeaders","net/http.(*http2ClientConn).readLoop","net/http.(*http2clientConnReadLoop).run","net/http.(*http2clientConnReadLoop).processHeaders","net/http.(*http2clientConnReadLoop).handleResponse","net/http.(*http2Framer).ReadFrame","net/http.(*http2Framer).readMetaFrame","vendor/golang.org/x/net/http2/hpack.(*Decoder).Write","vendor/golang.org/x/net/http2/hpack.(*Decoder).parseHeaderFieldRepr","vendor/golang.org/x/net/http2/hpack.(*Decoder).parseFieldLiteral","vendor/golang.org/x/net/http2/hpack.(*Decoder).readString","vendor/golang.org/x/net/http2/hpack.(*Decoder).callEmit","net/http.(*http2Framer).readMetaFrame.func1","net/http.(*connReader).backgroundRead","net.(*conn).Read","net/http.(*conn).serve","net/http.serverHandler.ServeHTTP","net/http.(*ServeMux).ServeHTTP","net/http.HandlerFunc.ServeHTTP","main.carRoute","rideshare/car.OrderCar","rideshare/utility.FindNearestVehicle","github.com/pyroscope-io/client/pyroscope.TagWrapper","runtime/pprof.Do","runtime/pprof.WithLabels","main.bikeRoute","rideshare/bike.OrderBike","context.WithValue","net/http.newBufioWriterSize","bufio.NewWriterSize","net/http.newBufioReader","bufio.NewReader","bufio.NewReaderSize","net/http.(*response).finishRequest","net/http.putBufioWriter","sync.(*Pool).Put","net/http.(*chunkWriter).Write","net/http.(*chunkWriter).writeHeader","net/http.Header.WriteSubset","net/http.Header.writeSubset","net/http.Header.sortedKeyValues","net/http.(*conn).readRequest","net/http.readRequest","net/url.ParseRequestURI","net/url.parse","net/textproto.(*Reader).ReadMIMEHeader","context.WithCancel","context.propagateCancel","context.(*cancelCtx).Done","github.com/pyroscope-io/client/internal/session.(*Session).takeSnapshots","github.com/pyroscope-io/client/internal/session.(*Session).reset","runtime/pprof.WriteHeapProfile","runtime/pprof.writeHeap","runtime/pprof.writeHeapInternal","runtime/pprof.writeHeapProto","syscall.Open","syscall.openat","syscall.BytePtrFromString","syscall.ByteSliceFromString","os.(*File).Stat","runtime/pprof.(*profileBuilder).pbValueType","runtime/pprof.writeHeapProto.func1","compress/flate.(*Writer).Write","compress/flate.(*compressor).write","github.com/pyroscope-io/client/pyroscope.(*standardLoggerImpl).Debugf","fmt.Printf","fmt.Fprintf","fmt.(*pp).doPrintf","fmt.(*buffer).writeString","github.com/pyroscope-io/client/internal/session.(*Session).reset.func1","runtime/pprof.StartCPUProfile","github.com/pyroscope-io/client/internal/session.(*Remote).handleJobs","github.com/pyroscope-io/client/internal/session.(*Remote).safeUpload","github.com/pyroscope-io/client/internal/session.(*Remote).uploadProfile","net/url.Values.Set","net/url.Values.Encode","strings.(*Builder).WriteString","net/url.(*URL).String","net/http.NewRequest","net/http.NewRequestWithContext","net/http.Header.Set","net/textproto.MIMEHeader.Set","net/http.(*Client).Do","net/http.(*Client).do","net/http.(*Client).send","net/http.send","net/http.send.func1","net/http.(*Transport).RoundTrip","net/http.(*Transport).roundTrip","net/http.http2noDialH2RoundTripper.RoundTrip","net/http.(*http2Transport).RoundTrip","net/http.(*http2Transport).RoundTripOpt","net/http.(*http2ClientConn).RoundTrip","net/http.(*Client).makeHeadersCopier","net/http.cloneOrMakeHeader","net/http.Header.Clone","mime/multipart.NewWriter","mime/multipart.randomBoundary","mime/multipart.(*part).Write","bytes.(*Buffer).Write","bytes.(*Buffer).grow","bytes.makeSlice","mime/multipart.(*Writer).FormDataContentType","mime/multipart.(*Writer).CreateFormFile","mime/multipart.(*Writer).CreatePart","io.Copy","io.copyBuffer","bytes.(*Buffer).WriteTo","io/ioutil.ReadAll","io.ReadAll"],"levels":[[0,5864400682,0,0],[0,147547556,0,155,0,4167832858,0,133,0,23645730,0,99,0,524328,0,97,0,3671904,0,85,0,100619048,0,66,0,1573000,0,54,0,1418986258,0,1],[0,147547556,0,156,0,4167832858,42394754,134,0,8395904,524400,125,0,2099202,0,117,0,4735046,0,114,0,6842402,0,112,0,1573176,0,100,0,524328,524328,98,0,3671904,0,86,0,100619048,0,67,0,1573000,0,55,0,20055246,0,52,0,1358960527,0,17,0,39970485,0,2],[0,147547556,524296,157,42394754,1304129056,0,153,0,524304,0,148,0,2820784744,0,135,524400,1572992,524296,130,0,3676676,0,112,0,2621836,524416,126,0,1574402,0,82,0,524800,0,118,0,4735046,0,115,0,6842402,6842402,113,0,1573176,0,101,524328,2623080,0,89,0,1048824,0,87,0,2623601,0,83,0,97995447,70350434,68,0,1573000,0,56,0,20055246,20055246,53,0,8932496,0,45,0,1204290812,0,27,0,68861142,0,39,0,4735384,0,36,0,66347948,0,20,0,5792745,0,18,0,39970485,0,3],[524296,1573632,0,192,0,81790640,524296,187,0,524336,524336,186,0,48450072,0,182,0,2622596,0,180,0,3671200,0,166,0,2097856,0,164,0,2097664,0,162,0,1048688,0,161,0,1573184,0,159,0,1573392,1573392,158,42394754,1304129056,1304129056,154,0,524304,0,149,0,2820784744,0,136,1048696,1048696,524360,131,0,3151876,3151876,113,0,524800,0,12,524416,1573060,1573060,129,0,524360,0,127,0,1574402,0,120,0,524800,0,119,0,4735046,4735046,116,6842402,1573176,0,102,524328,2623080,524312,90,0,1048824,1048824,88,0,2623601,0,84,70350434,4207118,0,82,0,21863494,0,71,0,1574401,0,12,0,1573000,0,57,20055246,8932496,0,46,0,1204290812,672388985,28,0,43691574,11039273,41,0,25169568,25169568,40,0,3158036,3158036,35,0,526338,0,38,0,1051010,0,37,0,2103686,0,31,0,60563736,0,26,0,2627848,0,23,0,1052678,0,21,0,5792745,5792745,19,0,29483453,28959117,16,0,10487032,4718664,4],[524296,1573632,1573632,193,524296,81266344,1048600,188,524336,48450072,0,183,0,2622596,1048604,181,0,3671200,0,167,0,2097856,2097856,165,0,2097664,2097664,163,0,1048688,1048688,160,0,1573184,1573184,160,1348097202,524304,0,150,0,2820784744,488276242,137,1573056,524336,524336,132,3151876,524800,0,69,2097476,524360,524360,128,0,1574402,0,121,0,524800,0,69,11577448,524312,0,109,0,1048864,0,103,1048640,2098768,0,91,1048824,2623601,0,82,70350434,4207118,0,75,0,21863494,0,72,0,1574401,0,69,0,1573000,0,58,20055246,8932496,0,47,672388985,531901827,325459185,29,11039273,21094871,0,26,0,1050754,0,42,0,8406258,8406258,35,0,1050690,0,38,0,1049728,0,37,28327604,526338,0,24,0,1051010,0,25,0,2103686,0,32,0,60563736,0,27,0,2627848,0,24,0,1052678,1052678,22,34751862,524336,0,6,4718664,1048832,0,14,0,4719536,2622080,5],[3670824,1048792,0,150,0,79168952,0,189,524336,48450072,0,184,1048604,1573992,0,10,0,1048928,0,177,0,2622272,0,168,1354914594,524304,0,151,488276242,2332508502,57936589,138,5249268,524800,524800,70,2621836,1574402,0,122,0,524800,524800,70,11577448,524312,0,110,0,1048864,0,104,1048640,2098768,0,92,1048824,2623601,0,75,70350434,4207118,0,76,0,21863494,0,73,0,1574401,1574401,70,0,1048632,0,60,0,524368,524368,59,20055246,8932496,0,48,997848170,203294544,203294544,30,0,3148098,2623234,43,11039273,21094871,0,27,0,526338,0,38,0,524416,0,37,8406258,1050690,0,24,0,1049728,0,25,28327604,526338,0,25,0,1051010,1051010,22,0,1577861,1577861,35,0,525825,0,33,0,60563736,30500190,28,0,2627848,0,25,35804540,524336,0,7,4718664,1048832,1048832,15,2622080,1048784,0,10,0,1048672,0,6],[3670824,1048792,0,183,0,79168952,0,190,524336,48450072,48450072,185,1048604,1573992,0,11,0,1048928,0,178,0,2622272,0,169,1354914594,524304,524304,152,546212831,1397182354,524416,39,0,68434864,0,17,0,773196790,0,20,0,524304,0,144,0,35233601,0,2,8395904,1574402,0,123,12102248,524312,0,105,0,1048864,0,105,1048640,2098768,0,93,1048824,2623601,0,76,70350434,4207118,0,77,0,21863494,0,74,1574401,1048632,0,61,20579614,8932496,0,49,1203765948,524864,524864,44,11039273,21094871,14787970,28,0,526338,0,24,0,524416,0,25,8406258,1050690,0,25,0,1049728,1049728,22,28327604,526338,526338,22,2628871,525825,0,34,30500190,30063546,20110866,29,0,2627848,2627848,22,35804540,524336,0,8,8389576,1048784,0,11,0,1048672,0,7],[3670824,1048792,0,184,0,79168952,0,191,50023012,1573992,0,12,0,1048928,1048928,179,0,1573440,0,171,0,1048832,1048832,170,1902176145,746429813,138634916,41,0,650228125,650228125,40,0,9457936,0,27,0,7003810,0,36,0,51973118,0,18,0,770043758,0,26,0,1051524,0,23,0,1051139,0,21,0,1050369,0,145,0,524304,524304,35,0,35233601,0,3,8395904,1574402,0,124,12102248,524312,0,106,0,1048864,0,106,1048640,524368,0,95,0,1574400,0,94,1048824,2623601,0,77,70350434,4207118,0,78,0,21863494,0,75,1574401,1048632,0,62,20579614,6830732,0,51,0,2101764,2101764,50,1230118055,6306901,3997425,29,0,526338,0,25,0,524416,524416,22,8406258,1050690,1050690,22,32532541,525825,525825,22,50611056,9952680,9952680,30,38432388,524336,524336,9,8389576,1048784,0,12,0,1048672,0,8],[3670824,1048792,1048792,185,0,79168952,0,183,50023012,524392,524392,13,0,1049600,0,69,1048928,1573440,0,172,2041859893,509720565,0,26,0,5781840,0,42,0,81250664,81250664,35,0,2103688,0,33,0,2101509,0,38,0,6836631,0,37,650228125,9457936,0,146,0,7003810,7003810,35,0,51973118,50912206,19,0,770043758,0,27,0,1051524,1051524,22,0,524800,0,34,0,526339,526339,22,0,1050369,0,32,524304,27368657,26844265,16,0,7864944,4194368,4,8395904,1574402,0,12,12102248,524312,0,107,0,1048864,0,107,1048640,524368,524368,96,0,1574400,0,12,1048824,524400,0,78,0,2099201,0,12,70350434,4207118,0,79,0,21863494,0,76,1574401,524312,524312,65,0,524320,0,63,20579614,6830732,6830732,50,1236217244,2309476,2309476,30,0,526338,526338,22,150949766,1048784,1048784,13,0,1048672,1048672,9],[4719616,79168952,0,184,50547404,1049600,1049600,70,1048928,1573440,0,173,2041859893,509720565,0,27,0,2625859,0,33,0,524928,0,38,0,2631053,0,37,81250664,2103688,0,34,0,2101509,0,24,0,6836631,0,25,650228125,9457936,0,147,57916016,1060912,0,34,0,770043758,429772288,28,1051524,524800,524800,22,526339,1050369,0,38,27368569,524392,524392,143,4194368,524544,0,14,0,3146032,524416,5,8395904,1574402,0,69,12102248,524312,0,108,0,1048864,1048864,108,1573008,1574400,0,69,1048824,524400,0,79,0,2099201,0,69,70350434,4207118,0,80,0,21863494,0,77,2098713,524320,524320,64],[4719616,79168952,79168952,185,52645932,1573440,0,174,2041859893,509720565,285592683,28,0,2625859,0,34,0,524928,0,24,0,2631053,0,25,81250664,2103688,2103688,22,0,2101509,0,25,0,6836631,6836631,22,650228125,9457936,0,48,57916016,1060912,1060912,22,429772288,340271470,211386689,29,2102663,1050369,0,24,32087329,524544,524544,15,524416,524312,524312,10,0,2097304,0,6,8395904,1574402,1574402,70,12102248,524312,524312,111,2621872,1574400,1574400,70,1048824,524400,0,80,0,2099201,2099201,70,70350434,4207118,4207118,81,0,21863494,0,78],[136534500,1573440,0,175,2327452576,224127882,135244406,29,0,2625859,2625859,22,0,524928,0,25,0,2631053,2631053,22,83354352,2101509,2101509,22,657064756,9457936,0,49,700135905,127310941,127310941,30,0,1573840,1048976,43,2102663,1050369,0,25,33660601,2097304,0,7,27841962,524400,524400,81,76656753,21863494,0,79],[136534500,1573440,1573440,176,2462696982,86785435,86785435,30,0,2098041,1573665,43,2625859,524928,524928,22,745151670,4203527,0,51,0,5254409,5254409,50,828495822,524864,524864,44,2102663,1050369,1050369,22,33660601,2097304,0,8,105023115,21863494,0,80],[2689164022,524376,524376,44,748302457,4203527,4203527,50,871088728,1573008,1573008,9,0,524296,0,139,105023115,21863494,21863494,81],[4314856118,524296,0,140],[4314856118,524296,0,141],[4314856118,524296,524296,142]],"numTicks":5864400682,"maxSelf":1304129056},"timeline":{"startTime":1659364190,"samples":[6304930,16712907,18950191,13352494,14720150,21776399,21824332,13203013,16507351,16356591,18825494,13129670,20968349,14517314,12591380,16547030,10626895,21473821,13856154,22489255,15406811,16522745,15949326,16622527,19726181,11495577,18304684,18194619,15266856,17495817,13331671,12098932,16608503,17780512,15853791,13964439,18517224,17245946,10520800,20702041,14230968,14723513,17227886,16310148,16065237,17805071,14471643,17922489,18612950,15463460,11166089,15599593,14091119,20144241,16294483,10928891,17944183,15327337,19116039,15210069,15291403,16679164,20102877,20993157,16929371,15044203,21379784,15850719,15554780,11026710,16530215,20596191,19070384,17193373,15039736,20919730,15278616,10927055,23709193,16950349,14774017,16277002,22563389,16842079,8452988,23639545,16888078,15595528,21351555,17591192,14231922,22277458,9222456,21490899,16323508,14905996,19097390,11969285,13151987,10647819,19185601,18287914,14866124,16171499,13653299,19149501,15801940,16436063,15501091,13904154,15422519,14895045,17847868,15201222,12443184,17976409,15011268,20666837,12437268,11983741,20440431,12984647,21114004,13664194,14503014,19916664,13203058,22690935,15283546,12907306,20386680,16087174,16239725,14207572,23293243,14482535,12919552,13192777,14586607,18754259,11317542,13490343,19089834,15549640,18330438,15258367,15463442,19314424,14709774,17957384,13815714,17282848,10229494,13450150,18442240,16660253,19539815,11653641,24850973,10597391,24201742,15198626,14139815,19867510,14217886,16994557,18194072,18606316,16756771,14936979,13911618,16749623,18959168,14374298,12507166,21168490,13262520,15063478,20971500,10921723,13002808,15793862,12510317,20598760,12746033,20095256,14407779,18739737,11594873,17330491,18403108,14771415,15682339,9422016,17829908,20175147,11280722,17563955,20303460,9949976,18813051,14393576,13524501,22090008,19605241,11486054,12999160,17980669,12805622,17382299,16301264,15481232,22668170,21115471,17227566,18406256,13837409,17409195,18242313,12395593,13180874,18052640,17290379,16045719,11016433,26865977,11272658,21623562,22224946,10299739,12550621,17683472,14925313,18132062,12146216,16426536,15830524,16000645,16697525,18046647,21172515,9544308,20279185,20020299,17541388,17056769,14625547,15018542,16542275,12924041,19212199,12640474,12457598,17533092,16730952,12960187,22779233,15143785,13071489,20137256,13555064,13974023,17879471,14238551,13034500,18819386,11349038,20375064,17605652,16968434,12964133,11937672,16988508,16891924,18192902,19201180,13395255,19431165,18618079,12045890,16509657,22213678,12517354,16987884,15757212,16965639,10707588,12739725,18296361,16951761,18792851,17151333,10795358,23489618,14990431,10541687,20241463,21063314,11197633,16848139,15371247,13729168,23018745,12198195,25611439,17661243,9747766,15419676,21858993,14013589,11102026,21767521,18101463,13685015,17674745,13575984,13243475,14078617,19189659,7272580,18957035,22655135,9361448,25811186,20422239,14643074,22258865,16221174,15684250,15203889,21179618,12709249,12936753,22993760,12338268,16448976,14639997,15569735,21166000,17310208,15951611,18074761,10627404,23295074,15512281,18701954,15279769,19681246,11863226,9900266,12473058,20975697,9219428,18213684,18609313,16542232,12970498,19170947,11904237,23240336,0],"durationDelta":10,"watermarks":null},"groups":{},"telemetry":{"nanoseconds_elapsed_cold":186554608,"nanoseconds_elapsed_hot":94335246,"nanoseconds_elapsed_total":186951815},"metadata":{"format":"single","spyName":"gospy","sampleRate":0,"units":"bytes","name":"rideshare-app-golang.alloc_space 2022-08-01T14:29:55Z","appName":"rideshare-app-golang.alloc_space","startTime":1659364195,"endTime":1659367795,"query":"rideshare-app-golang.alloc_space{}","maxNodes":1024}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions