Skip to content

perf: enable hardware concurrency detection for better performance#209

Open
sangjiexun wants to merge 2 commits intoStreamedian:masterfrom
sangjiexun:fix-cpu-cores
Open

perf: enable hardware concurrency detection for better performance#209
sangjiexun wants to merge 2 commits intoStreamedian:masterfrom
sangjiexun:fix-cpu-cores

Conversation

@sangjiexun
Copy link
Copy Markdown

修复内容

修复了 CPU_CORES 硬编码为 1 的性能问题。

问题描述

CPU_CORES 之前被硬编码为 1,导致无法利用多核 CPU 进行并行处理。

修改内容

src/core/util/browser.js

  • 启用 navigator.hardwareConcurrency 检测
  • 回退值设为 4(对于不支持该 API 的浏览器)

性能影响

  • 启用多核 CPU 利用
  • 提升并行处理能力
  • 改善高分辨率视频流的解码性能

Developer added 2 commits March 19, 2026 09:19
…eanup

- player.js: Store bound handlers and remove all event listeners in destroy()
- base_client.js: Call stopStreamFlush() in destroy() to clear timers
- mse.js: Remove sourceopen/sourceended/sourceclose listeners in destroy()
- MSEBuffer: Add null check for sourceBuffer before removal
- CPU_CORES now uses navigator.hardwareConcurrency with fallback to 4
- This enables multi-core CPU utilization for parallel processing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant