什么是 LLVM?用 LLVM 替换 Python VM 如何将速度提高 5 倍?

发布于 2024-07-15 22:22:51 字数 332 浏览 7 评论 0原文

Google 正在赞助一个开源项目,旨在将 Python 的速度提高 5 倍。

Unladen-Swallow 似乎有一个好的项目计划

为什么并发是一个如此困难的问题?
LLVM 会解决并发问题吗?
除了多核之外还有其他解决方案可以促进硬件进步吗?

Google is sponsoring an Open Source project to increase the speed of Python by 5x.

Unladen-Swallow seems to have a good project plan

Why is concurrency such a hard problem?
Is LLVM going to solve the concurrency problem?
Are there solutions other than Multi-core for Hardware advancement?

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

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

发布评论

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

评论(3

德意的啸 2024-07-22 22:22:51

LLVM 是几个东西的结合体 - 一种虚拟机/优化编译器,与接受特定输入的不同前端相结合语言并以中间语言输出结果。 此中间输出可以与虚拟机一起运行,也可以用于生成独立的可执行文件。

并发的问题在于,尽管它在科学计算中使用了很长时间,但最近才在消费应用程序中变得普遍。 因此,虽然众所周知如何编写一个科学计算程序以实现出色的性能,但编写一个擅长并发的邮件用户代理/文字处理器却是完全不同的事情。 此外,当前大多数操作系统在设计时都考虑到了单处理器,它们可能没有为多核处理器做好充分准备。

LLVM 在并发性方面的好处是您拥有中间输出,如果将来并发性有进步,那么通过更新您的解释器,您可以立即在所有 LLVM 编译的程序中获得这些好处。 如果您已编译为独立的可执行文件,这就不那么容易了。 因此,LLVM 本身并没有解决并发问题,但它为未来的增强敞开了大门。

当然,量子计算机、遗传学计算机等硬件还有更多可能的进步。但我们必须等待它们成为现实。

LLVM is several things together - kind of a virtual machine/optimizing compiler, combined with different frontends that take the input in a particular language and output the result in an intermediate language. This intermediate output can be run with the virtual machine, or can be used to generate a standalone executable.

The problem with concurrency is that, although it was used for a long time in scientific computing, it has just recently has become common in consumer apps. So while it's widely known how to program a scientific calculation program to achieve great performance, it is completely different thing to write a mail user agent/word processor that can be good at concurrency. Also, most of the current OS's were being designed with a single processor in mind, and they may not be fully prepared for multicore processors.

The benefit of LLVM with respect to concurrency is that you have an intermediate output, and if in the future there are advances in concurrency, then by updating your interpreter you instantly gain those benefits in all LLVM-compiled programs. This is not so easy if you had compiled to a standalone executable. So LLVM doesn't solve the concurrency problem per se but it leaves an open door for future enhancements.

Sure there are more possible advances for the hardware like quantum computers, genetics computers, etc. But we have to wait for them to become a reality.

初雪 2024-07-22 22:22:51

切换到 LLVM 本身并不能解决并发问题。 通过摆脱 全局解释器锁

我不确定我对此有何感受; 我使用线程主要是为了处理阻塞 I/O,而不是为了利用多核处理器(为此,我将使用 multiprocessing 模块来生成单独的进程)。

所以我有点喜欢GIL; 它使我的生活变得更加轻松,而不必考虑棘手的同步问题。

The switch to LLVM itself isn't solving the concurrency problem. That's being solved separately, by getting rid of the Global Interpreter Lock.

I'm not sure how I feel about that; I use threads mainly to deal with blocking I/O, not to take advantage of multicore processors (for that, I would use the multiprocessing module to spawn separate processes).

So I kind of like the GIL; it makes my life a lot easier not having to think about tricky synchronization issues.

一个人的旅程 2024-07-22 22:22:51

LLVM 负责代码生成的细节,因此它允许他们以更通用、可移植、可维护的方式重写 Psyco。 这反过来又允许他们重写 CPython 核心,从而让他们能够尝试替代 GC 和其他需要改进 Python 对并发支持的东西。

换句话说,LLVM并没有解决并发问题,它只是解放了你的双手,让你可以解决它。

LLVM takes care of the nitty-gritty of code generation, so it lets them rewrite Psyco in a way that's more general, portable, maintainable. That in turn allows them to rewrite the CPython core, which lets them experiment with alternate GCs and other things needed to improve python's support for concurrency.

In other words, LLVM doesn't solve the concurrency problem, it just frees up your hands so YOU can solve it.

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