Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ffmpeg] Slow build process with low CPU utilization #42281

Closed
greed-106 opened this issue Nov 21, 2024 · 2 comments
Closed

[ffmpeg] Slow build process with low CPU utilization #42281

greed-106 opened this issue Nov 21, 2024 · 2 comments
Assignees
Labels
category:question This issue is a question

Comments

@greed-106
Copy link

Describe the bug
When installing ffmpeg with vcpkg, the build process is extremely slow, taking up to 1.6 hours to complete. Additionally, CPU utilization remains very low during the build (consistently below 30%).

Environment

  • OS: Windows 11 Professional 23H2
  • vcpkg version: 2024-11-12-eb492805e92a2c14a230f5c3deb3e89f6771c321
  • Toolchain: Visual Studio 2022, MSVC 14.42.34433
  • Triplet: x64-windows
  • Hardware: Intel i9-12900K, 32GB RAM

Reproduction Steps

  1. Install ffmpeg using the command:

    .\vcpkg.exe install ffmpeg
  2. Observe that the build process is extremely slow, taking over an hour to complete, and CPU utilization remains consistently below 30%.

Expected Behavior The build should leverage more CPU cores and complete significantly faster, especially on high-performance hardware.

Additional Context

  • I've already tried restarting my computer and reinstalling vcpkg, but the issue persists.
  • No other CPU-intensive programs were running during the build.
  • Proxy is configured: 127.0.0.1:7890
  • The problem seems related to inefficient use of system resources during the build.

Logs Below is the complete log from the build process:

PS D:\ymj\code\cpp\vcpkg> .\vcpkg.exe install ffmpeg
Computing installation plan...
The following packages will be built and installed:
    ffmpeg[avcodec,avdevice,avfilter,avformat,core,swresample,swscale]:[email protected]#1
Detecting compiler hash for triplet x64-windows...
-- Automatically setting %HTTP(S)_PROXY% environment variables to "127.0.0.1:7890".
Compiler found: D:/VisualStudio/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\ymj\AppData\Local\vcpkg\archives in 174 us. Use --debug to see more details.
Installing 1/1 ffmpeg[avcodec,avdevice,avfilter,avformat,core,swresample,swscale]:[email protected]#1...
Building ffmpeg[avcodec,avdevice,avfilter,avformat,core,swresample,swscale]:[email protected]#1...
-- Using cached ffmpeg-ffmpeg-n7.1.tar.gz.
-- Cleaning sources at D:/ymj/code/cpp/vcpkg/buildtrees/ffmpeg/src/n7.1-d40f62baf3.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source D:/ymj/code/cpp/vcpkg/downloads/ffmpeg-ffmpeg-n7.1.tar.gz
-- Applying patch 0001-create-lib-libraries.patch
-- Applying patch 0002-fix-msvc-link.patch
-- Applying patch 0003-fix-windowsinclude.patch
-- Applying patch 0004-dependencies.patch
-- Applying patch 0005-fix-nasm.patch
-- Applying patch 0007-fix-lib-naming.patch
-- Applying patch 0013-define-WINVER.patch
-- Applying patch 0020-fix-aarch64-libswscale.patch
-- Applying patch 0024-fix-osx-host-c11.patch
-- Applying patch 0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch
-- Applying patch 0041-add-const-for-opengl-definition.patch
-- Applying patch 0043-fix-miss-head.patch
-- Using source at D:/ymj/code/cpp/vcpkg/buildtrees/ffmpeg/src/n7.1-d40f62baf3.clean
-- Found external ninja('1.12.1').
-- Getting CMake variables for x64-windows
-- Using cached msys2-automake-wrapper-20240607-1-any.pkg.tar.zst.
...
-- Fixing pkgconfig file: D:/ymj/code/cpp/vcpkg/packages/ffmpeg_x64-windows/debug/lib/pkgconfig/libswscale.pc
-- Dependencies (release):
-- Dependencies (debug):
-- Installing: D:/ymj/code/cpp/vcpkg/packages/ffmpeg_x64-windows/share/ffmpeg/usage
-- Installing: D:/ymj/code/cpp/vcpkg/packages/ffmpeg_x64-windows/share/ffmpeg/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 3.5 s.
Elapsed time to handle ffmpeg:x64-windows: 1.6 h
ffmpeg:x64-windows package ABI: 5bae88431e5dfc894accc3cd6c3f2e25b029f99a02c116498c89acd3985bfe7c
Total install time: 1.6 h
To use ffmpeg add the following to your CMake project:

    find_package(FFMPEG REQUIRED)
    target_include_directories(main PRIVATE ${FFMPEG_INCLUDE_DIRS})
    target_link_directories(main PRIVATE ${FFMPEG_LIBRARY_DIRS})
    target_link_libraries(main PRIVATE ${FFMPEG_LIBRARIES})

PS D:\ymj\code\cpp\vcpkg>

Suggestions

  1. Could the low CPU utilization be due to inefficient parallelization during the build process?
  2. Is there a way to manually increase the parallelization level or optimize the build process?

Thank you for your assistance!

@dg0yt
Copy link
Contributor

dg0yt commented Nov 21, 2024

  1. The build uses parallel jobs via make -j${JOBS}. The actual value is found in the build.sh script which is generated at build time.
    (However, this port doesn't use the regular vcpkg_build_make).

  2. There should not be much need for tuning. Check the logs if something goes wrong. Check the environment to not limit VCPKG_MAX_CONCURRENCY. Check that antivirus operations don't cause interference.

FTR vcpkg CI has:

Installing 324/2396 ffmpeg[aom,ass,avcodec,avdevice,avfilter,avformat,avisynthplus,avresample,bzip2,core,dav1d,drawtext,dvdvideo,fdk-aac,ffmpeg,fontconfig,freetype,fribidi,gpl,iconv,ilbc,lzma,modplug,mp3lame,nonfree,nvcodec,opencl,opengl,openh264,openjpeg,openmpt,openssl,opus,postproc,qsv,sdl2,snappy,soxr,speex,srt,ssh,swresample,swscale,tesseract,theora,version3,vorbis,vpx,webp,x264,x265,xml2,zlib]:[email protected]#1...
....
Elapsed time to handle ffmpeg:x64-windows: 23 min

@Mengna-Li Mengna-Li added the category:question This issue is a question label Nov 22, 2024
@greed-106
Copy link
Author

Thank you all for your help and suggestions! The issue has been resolved.

I was able to restore the normal build speed by using the dControl software to disable the Antimalware Service Executable process on my system. I hope this solution can help others facing similar issues.

Thanks again for the support from the community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

3 participants