如何更改 Erlang makefile 以启用 SMP 模式?
Posted
技术标签:
【中文标题】如何更改 Erlang makefile 以启用 SMP 模式?【英文标题】:How can I change the Erlang makefile so that it enables the SMP mode? 【发布时间】:2018-09-23 01:43:26 【问题描述】:我想开发一个需要 SMP 的应用程序。但在我使用的 Erlang makefile 中,选项设置为非 smp 模式。因此,当我启动应用程序时,我在 Shell 中收到一个错误,指示需要 SMP 仿真器并且我应该从 erl -smp 开始。 PS:erl -smp 命令在命令提示符下工作,即当我不使用 makefile 时。
【问题讨论】:
有成千上万种不同的方式来编写 Makefile。不可能回答以这种方式提出的问题。嗯,你需要找到erl
在Makefile中的某个地方执行,并添加-smp
【参考方案1】:
请注意,smp 版本通常是默认的(除非您在单核机器上运行,在这种情况下您可能需要强制使用它),并且非 smp 版本实际上将从从下一个主要版本 (OTP 21) 开始的代码库 - 您仍然可以在单核机器上运行,但代码不会专门用于单核情况。 (这大大简化了模拟器代码,删除了一大堆#ifdefs。)
【讨论】:
【参考方案2】:不知道 makefile 的确切解决方案,但这可能会有所帮助
# Makefile
.PHONY: all compile run
REBAR=./rebar3
all: compile
compile:
$(REBAR) compile
run: compile
erl -pa _build/default/lib/*/ebin -config config/sys.config -args_file config/vm.args -boot start_sasl -s sync -s yourawesomeapp
就我而言,我总是使用vm.args
文件和rebar3
这里是代码示例
## Name of the node
-name node@10.00.0.00
## Cookie for distributed erlang
-setcookie test_cookie
## Enable kernel poll and a few async threads
+K true
+A 2
## Force the erlang VM to use SMP
-smp enable
## Increase number of concurrent ports/sockets
-env ERL_MAX_PORTS 65535
【讨论】:
以上是关于如何更改 Erlang makefile 以启用 SMP 模式?的主要内容,如果未能解决你的问题,请参考以下文章