Haskell/GHC 可以实时自我报告其 GC 统计信息吗?
Can a Haskell/GHC self-report its GC stats live?
我认为让服务器自行报告其内存使用情况会很方便。
我已经阅读了手册中关于 memory profiling 的部分,但是这有一些缺点:
- 首先这似乎只提供 post-mortem 统计数据。
- 启用分析会产生开销。
- 我真的不需要那么详细。
这就是我的问题,如何在 GHC 编译的 运行 程序中跟踪不同的内存集?
GHC 特定模块 GHC.Stats
提供了一个函数 getGCStats
,其中包含 returns(在 IO
中)各种 GC 统计信息:
getGCStats :: IO GCStats
Retrieves garbage collection and memory statistics as of the last
garbage collection. If you would like your statistics as recent as
possible, first run a performGC
.
如果您将 ekg 集成到您的服务器中,您可以通过 HTTP 访问有关运行时甚至您自己的自定义指标的精美图表和统计信息:
(图片链接自 Oliver Charles’ blogpost on ekg)
我认为让服务器自行报告其内存使用情况会很方便。
我已经阅读了手册中关于 memory profiling 的部分,但是这有一些缺点:
- 首先这似乎只提供 post-mortem 统计数据。
- 启用分析会产生开销。
- 我真的不需要那么详细。
这就是我的问题,如何在 GHC 编译的 运行 程序中跟踪不同的内存集?
GHC 特定模块 GHC.Stats
提供了一个函数 getGCStats
,其中包含 returns(在 IO
中)各种 GC 统计信息:
getGCStats :: IO GCStats
Retrieves garbage collection and memory statistics as of the last garbage collection. If you would like your statistics as recent as possible, first run a
performGC
.
如果您将 ekg 集成到您的服务器中,您可以通过 HTTP 访问有关运行时甚至您自己的自定义指标的精美图表和统计信息:
(图片链接自 Oliver Charles’ blogpost on ekg)