多核 llvm 的垃圾收集器?

发布于 2024-08-21 20:59:36 字数 393 浏览 8 评论 0原文

我已经将 LLVM 作为我当前正在实现的语言的新后端来研究很长一段时间了。它似乎具有良好的性能,相当高级的生成API,足够的低级支持来优化奇异的优化。另外,虽然我自己没有检查过,但Apple似乎已经成功演示了LLVM对于垃圾收集多核程序的使用。

到目前为止,一切都很好。由于我对垃圾收集和多核都感兴趣,下一步是选择 LLVM 多核垃圾收集器。这让我想到一个问题:有什么可用的?我知道 Jon Harrop 的 HLVM 工作,但仅此而已。

请注意,我需要跨平台,因此 Apple 的 GC 可能不是我正在寻找的(除非有跨平台版本)。另请注意,我并不反对停止世界垃圾收集器。

提前致谢, 约里克

I've been looking at LLVM for quite some time as a new back-end for the language I'm currently implementing. It seems to have good performance, rather high-level generation APIs, enough low-level support to optimize exotic optimizations. In addition, and although I haven't checked it myself, Apple seems to have successfully demonstrated the use of LLVM for garbage-collected multi-core programs.

So far, so good. As I'm interested in both garbage-collection and multi-core, the next step would be to choose a LLVM multi-core-able garbage-collector. Which brings me to the question: what is available? I'm aware of Jon Harrop's HLVM work, but that's about it.

Note that I need cross-platform, so Apple's GC is probably not what I'm looking for (unless there's a cross-platform version). Also note that I have nothing against stop-the-world garbage-collectors.

Thanks in advance,
Yoric

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水晶透心 2024-08-28 20:59:36

LLVM 文档说它不支持多线程收集器 还< /em>.

如矩阵所示,LLVM
垃圾收集基础设施是
已经适合各种各样的
收藏家,但目前还没有
扩展到多线程程序。这
将来会添加
就是兴趣。

文档确实说要进行多线程垃圾收集,您需要停止世界,这是一个不可移植的东西:

螺纹
表示多线程变异器;收集器仍然必须停止
mutator(“停止世界”)之前
开始可达性分析。
停止多线程变异器是
复杂的问题。它一般
需要高度特定于平台的代码
在运行时,以及生产
精心设计的机器代码
安全点。

然而,线程之间的共享状态是一个令人讨厌的扩展问题。如果您的语言仅通过“任务”之间传递消息进行通信,因此工作线程之间没有共享状态,那么您可以对每个线程堆使用每个线程收集器吗?

LLVM docs say that it does not support multi-threaded collectors yet.

As the matrix indicates, LLVM's
garbage collection infrastructure is
already suitable for a wide variety of
collectors, but does not currently
extend to multithreaded programs. This
will be added in the future as there
is interest.

The docs do say that to do multi-threaded garbage collection you need to stop the world and that this is a non-portable thing:

Threaded
Denotes a multithreaded mutator; the collector must still stop the
mutator ("stop the world") before
beginning reachability analysis.
Stopping a multithreaded mutator is a
complicated problem. It generally
requires highly platform specific code
in the runtime, and the production of
carefully designed machine code at
safe points.

However, shared state between threads is a nasty scaling issue. If your language communicates solely through message passing between 'tasks', and therefore there was no shared state between worker threads, then you could use a per-thread collector for the per-thread heap?

你的背包 2024-08-28 20:59:36

Will 引用的内容是关于 LLVM 对 GC 的内在支持,您可以使用 C++ 代码来增强 LLVM,告诉它如何遍历堆栈、解释堆栈帧、注入读写屏障等等。我的 HLVM 项目的主要目标是以最小的努力和风险变得有用,所以我选择将影子堆栈用于“不合作环境”,以避免对 LLVM 不成熟的内部结构进行黑客攻击。因此,有关 LLVM 对 GC 的内在支持的那些声明不适用于 HLVM 的垃圾收集器,因为它根本不使用该基础设施。我的结果非常引人注目:您可以用最少的努力实现出色的性能 (串行性能并行性能 )。

我相信 HLVM 已经可以在包括 Mac OS X 在内的 Unix 上开箱即用地运行,因为它仅需要 POSIX 线程。我强烈不同意编写 stop-the-world GC 很困难的说法:我花了 5 天时间编写了一个 100 行多核垃圾收集器,而且我对计算机几乎一无所知。我不敢相信移植到 Windows 也会很困难。

The quotes that Will gave are about LLVM's intrinsic support for GC, where you augment LLVM with C++ code telling it how to walk the stack, interpret stack frames, inject read and write barriers and so on. The primary goal of my HLVM project is to become useful with minimal effort and risk so I chose to use the shadow stack for an "uncooperative environment" in order to avoid hacking on immature internals of LLVM. Consequently, those statements about LLVM's intrinsic support for GC do not apply to HLVM's garbage collector because it does not use that infrastructure at all. My results are extremely compelling: you can achieve excellent performance with minimal effort (serial performance and parallel performance).

I believe HLVM already runs out-of-the-box across Unixs including Mac OS X because it requires only POSIX threads. I strongly disagree with the claim that writing a stop-the-world GC is difficult: it took me 5 days to write a 100-line multicore garbage collector and I barely know anything about computers. I cannot believe it would be difficult to port to Windows either.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文