dongxie7683 2016-01-11 11:58
浏览 103

Golang 1.4.1中由GC导致的cpu核心是什么

I have recently come across a situation where one of our Golang app, consuming almost 30GB memory, will periodically eating all 24 cpu cores with nearly almost 100%. This will last maybe for more than 3 seconds. Our Golang version is 1.4.1 on linux 64-bit.

I have googled for some info. Here is my assumption:

  • in our app, we use a data type []map[string]*list and the instance of this type will contain more than 250K keys.
  • maybe the gc in golang 1.4.1 consuming more cpu time and stop the world. However, i can not find the parameter to configure the parallelism of gc goroutines(threads). And, does it have some relationship with the GOMAXPROCS parameter.
  • 写回答

1条回答 默认 最新

  • dongyou7292 2016-01-13 03:20
    关注

    You've really gotta profile to figure a problem like this out.

    That said you might be able to reduce the load you put on the garbage collector. Here are a couple of suggestions:

    1. Linked lists result in a lot of small allocations. Have you considered using a []map[string][]whatever_you_are_storing?
    2. Are you adding and removing things from this giant map? Are the things you're adding and removing all basically the same? If so you may be able to use a sync.Pool.
    3. Have you tried storing the item directly: map[string]list instead of map[string]*list. It will change the behavior of your program, but for a small struct it may make sense anyway.

    Those are shots in the dark.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100