Flame Graph — Go gRPC Pricing Service (pprof CPU)
A 30-second pprof CPU profile of a Go pricing service at 1,800 requests per second (6,680 samples): regular expressions take 45.7% of the CPU, 18.2% of it recompiling the same rule patterns on every call, and garbage collection plus allocation take another 26.6% — the pattern that says "compile once at load, cache the *regexp.Regexp". Illustrative values.
Make it your own.
title "pricing-svc — pprof CPU profile, 30 s, 6,680 samples (illustrative)"
# go tool pprof -raw http://pricing-svc:6060/debug/pprof/profile?seconds=30 | stackcollapse-go.pl
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;pricing/api._PricingService_Quote_Handler;pricing/service.(*Service).Quote;pricing/rules.(*Engine).Evaluate;regexp.(*Regexp).MatchString 1840
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;pricing/api._PricingService_Quote_Handler;pricing/service.(*Service).Quote;pricing/rules.(*Engine).Evaluate;pricing/rules.compile;regexp.Compile 1215
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;pricing/api._PricingService_Quote_Handler;pricing/service.(*Service).Quote;pricing/rules.(*Engine).Evaluate;runtime.mapaccess2_faststr 310
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;pricing/api._PricingService_Quote_Handler;pricing/service.(*Service).Quote;pricing/fx.(*Cache).Rate;sync.(*RWMutex).RLock 145
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;pricing/api._PricingService_Quote_Handler;pricing/service.(*Service).Quote;encoding/json.Unmarshal;encoding/json.(*decodeState).object 690
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;google.golang.org/protobuf/proto.MarshalOptions.marshal 285
runtime.goexit;google.golang.org/grpc.(*Server).handleStream;google.golang.org/grpc.(*Server).processUnaryRPC;google.golang.org/grpc.(*Server).sendResponse;internal/poll.(*FD).Write;syscall.write 240
runtime.gcBgMarkWorker;runtime.gcDrain;runtime.scanobject 1120
runtime.gcBgMarkWorker;runtime.gcDrain;runtime.markroot 260
runtime.mallocgc;runtime.(*mcache).nextFree 395
runtime.mcall;runtime.schedule;runtime.findRunnable 180