gpt4 book ai didi

go - runtime.memclrNoHeapPointers 有什么作用?

转载 作者:IT王子 更新时间:2023-10-29 02:35:40 32 4
gpt4 key购买 nike

我正在分析一个库,发现名为 runtime.memclrNoHeapPointers 的函数占用了大约 0.82 秒的 cpu 时间。

这个函数有什么作用,它告诉我关于我正在分析的库的内存使用情况的什么信息?

完整的输出:

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

最佳答案

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

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

这是垃圾收集器的一部分。 You can see the declaration here.

它所做的细节取决于 CPU。 See the various memclr_*.s files in the runtime for implmentation

这在 GC 中看起来确实需要很长时间,但我认为仅凭您显示的数据很难说出库的内存使用情况。

关于go - runtime.memclrNoHeapPointers 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54657446/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com