douyao1856 2019-02-12 19:33
浏览 292
已采纳

runtime.memclrNoHeapPointers是做什么的?

I am profiling a library and see that a function called runtime.memclrNoHeapPointers is taking up about 0.82seconds of the cpu-time.

What does this function do, and what does this tell me about the memory-usage of the library i am profiling?

The output, for completeness:

File: gribtest.test
Type: cpu
Time: Feb 12, 2019 at 8:27pm (CET)
Duration: 5.21s, Total samples = 5.11s (98.15%)
Showing nodes accounting for 4.94s, 96.67% of 5.11s total
Dropped 61 nodes (cum <= 0.03s)
      flat  flat%   sum%        cum   cum%
     1.60s 31.31% 31.31%      1.81s 35.42%  github.com/nilsmagnus/grib/griblib.(*BitReader).readBit
     1.08s 21.14% 52.45%      2.89s 56.56%  github.com/nilsmagnus/grib/griblib.(*BitReader).readUint
     0.37s  7.24% 59.69%      0.82s 16.05%  encoding/binary.(*decoder).value
     0.35s  6.85% 66.54%      0.35s  6.85%  runtime.memclrNoHeapPointers
  • 写回答

1条回答 默认 最新

  • duan2477 2019-02-12 20:49
    关注

    func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)

    memclrNoHeapPointers clears n bytes starting at ptr.

    Usually you should use typedmemclr. memclrNoHeapPointers should be used only when the caller knows that *ptr contains no heap pointers because either:

    1. *ptr is initialized memory and its type is pointer-free.

    2. *ptr is uninitialized memory (e.g., memory that's being reused

    for a new allocation) and hence contains only "junk".

    in memclr_*.s go:noescape

    See https://github.com/golang/go/blob/9e277f7d554455e16ba3762541c53e9bfc1d8188/src/runtime/stubs.go#L78

    This is part of the garbage collector. You can see the declaration here.

    The specifics of what it does are CPU dependent. See the various memclr_*.s files in the runtime for implmentation

    This does seem like a long time in the GC, but it's hard to say something about the memory usage of the library with just the data you've shown I think.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题