因预编译资源导致的内存过度消耗

你好 @david

在 assets:build 任务完成后,内存使用量会立即下降吗?

不会。我进一步排查后发现有些奇怪的地方。

在执行 precompiling:build 之前,插件列表如下:

/var/www/discourse$ ls plugins/
automation           discourse-akismet           discourse-data-explorer  discourse-hcaptcha           discourse-microsoft-auth  discourse-post-voting  discourse-saved-searches       discourse-user-notes           styleguide
chat                 discourse-apple-auth        discourse-details        discourse-lazy-videos        discourse-narrative-bot   discourse-presence     discourse-solved               discourse-zendesk-plugin
checklist            discourse-assign            discourse-docs           discourse-local-dates        discourse-oauth2-basic    discourse-prometheus   discourse-subscriptions        footnote
discourse-adplugin   discourse-cakeday           discourse-gamification   discourse-login-with-amazon  discourse-openid-connect  discourse-reactions    discourse-templates            msgraph-poll-discourse-plugin
discourse-affiliate  discourse-calendar          discourse-github         discourse-lti                discourse-patreon         discourse-rewind       discourse-topic-trade-buttons  poll
discourse-ai         discourse-chat-integration  discourse-graphviz       discourse-math               discourse-policy          discourse-rss-polling  discourse-topic-voting         spoiler-alert

通过调试代码,我注意到了以下行为:

/var/www/discourse$ script/rails runner "AssetProcessor.ember_version"
插件名称为 'msgraph-polling',但插件目录名为 'msgraph-poll-discourse-plugin'

# 在此处无限挂起

AssetProcessor.ember_version 对应于 discourse/lib/plugin/js_manager.rb at latest · discourse/discourse · GitHub 这一行。

因此,我对该文件进行了一些修改(已附上),主要是为了打印在处理过程中卡住的位置,并移除 discourse/lib/plugin/js_manager.rb at latest · discourse/discourse · GitHub 中的 AssetProcessor.ember_version,直接设置为 5 以继续生成十六进制值。

随后,我将并行度降低为 1 以简化操作,修改位置在 discourse/lib/plugin/js_manager.rb at latest · discourse/discourse · GitHub = [Etc.nprocessors, 1].min`)。

之后,我执行了 bundle exec rake assets:precompile:build,结果如下:

/var/www/discourse$ bundle exec rake assets:precompile:build
插件名称为 'msgraph-polling',但插件目录名为 'msgraph-poll-discourse-plugin'
[assemble_ember_build] 正在复用现有的核心 Ember 构建。全部完成。
插件名称为 'msgraph-polling',但插件目录名为 'msgraph-poll-discourse-plugin'
[Plugin::JsManager] 正在编译 49 个插件...
正在编译 automation...
文件排序结束
文件排序结束
        hex_digest 103dc9ebebb80a7065cb8dd41fb3356b30f151f7
########### 递归

# 在此处无限挂起,占用全部内存

我怀疑这可能与 ulimit 值有关(我们将其设置为 unlimited 而不是类似 ulimit -n 1048576; 的值),因为您打开了大量文件并将其内容存储在内存中(通过递归调用)。

请告诉我这是否让您想起了什么,或者您是否有关于问题原因的其他线索。

祝好,

Ismael

js_manager.rb.txt|附件 (7.7 KB)