Lua Lanes 和多核支持:可以做到吗?
Lua Lanes 表示它通过多线程实现多核支持。这不是不正确吗?难道不需要使用多个进程来利用多核的优势吗? Lua Lanes 这样做吗?
也许我误解了他们的意思。这是他们网站上的一段话:
Lua Lanes 是一个 Lua 扩展库,提供并行运行多个 Lua 状态的可能性。它旨在用于优化多核 CPU 的性能,并研究使 Lua 程序自然并行的方法。
谢谢
Lua Lanes says that it enables multi-core support through multithreading. Isn't this incorrect? Don't you need to use multiple processes to take advantage of multiple cores? Does Lua Lanes do this?
Perhaps I'm misinterpreting what they're saying. Here's the passage from their site:
Lua Lanes is a Lua extension library providing the possibility to run multiple Lua states in parallel. It is intended to be used for optimizing performance on multicore CPU's and to study ways to make Lua programs naturally parallel to begin with.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于操作系统,但大多数当前操作系统(Windows、Linux/*nix 等)通过线程而不是进程将任务分配到内核/CPU 上。因此具有多个线程的单个进程可以在多个核心上运行。
Lanes 使用真正的操作系统线程,而不是轻量级 Lua 线程(协程),因此调度程序实际上可以将其分配到多个内核上。
It depends on the operating system, but most current operating systems (Windows, Linux/*nix, ...) distribute tasks onto cores/CPUs by threads, not by processes. So a single process with multiple threads can be run on multiple cores.
Lanes uses real OS threads, not the lightweight Lua threads - coroutines, so the scheduler can actually distribute it onto multiple cores.
据我所知,他们在一个多线程操作系统进程中运行多台 Lua 机器。他们使用Lindas进行Lua共享数据和IPC,但这不涉及OS级IPC和其他多进程开销。
请注意,我是在浏览了您的链接后得出此结论,而不是在尝试运行车道等之后得出的结论。我可能完全错了。
As far as I can tell, they run multiple Lua machines inside one multi-threaded OS process. They use Lindas for Lua shared data and IPC, but this does not involve OS-level IPC and other multi-process overhead.
Note that I conclude this after skimming your link, not after trying to run lanes, etc. I may be dead wrong.