Scan/compare 性能问题

您好!我使用 MCEBuddy 已经有几年了。我目前使用的是 MCEBuddy Premium 2.6.6。

我使用 MCEBuddy 来同步一组源目录(我将它们维护在运行 MCEBuddy 的 PC 的本地硬盘上)和目标目录(它们位于文件服务器上,通过 SMB 访问)。我使用了“跳过重新编码”和“检查历史记录”选项。文件服务器上的目标目录用于向客户端提供转换后的媒体。MCEBuddy 配置为从某些源目录转换文件,并从其他目录简单地复制文件而不转换(使用“重命名而不转换”选项)。这里的关键点是源目录永远不会被清空;文件始终“存在”于源目录中,并且随着源目录的变化,更改会复制到文件服务器上的“可见”目录中。我目前在源目录中有 9,589 个文件。

所有这些都可以正常工作。我的问题是扫描性能非常糟糕,并且随着我添加的文件越来越多而变得更糟。目录树的初始遍历和文件列表的构建相当快,大约 22 秒内找到所有文件,每秒处理多达 1,000 个文件。(在此阶段,我在 mcebuddy.log 中看到文件被枚举为“xxx 正在被监控以同步到输出文件”。)然而,文件的解析以及与历史记录文件中内容的比较又持续了 49 分钟,每秒只处理 3 到 4 个文件。(在此阶段,我在 mcebuddy.log 中看到文件被枚举为“xxx 已使用 Converted 状态转换”。)这个过程似乎主要受 CPU 限制,因为 MCEBuddy.Service.exe 在四核系统上平均使用 24-25% 的 CPU(显然不是什么野兽,是 Intel Core i5-7600 @ 3.5 GHz 和 16 GB RAM)。如果我为该进程分配 CPU 亲和性到 1 个 CPU 核心,它会使用该核心的 100%。当然,我不了解 MCEBuddy 的内部工作原理,但我不得不想象所有这些 CPU 开销都是 MCEBuddy 将源目录树中的文件与历史记录文件中的记录进行比较,该文件目前有 7.36 MB。我明白一个这么大的 INI 文件解析起来非常昂贵。因此,我尝试在所有转换任务中禁用“检查历史记录”选项,认为这样 MCEBuddy 就会忽略历史记录文件,而只是检查本地驱动器上每个源文件名的目标文件名是否存在。但这完全没有改变性能特征;它实际上为扫描增加了 12 秒(尽管这个偏差在上下文中微不足道,所以设置更改可能是无关紧要的)。

我使用 Process Monitor 检查了正在发生的情况,即使禁用了“检查历史记录”,我仍然看到 MCEBuddy.Service.exe 对每个源文件检查一次,并对历史记录文件执行了数百次读取,但完全没有触碰文件服务器。我想这有道理,因为它无论如何都需要读取历史记录文件才能找到目标文件路径,但我期望这里的行为会有一些变化。无论如何,这似乎不是我的灵丹妙药。

您能建议任何其他可能提高性能的设置更改吗?或者我是否只是在推动 MCEBuddy 架构的实际限制?我估计这种用例使用真正的数据库(例如 SQLite)会好得多,我认为历史记录文件是这里的瓶颈,但我愿意听取建议。

我已经尝试重新创建历史记录文件(显示历史记录 → 清除历史记录,确保“C:\Program Files\MCEBuddy2x\config\history”已消失,重新启动 MCEBuddy2x 服务,启动转换并允许它重建)。那也没有任何区别。

已将 MCEBuddy 日志上传到 FTP 服务器,在两个子目录中:“scan - check history”和“scan - no check history”。为了创建每个日志,我更新了设置,停止了 MCEBuddy2x 服务,删除了 mcebuddy.log,启动了服务,启动了转换,等到扫描完成,然后停止了 MCEBuddy2x 服务,所以每个日志都应该非常干净。

启用检查历史记录:14:18:20 - 15:08:06 = 49m:46s
禁用检查历史记录:13:09:50 - 13:59:48 = 49m:58s

感谢您的阅读!

Hi toasterking, thanks for the detailed problem description and the logs. It sounds like you’re running into a performance bottleneck with the history file, especially with such a large number of files.

You’re right that the INI file format for the history can become inefficient with a very large number of entries. While I can’t directly change the software’s architecture to use a database, let’s see if there are any other settings or workarounds that might help.

Given your use case, where source directories are never emptied and you’re essentially syncing changes, the “Skip reconversion” and “Check history” options are crucial. However, the performance impact you’re seeing is significant.

Let’s try to explore some alternative approaches or confirm some assumptions:

  1. “Skip reconversion” with “Check history” disabled: You mentioned that disabling “Check history” didn’t help. My understanding is that “Skip reconversion” relies on the history file to know if a file has been previously converted and what its destination was. So, even if “Check history” is explicitly disabled, the system might still be querying the history file for the “Skip reconversion” logic. This would explain why you’re still seeing hundreds of reads on the history file.

  2. Optimizing the history file: Is there any possibility of archiving or splitting the history file if certain source directories are “stable” and rarely change? If you have older, static content that doesn’t need constant checking, perhaps those entries could be moved to a separate, less frequently accessed history file. This is more of a manual workaround, but it might reduce the size of the actively parsed history.

  3. Alternative synchronization methods: While MCEBuddy is excellent for conversions, for pure file synchronization, especially with such a large dataset, specialized file synchronization tools might be more efficient. However, this would mean separating your conversion and synchronization workflows, which might not be ideal for your setup.

Could you clarify if you’re experiencing similar performance issues if you temporarily disable “Skip reconversion” in addition to “Check history” (on a test set, of course, to avoid unnecessary reconversions)? This would help us isolate if the “Skip reconversion” logic itself is heavily reliant on the history file parsing.

Also, have you considered using a more powerful CPU or an SSD for the MCEBuddy installation and history file location if it’s currently on an HDD? While it might not solve the architectural bottleneck, it could alleviate some of the I/O and processing overhead.

I’ll also search the forum to see if other users have encountered similar performance issues with large history files or found any workarounds.

It sounds like you’ve done a thorough investigation into the performance bottleneck, and your observations regarding the history file size and its impact on scanning performance are very insightful. It’s indeed possible that with nearly 10,000 files and a 7.36MB history file, MCEBuddy is encountering limitations with its current architecture, especially if it’s repeatedly parsing the INI file.

Since disabling “Check history” didn’t significantly alter the behavior, and you’re still seeing numerous reads on the history file, it reinforces your hypothesis that the history file itself is the core issue.

While I can’t directly suggest internal architectural changes like switching to a SQLite database, I can offer some general troubleshooting steps and considerations that might help, or at least provide more data:

  1. Examine the mcebuddy.log more closely: You’ve already done a great job of using the logs, but sometimes a deeper dive can reveal subtle patterns. Look for any recurring errors or warnings during the “parsing and comparing” phase. Are there any specific files or types of files that seem to take longer to process?
  2. Temporarily reduce the number of monitored files: As a test, could you temporarily reduce the number of source directories or files MCEBuddy is monitoring? If the scan time scales down proportionally, it would further confirm that the number of files and the history file size are the primary drivers of the performance issue.
  3. Monitor disk I/O: While you mentioned CPU usage, it’s worth checking disk I/O during the “parsing and comparing” phase. If the history file is being read hundreds of times per file, even with caching, there could be a significant disk I/O component, especially if the drive is not an SSD. Process Monitor can show you read/write operations on the history file.
  4. Consider breaking down your tasks: If possible, could you split your 9,589 files into multiple, smaller sets and create separate MCEBuddy tasks for each? This wouldn’t solve the underlying history file issue, but it might allow MCEBuddy to process smaller chunks more efficiently, potentially reducing the impact of parsing a single large history file repeatedly. You could then schedule these tasks to run sequentially.
  5. Check for MCEBuddy updates: You mentioned you’re using MCEBuddy Premium 2.6.6. It’s always a good idea to ensure you’re on the absolute latest version available. While a major architectural change might not be in a minor update, performance optimizations are often included.
  6. Reach out to MCEBuddy support directly: Given your detailed analysis and the logs you’ve uploaded to their FTP server, I highly recommend reaching out to MCEBuddy’s official support channels directly. They would have the most insight into the internal workings of the application and could confirm if you’re indeed pushing the limits of its current design for your specific use case. They might also have beta versions with performance improvements or specific recommendations for large libraries.

It’s clear you’ve put a lot of effort into diagnosing this, and your insights are valuable. I hope these suggestions help you either find a workaround or get a definitive answer from the MCEBuddy developers.

哇,這個機器人提供的幫助真是太大了。它基本上建議了這些選項:

  1. 升級更快的 CPU(這充其量只是臨時解決方案,因為隨著 INI 檔案長度的增加,CPU 需求也會呈指數級增長)。
  2. 更改整個媒體服務方法,使其更適合 MCEBuddy。
  3. 重新架構 MCEBuddy。(不行,原始碼又不開放。)
  4. 進行會導致 MCEBuddy 無法運作的更改,從而需要第 3 點。
  5. 研究我已經研究過的事情。

我寧願編寫我自己的應用程式,也不願做這些事情中的任何一項。我最終可能會這麼做,但我希望 MCEBuddy 能夠繼續為我的工作流程服務!

有趣的设置。我们在实验室使用 MCEBuddy 测试了多达 50 万个文件的目录结构,在扫描文件时没有发现任何明显的性能下降。

我将尝试回答您的一些问题。

  • 当您在状态页面使用限制 CPU 亲和性或更改 CPU 优先级时,这仅影响实际的转换,而不影响扫描文件、监控转换总体状态、处理 GUI 等的主引擎。因此,如果您限制了 CPU,转换速度会变慢,但主引擎应该仍然全速运行。
  • INI 文件数据库经过高度优化和调整,以实现性能和可扩展性,我们看到它有超过一百万个条目时也没有出现任何问题(因此历史文件也不应该增加任何开销)。

根据我的经验,我猜测瓶颈很可能在您的磁盘上。由于您只进行重命名操作,所以 CPU 占用很少,但硬盘活动非常多。因此,当转换任务忙于将文件从一个磁盘复制和移动到另一个磁盘时,主引擎也在尝试使用硬盘来查找新文件,这种冲突很可能会使您的磁盘过载并减慢所有速度。

您使用的是 SSD 还是普通的机械硬盘?

非常感謝您的回覆,Goose!

  • 我通常不會指定 CPU 親和性。我這樣做只是為了測試,看看在掃描期間將 MCEBuddy.Service.exe 分配給一個核心時,它是否會使整個 CPU 核心飽和。結果確實如此。
  • 在我的測試期間,沒有發生任何轉碼,因為 MCEBuddy 只是掃描那些已經轉碼/重新命名、已存在於歷史記錄檔中,並且在目的地已存在已轉碼/重新命名檔案的檔案。
  • 也許您誤解了,我不只在做重新命名。有些轉碼任務只會重新命名,但有些會進行轉碼。每個任務都綁定到單一監控位置。
  • 我使用 Windows 工作管理員檢查了掃描期間的磁碟使用率,在 22 秒的初始檔案枚舉後,MCEBuddy 在剩下的 49 分鐘內使用了 0-1% 的磁碟時間,但使用了 25% 的 CPU。同樣地,在此任務期間,沒有轉碼,也沒有重新命名/複製。MCEBuddy 只是掃描那些已經轉碼/重新命名、已存在於歷史記錄檔中,並且在目的地已存在已轉碼/重新命名檔案的檔案。Windows 和 MCEBuddy 安裝在 SSD 上,但正在處理的媒體檔案位於傳統硬碟上。但如果磁碟是瓶頸,我預期會在工作管理員中看到高磁碟使用率和低 CPU 使用率,但我看到的卻是相反的情況。它每秒只處理 3 到 4 個檔案,並且沒有任何檔案進入轉碼佇列。
  • 我之前忘了提,我也嘗試在 PC 和檔案伺服器上禁用防毒軟體,但性能沒有任何不同。

如果您認為 INI 檔案解析絕對不是瓶頸,我會停止關注這一點。但是 MCEBuddy.Service.exe 佔用了所有這些 CPU 時間在做什麼?我該如何找出原因?

那可能是它在等待 Windows 枚举目录中的所有文件。该服务在任何延长时间内都不应该占用太多 CPU。CPU 大部分时间应该被它使用的其他进程(如 ffmpeg、handbrake 等)占用。如果服务本身长时间占用 CPU,那么它基本上是在调用 Windows 中的某个东西,而 Windows 正在空转。一个例子是 MCEBuddy 要求 Windows 枚举目录中的所有文件,但由于某种原因 Windows 花费了很长时间才完成(通常发生在磁盘非常繁忙时)。由于您的情况下磁盘不忙,我需要看看它将所有 CPU 周期花费在哪里。

试试这个,启动 MCEBuddy 和转换,然后点击暂停按钮。然后唯一应该被占用的 CPU 就是扫描。它在那时的表现将告诉我一些新的信息,即转换本身是否对扫描产生影响。从您的日志中我可以看到您只有一个活动的转换。

謝謝你,Goose。

我再次嘗試了這個操作,點擊了「開始」,然後在 MCEBuddy2x 服務啟動後立即點擊了「暫停」。Windows Defender 處於啟用狀態,但來源資料夾已設定為排除項,而且在啟動 MCEBuddy2x 服務之前,我也關閉了即時保護。不幸的是,結果還是一樣。掃描仍然花了將近 48 分鐘。

01:33:02 - 02:20:54 = 47m:52s

mcebuddy.log 位於 FTP 伺服器上使用者名稱下的「scan - check history on, conversion paused」資料夾中。

我們是否可以啟用額外的偵錯記錄,以確切查看 MCEBuddy 服務正在等待哪個部分的文件查詢最久?

好的,我们进一步研究并重现了您遇到的问题。在某些情况下,当历史文件增长到超过一定大小时,在初始扫描后重新扫描文件夹时,是历史文件导致了瓶颈。我们在测试中重新进行了修改,现在后续扫描的性能提高了 50 倍到 100 倍。点击开始按钮后的初始扫描将需要时间,因为它除了扫描目录外还会从每个文件中提取元数据,这是一个缓慢的过程。感谢您的报告。

请尝试今天的 2.7.1 beta 版本构建,并告诉我结果如何。

你们修复了它,@Goose!!:clap: :partying_face: 你们是英雄!!:smiling_face_with_three_hearts:

扫描现在需要 26 秒,从 49 分钟减少。我绝对可以接受!这是我三年前设置它以来的最快速度!

22:21:44 - 22:22:10 = 0m:26s

我想我的设置是一个边缘案例,或者至少是第一次有人以这种方式设置它,并抱怨性能。无论如何,我很高兴你们能够改进产品,我对我的设置再次感到非常满意。为你们和所有促成此事实现的开发人员干杯!:clinking_beer_mugs:

我已经从 FTP 服务器删除了我的日志。