高负载服务器的脚本编程策略

发布于 2024-10-20 21:52:39 字数 177 浏览 1 评论 0原文

我有一个用 C++ 编写的 MMORPG 服务器,我以前从未编写过脚本,从我的角度来看,我认为如果我在运行时解析脚本,服务器的整体性能将会下降(虽然我没有测试过),但我想要有这样的功能。

您建议/使用哪些适合多线程环境的优秀脚本技术?一本书或一篇文章也很好,最好与 C++ 相关,但我不介意其他语言。

谢谢。

I have a MMORPG server in C++, I've never done scripting before and from my point of view I think it would be degrading to the overall performance of the server if I parse scripts on the go (I haven't tested though), but I would like to have such functionality.

What good scripting techniques for multi-threaded environments that you would suggest/use? A book or an article would be nice too, preferably related to C++ but I don't mind other languages.

Thanks.

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

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

发布评论

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

评论(2

梦里寻她 2024-10-27 21:52:39

我相信大多数常用的脚本语言将解析作为执行的单独步骤来执行,因此这不会造成显着的性能成本。通常它们会编译为某种字节码格式(例如 Python、Lua 和 Perl 都这样做),并且通常该格式可以序列化并直接从磁盘加载。

有一些脚本语言的实现可以编译为本机代码。例如,您可以尝试 javascript 和 Google 的 v8 引擎,(据我所知aware)在执行之前将所有内容编译为本机代码。

v8 当然是在 Chrome 中使用的,它是一个多进程环境,所以我想它在多线程环境中会完美地工作(尽管我不能声称个人经验)。

还有一些通常编译为字节码的语言的 JIT 编译器(例如,用于 python 的 PsycoLuaJit 用于 Lua)。不过,这些通常与主要语言发行版的最新版本不同步。

I believe the majority of commonly used scripting languages perform parsing as a separate step to execution, so that wouldn't be a significant performance cost. Usually they compile to some kind of bytecode format (Python, Lua and Perl all do this for example), and often that format can be serialised and loaded directly from disk.

There are implementations of scripting languages that compile to native code. For example, you could try javascript and Google's v8 engine, which (as far as I'm aware) compiles everything to native code before execution.

v8 is of course used in Chrome, which is a multi-process environment, so I would imagine it would work perfectly well in a multi-threaded environment (I can't claim personal experience of that though).

There are also JIT compilers for languages that are typically compiled to bytecode (for example, Psyco for python, and LuaJit for Lua). These are often not in sync with the latest version of the main language distribution though.

月依秋水 2024-10-27 21:52:39

我想你想看看 Node.js

它是一个构建在 Google V8 引擎之上的高性能多线程引擎。它的速度非常快,并且是为了扩展到巨大的水平而设计的。

I think you want to check out Node.js.

It is a high performance multi threaded engine built on top of Google's V8 engine. It's extremely fast and built to be for scaling to huge levels.

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