When you say "set up GC rate(10%) to reduce memory usage down to normal" what exactly did the program do? Compute (CPU) costs money and heap memory (DRAM) costs money. Minimizing the sum should be the goal. This requires one to have a model of the relative costs of CPU vs. RAM, HW folks balance these costs when they spec a machine so you could steal that model. Right now I'm on a 4 core (8 HW thread) machine with 16 GBytes of memory, so that's 2 GBytes per P. Cloud providers have price lists that can also be used to build a model. Once there is a model, set GODEBUG=gctrace=1 and adjust GOGC to find the balance that minimizes the sum of CPU and heap size based on your model.
Alternatively your manager may give out bonuses for improving benchmarks that only look at CPU times. This produces a model where memory is free as long as one doesn't OOM. I've used that model but it brought little job satisfaction. On Tuesday, June 4, 2019 at 8:55:39 AM UTC-4, Joseph Wang wrote: > > Hello everyone > > I just have a question about my golang code debugging. It's not specific > code question. But I never met this issue before. > > The problem is like this. I replaced our back-end system's cache from > single node cache to groupcache that is a kind mem cache. Then I met high > memory usage issue at beginning. I use pprof and online resource then I set > up GC rate(10%) to reduce memory usage down to normal. But then this will > cause high CPU usage, because heavy GC operations. I use pprof to get the > hot spot is runtime.ScanObject() this function, which is out of scope of my > code base. > > So I don't know if anyone can give me some suggestions about how to fix > this kind issue. I know the issue should come from my code base. But I > don't know how to find out the issue and fix it ASAP. > > Best, > > Joseph > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c0503366-90f2-431a-aef5-9659f9b679ac%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
