libtorrent icon indicating copy to clipboard operation
libtorrent copied to clipboard

Debug build is too slow

Open alervd opened this issue 5 months ago • 1 comments

In my app, I have 48 seeding downloads.

In Release build, Libtorrent processes all requests to it (e.g. add/pause/remove torrent) quite fast. So my app shuts down immediately with Libtorrent 2.0.11 and in a few seconds with Libtorrent 1.2.20.

In Debug build, contrariwise, it works a way too slower. It takes 3.5 minutes (!) for my app to shut down (a few seconds after I start it) with Libtorrent 1.2.20 and 7 minutes (2 times slower) with Libtorrent 2.0.11. It's constantly using 100% CPU core in its session's thread during this time.

The only explanation I can think of is that this can be caused by invariant checks in debug builds. But I have them disabled (I hope so).

This is a piece of my build script. Is there any mistake in it?

set BOOSTBUILD=%~dp0\..\..\boost-build2\%OUTPUTDIR%\bin\b2.exe

set BUILD_OPTIONS=-q cxxstd=20 cxxflags="\"/Zc:__cplusplus\"" --without-python --toolset=msvc-14.3 invariant-checks=off deprecated-functions=off link=static runtime-link=shared  logging=off dht=on boost-link=static encryption=on crypto=openssl include="%~dp0..\..\openssl-build\v3\prebuilt\windows\%1\include" library-path="%~dp0..\..\openssl-build\v3\prebuilt\windows\%1\lib" include="%~dp0..\..\boost-build2\%OUTPUTDIR%\include" library-path="%~dp0..\..\boost-build2\%OUTPUTDIR%\lib" -sBOOST_ROOT="%~dp0..\..\boost-build2\src" define=_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR -j6 install --prefix="%OUTPUTPATH%"

call %BOOSTBUILD% %BUILD_OPTIONS% variant=debug

alervd avatar Jul 22 '25 22:07 alervd

I would also have thought it was the invariant checks that was slow (and consuming a lot of CPU). Your command line to disable invariant checks looks correct.

Although I don't think you need library-path=... and include=....

And where you specify the include- and library path to openssl, I would expect you to have to say: openssl-include=...and openssl-lib=....

Have you tried profiling shutting down? If it takes minutes I would expect it to be easy to pinpoint what it's doing.

arvidn avatar Jul 25 '25 20:07 arvidn