CarlGao4 / Demucs-Gui

A GUI for music separation AI demucs
GNU General Public License v3.0
493 stars 37 forks source link

Bug: Strangely high CPU usage #50

Open Mrw33554432 opened 5 months ago

Mrw33554432 commented 5 months ago

happen

  1. Having over 1000 audio in queue
  2. Start separation
  3. If there is over 10000 audio files in queue, then the program is completely CPU bounded. (Super slow sep and very low GPU usage - about 1%)
  4. version 1.1a2 and 1.1b2

It happens during the whole separation process (not just loading and saving phrase) It' very likely caused by the gui I am highly suspicious on the queue management as the performance get worse when queue is larger - the degradation is almost linear Issue

What is the platform you are using?

Windows

log

2024-03-15 09:57:25,467 (GuiMain.py) (Line 1729) [INFO] : Python version: 3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)]
2024-03-15 09:57:25,467 (GuiMain.py) (Line 1730) [INFO] : Demucs GUI version: 1.1b2
2024-03-15 09:57:25,494 (GuiMain.py) (Line 1731) [INFO] : System: Windows-10-10.0.19045-SP0
2024-03-15 09:57:25,494 (GuiMain.py) (Line 1732) [INFO] : Architecture: 64bit
2024-03-15 09:57:25,494 (GuiMain.py) (Line 1733) [INFO] : CPU: AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD
2024-03-15 09:57:25,494 (GuiMain.py) (Line 1734) [INFO] : CPU count: 24
2024-03-15 09:57:25,508 (GuiMain.py) (Line 1735) [INFO] : System memory: 34239574016 (31.888GB)
2024-03-15 09:57:25,510 (GuiMain.py) (Line 1738) [INFO] : System free memory: 29271797760 (27.262GB)
2024-03-15 09:57:25,607 (GuiMain.py) (Line 1741) [INFO] : System swap memory: 5100273664 (4.75GB)
2024-03-15 09:57:25,686 (find_device_win.py) (Line 111) [INFO] : Found GPU: NVIDIA GeForce RTX 3090 (10DE:2204)
2024-03-15 09:57:25,686 (GuiMain.py) (Line 1755) [INFO] : Using PySide6
2024-03-15 09:57:25,686 (GuiMain.py) (Line 1756) [INFO] : Qt version: 6.5.3
2024-03-15 09:57:25,686 (GuiMain.py) (Line 1757) [INFO] : PySide6 version: 6.5.3
2024-03-15 09:57:25,719 (shared.py) (Line 289) [INFO] : [1] Thread starter (separator.py) starts
2024-03-15 09:57:25,754 (GuiMain.py) (Line 1762) [DEBUG] : Supported styles: windowsvista, Windows, Fusion
2024-03-15 09:57:25,755 (GuiMain.py) (Line 1766) [DEBUG] : Current style: windowsvista
2024-03-15 09:57:26,846 (separator.py) (Line 64) [INFO] : Intel Extension for PyTorch is not installed
2024-03-15 09:57:26,925 (audio.py) (Line 34) [INFO] : Soundfile version: 0.12.1
2024-03-15 09:57:26,926 (audio.py) (Line 35) [INFO] : libsndfile version: 1.2.0
2024-03-15 09:57:26,926 (audio.py) (Line 36) [INFO] : SoXR version: 0.3.7
2024-03-15 09:57:26,926 (audio.py) (Line 37) [INFO] : libsoxr version: 0.1.3-7-gacc0dac
2024-03-15 09:57:26,926 (separator.py) (Line 85) [INFO] : Demucs version: 4.1.0a2
2024-03-15 09:57:26,926 (separator.py) (Line 86) [INFO] : PyTorch version: 2.0.1+cu118
2024-03-15 09:57:26,926 (separator.py) (Line 95) [INFO] : CUDA Info: _CudaDeviceProperties(name='NVIDIA GeForce RTX 3090', major=8, minor=6, total_memory=24575MB, multi_processor_count=82)
2024-03-15 09:57:27,953 (audio.py) (Line 49) [INFO] : ffmpeg -version output:
ffmpeg version 6.1.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers

built with gcc 12.2.0 (Rev10, Built by MSYS2 project)

configuration: --enable-gpl --enable-version3 --enable-shared --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint

libavutil      58. 29.100 / 58. 29.100

libavcodec     60. 31.102 / 60. 31.102

libavformat    60. 16.100 / 60. 16.100

libavdevice    60.  3.100 / 60.  3.100

libavfilter     9. 12.100 /  9. 12.100

libswscale      7.  5.100 /  7.  5.100

libswresample   4. 12.100 /  4. 12.100

libpostproc    57.  3.100 / 57.  3.100

2024-03-15 09:57:27,980 (audio.py) (Line 54) [INFO] : Using ffmpeg from D:\Desktop\Demucs-GUI_1.1b2_cuda\ffmpeg\ffmpeg.EXE
2024-03-15 09:57:27,980 (audio.py) (Line 55) [INFO] : ffprobe -version output:
ffprobe version 6.1.1-full_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers

built with gcc 12.2.0 (Rev10, Built by MSYS2 project)

configuration: --enable-gpl --enable-version3 --enable-shared --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint

libavutil      58. 29.100 / 58. 29.100

libavcodec     60. 31.102 / 60. 31.102

libavformat    60. 16.100 / 60. 16.100

libavdevice    60.  3.100 / 60.  3.100

libavfilter     9. 12.100 /  9. 12.100

libswscale      7.  5.100 /  7.  5.100

libswresample   4. 12.100 /  4. 12.100

libpostproc    57.  3.100 / 57.  3.100

2024-03-15 09:57:28,980 (shared.py) (Line 300) [INFO] : [1] Thread starter (separator.py) ends
2024-03-15 09:57:28,983 (shared.py) (Line 289) [INFO] : [2] Thread checkUpdate (shared.py) starts
2024-03-15 09:57:28,988 (shared.py) (Line 316) [INFO] : Checking for updates...
2024-03-15 09:57:30,922 (shared.py) (Line 289) [INFO] : [3] Thread loadModel (GuiMain.py) starts
2024-03-15 09:57:30,923 (GuiMain.py) (Line 625) [INFO] : Loading model htdemucs from repo D:\Desktop\Demucs-GUI_1.1b2_cuda\pretrained
2024-03-15 09:57:31,225 (GuiMain.py) (Line 653) [INFO] : Model loaded within 0.2984s
2024-03-15 09:57:31,225 (GuiMain.py) (Line 654) [INFO] : Model: htdemucs
Repo: D:\Desktop\Demucs-GUI_1.1b2_cuda\pretrained
Type: Bag of models
Audio channels: 2
Sample rate: 44100
Sources: drums, bass, other, vocals

Model 0:
 Type: HTDemucs
 Default segment: 7.8
 Weight: [1.0, 1.0, 1.0, 1.0]
2024-03-15 09:57:31,235 (shared.py) (Line 300) [INFO] : [3] Thread loadModel (GuiMain.py) ends
2024-03-15 09:57:31,235 (GuiMain.py) (Line 1234) [INFO] : Preset stem key: ["bass","drums","other","vocals"]
2024-03-15 09:57:31,235 (GuiMain.py) (Line 1386) [INFO] : Adding saved presets: []
2024-03-15 09:57:34,907 (shared.py) (Line 319) [INFO] : Latest version: 1.1b2
2024-03-15 09:57:34,907 (shared.py) (Line 300) [INFO] : [2] Thread checkUpdate (shared.py) ends
2024-03-15 09:58:42,893 (shared.py) (Line 289) [INFO] : [4] Thread separate (separator.py) starts
2024-03-15 09:58:42,893 (separator.py) (Line 446) [INFO] : Start separating audio: xxx.mp3
2024-03-15 09:58:42,893 (separator.py) (Line 447) [INFO] : Parameters: segment=7.80 overlap=0.25 shifts=0
2024-03-15 09:58:42,893 (separator.py) (Line 448) [INFO] : Device: cuda:0
2024-03-15 09:58:42,893 (audio.py) (Line 66) [DEBUG] : Reading audio with soundfile: D:\Desktop\data\xxx.mp3
2024-03-15 09:58:42,948 (audio.py) (Line 82) [INFO] : Read audio D:\Desktop\data\xxx.mp3: samplerate=44100 shape=(3764224, 2)
2024-03-15 09:58:42,952 (separator.py) (Line 478) [INFO] : Running separation...
2024-03-15 09:58:47,139 (separator.py) (Line 503) [INFO] : Saving separated audio...
2024-03-15 09:58:47,140 (shared.py) (Line 289) [INFO] : [5] Thread save (GuiMain.py) starts
2024-03-15 09:58:47,140 (shared.py) (Line 300) [INFO] : [4] Thread separate (separator.py) ends
2024-03-15 09:58:47,141 (GuiMain.py) (Line 1506) [INFO] : Mixing stem vocals

2024-03-15 09:58:47,204 (shared.py) (Line 205) [DEBUG] : (save) Set history ('save_location',) to OrderedSet([
3000 items here
3000 items here
3000 items here
'separated/vocals/053.flac', 'separated/vocals/052.flac', 'separated/vocals/051.flac', 'separated/vocals/050.flac', 
'separated/vocals/049.flac', 'separated/vocals/048.flac', 'separated/vocals/047.flac', 'separated/vocals/046.flac', 'separated/vocals/045.flac', 'separated/vocals/044.flac', 'separated/vocals/043.flac', 'separated/vocals/042.flac', 'separated/vocals/041.flac', 'separated/vocals/040.flac', 'separated/vocals/039.flac', 'separated/vocals/038.flac', 'separated/vocals/037.flac', 'separated/vocals/036.flac', 'separated/vocals/035.flac', 'separated/vocals/034.flac', 'separated/vocals/033.flac', 'separated/vocals/032.flac', 'separated/vocals/031.flac', 'separated/vocals/030.flac', 'separated/vocals/029.flac', 'separated/vocals/028.flac', 'separated/vocals/027.flac', 'separated/vocals/026.flac', 'separated/vocals/025.flac', 'separated/vocals/024.flac', 'separated/vocals/023.flac', 'separated/vocals/022.flac', 'separated/vocals/021.flac', 'separated/vocals/020.flac', 'separated/vocals/019.flac', 'separated/vocals/018.flac', 'separated/vocals/017.flac', 'separated/vocals/016.flac', 'separated/vocals/015.flac', 'separated/vocals/014.flac', 'separated/vocals/013.flac', 'separated/vocals/012.flac', 'separated/vocals/011.flac', 'separated/vocals/010.flac', 'separated/vocals/009.flac', 'separated/vocals/008.flac', 'separated/vocals/007.flac', 'separated/vocals/006.flac', 'separated/vocals/005.flac', 'separated/vocals/004.flac', 'separated/vocals/003.flac', 'separated/{model}/{track}/{stem}.{ext}'])

2024-03-15 09:58:47,255 (shared.py) (Line 289) [INFO] : [6] Thread separate (separator.py) starts
2024-03-15 09:58:47,255 (separator.py) (Line 446) [INFO] : Start separating audio: xxx.mp3
2024-03-15 09:58:47,255 (separator.py) (Line 447) [INFO] : Parameters: segment=7.80 overlap=0.25 shifts=0
2024-03-15 09:58:47,255 (separator.py) (Line 448) [INFO] : Device: cuda:0
2024-03-15 09:58:47,255 (audio.py) (Line 66) [DEBUG] : Reading audio with soundfile: D:\Desktop\data\xxx.mp3
2024-03-15 09:58:47,429 (audio.py) (Line 129) [INFO] : Saved audio D:\Desktop\data\xxx.flac: shape=torch.Size([2, 3764224])
2024-03-15 09:58:47,430 (shared.py) (Line 300) [INFO] : [5] Thread save (GuiMain.py) ends
2024-03-15 09:58:47,438 (audio.py) (Line 82) [INFO] : Read audio D:\Desktop\data\xxx.mp3: samplerate=44100 shape=(10780672, 2)
2024-03-15 09:58:47,449 (separator.py) (Line 478) [INFO] : Running separation...
2024-03-15 09:58:52,425 (separator.py) (Line 503) [INFO] : Saving separated audio...
2024-03-15 09:58:52,426 (shared.py) (Line 289) [INFO] : [7] Thread save (GuiMain.py) starts
2024-03-15 09:58:52,428 (shared.py) (Line 300) [INFO] : [6] Thread separate (separator.py) ends
2024-03-15 09:58:52,428 (GuiMain.py) (Line 1506) [INFO] : Mixing stem vocals
2024-03-15 09:58:52,429 (shared.py) (Line 289) [INFO] : [8] Thread separate (separator.py) starts
2024-03-15 09:58:52,429 (separator.py) (Line 446) [INFO] : Start separating audio:xxx.mp3
2024-03-15 09:58:52,430 (separator.py) (Line 447) [INFO] : Parameters: segment=7.80 overlap=0.25 shifts=0
2024-03-15 09:58:52,430 (separator.py) (Line 448) [INFO] : Device: cuda:0
2024-03-15 09:58:52,432 (audio.py) (Line 66) [DEBUG] : Reading audio with soundfile: D:\Desktop\data\xxx.mp3

2024-03-15 09:58:52,649 (shared.py) (Line 205) [DEBUG] : (save) Set history ('save_location',) to OrderedSet([
3000 items here
3000 items here
3000 items here
 'separated/vocals/004.flac', 'separated/vocals/003.flac', 'separated/{model}/{track}/{stem}.{ext}'])

2024-03-15 09:58:52,721 (audio.py) (Line 82) [INFO] : Read audio D:\Desktop\data\xxx.mp3: samplerate=44100 shape=(11394048, 2)
2024-03-15 09:58:52,733 (separator.py) (Line 478) [INFO] : Running separation...
2024-03-15 09:58:53,299 (audio.py) (Line 129) [INFO] : Saved audio D:\Desktop\data\xxx.flac: shape=torch.Size([2, 10780672])
2024-03-15 09:58:53,301 (shared.py) (Line 300) [INFO] : [7] Thread save (GuiMain.py) ends
2024-03-15 09:58:58,057 (separator.py) (Line 503) [INFO] : Saving separated audio...
2024-03-15 09:58:58,057 (shared.py) (Line 289) [INFO] : [9] Thread save (GuiMain.py) starts
2024-03-15 09:58:58,063 (shared.py) (Line 300) [INFO] : [8] Thread separate (separator.py) ends
2024-03-15 09:58:58,063 (GuiMain.py) (Line 1506) [INFO] : Mixing stem vocals
2024-03-15 09:58:58,064 (shared.py) (Line 289) [INFO] : [10] Thread separate (separator.py) starts
2024-03-15 09:58:58,073 (separator.py) (Line 446) [INFO] : Start separating audio:xxx.mp3
2024-03-15 09:58:58,074 (separator.py) (Line 447) [INFO] : Parameters: segment=7.80 overlap=0.25 shifts=0
2024-03-15 09:58:58,074 (separator.py) (Line 448) [INFO] : Device: cuda:0
2024-03-15 09:58:58,074 (audio.py) (Line 66) [DEBUG] : Reading audio with soundfile: D:\Desktop\data\xxx.mp3

2024-03-15 09:58:58,305 (shared.py) (Line 205) [DEBUG] : (save) Set history ('save_location',) to OrderedSet([
3000 audio files in this set
3000 audio files in this set
3000 audio files in this set
'separated/vocals/004.flac', 'separated/vocals/003.flac', 'separated/{model}/{track}/{stem}.{ext}'])
CarlGao4 commented 5 months ago

What if you click on the table header “status”? As I explained in the documentation, the progress bar shown in the table will lose its animation by default. But I manually enabled it by force repainting every 1/25 seconds. I realized that this will consume a lot of CPU time, so I then gave the user a choice to disable it by clicking on the table header

Mrw33554432 commented 5 months ago

What if you click on the table header “status”? As I explained in the documentation, the progress bar shown in the table will lose its animation by default. But I manually enabled it by force repainting every 1/25 seconds. I realized that this will consume a lot of CPU time, so I then gave the user a choice to disable it by clicking on the table header

Here is what I observed after click on Status:

  1. The program is a lot slower.
  2. GPU usage having large gap between each peak
  3. CPU usage is a lot lower (consistent 60%) -> (40% peak with gap in between)
CarlGao4 commented 5 months ago

So this means that you didn't enable the animation before I think I need to find out how Qt6 deal with large tables

CarlGao4 commented 5 months ago

Can you try pausing when separating a file and see CPU usage? I’m using my phone and can’t test it myself

Mrw33554432 commented 5 months ago

Can you try pausing when separating a file and see CPU usage? I’m using my phone and can’t test it myself

pause -> CPU 1%

CarlGao4 commented 5 months ago

And clicking on the header when paused?

Mrw33554432 commented 5 months ago

And clicking on the header when paused?

6% (no white light animation, just green bar)

It's a little tricky as enabling the animation result in a higher GPU occupacy (better). I will also test a little bit about file language issue since the GUI worked fine on another dataset in different filename language.

CarlGao4 commented 5 months ago

I guess this is related to QTableWidget but I can’t prove it now It will create a widget for every table item, so if you add 10k+ files it will construct 30k+ (10k for vertical header, 10k for file name, 10k for progress bar) But fixing this requires rewriting the whole program as I’m actually passing the table item widgets as function arguments to update UI

Mrw33554432 commented 5 months ago

I guess this is related to QTableWidget but I can’t prove it now It will create a widget for every table item, so if you add 10k+ files it will construct 30k+ (10k for vertical header, 10k for file name, 10k for progress bar) But fixing this requires rewriting the whole program as I’m actually passing the table item widgets as function arguments to update UI

what if we cut the files passed to the GUI into chunks of 10 - 50 files, and working on each file chunk one by one? That might be a little easier to implement since it doesn't change the UI but file handling XD.

CarlGao4 commented 5 months ago

Sorry but I didn't quite understand what you mean

Mrw33554432 commented 5 months ago

Sorry but I didn't quite understand what you mean

Actually It is quite simple.

Instead of 10000 files -> GUI

we do 50 files -> GUI ... 50 files -> GUI x 200

Just adding a second level queue (only display numbers, store in a python list or queue)would solve this issue. Now the GUI will only display up to 50 (n, you can determine) files that it is currently processing on, and the number of files that has been processed and waiting to be processed (basically fold them up). like

1000 files done!
file 1 - process bar
file 2 - process bar
file 3 - process bar
9000 files in queue

And for users who pass less than 50 (n) files to GUI, there won't be any change

It is mostly a patch-like approach

Mrw33554432 commented 5 months ago

New Update:

The problem can be partially solved by selecting any tab other than File queue (xxx). For example, if you switch to the Mixer tab or Select Model tab, the low GPU usage issue will be disappear.

But the high CPU usage issue remains.

CarlGao4 commented 5 months ago

That's strange. I remember that Qt renders its window CPU-only, while separation and window rendering is in different threads, so theoretically they won't affect each other...

Mrw33554432 commented 5 months ago

That's strange. I remember that Qt renders its window CPU-only, while separation and window rendering is in different threads, so theoretically they won't affect each other...

Here is a quick analysis from AI, actually I partially agree with it. Instead of having the GPU thread to send signal to window thread, it might be better for the window thread to request status on GPU thread, or having another one in between that is guaranteed to be non-blocking.

I have not been working on thread programming for a while, but I remember a trick you can try

class Separator
    ...
    self.processbar: float = 1.1 #example

and just access this param from window thread, which should be non-blocking in most cases.

(Below From AI)

Based on the provided code, it appears that the separation process and the GUI are already running on separate threads. The startSeparate method in the Separator class is decorated with @shared.thread_wrapper(daemon=True), indicating that it runs on a separate daemon thread.

However, there are a few places where the GUI thread may potentially block the GPU processing thread:

  1. In the Separator.separate method, there are calls to setStatus, setModelProgress, and setAudioProgress. These methods emit signals that are connected to slots in the GUI thread. If the GUI thread is busy or unresponsive, it may delay the processing of these signals, potentially blocking the separation thread.

  2. The Separator.separate method also calls the save_callback function, which is passed as an argument and is responsible for saving the separated audio files. If the save_callback function performs any blocking operations or interacts with the GUI thread, it could potentially block the separation thread.

  3. The Separator.updateProgress method is called frequently during the separation process to update the progress information. This method emits signals to update the GUI elements. If the GUI thread is busy or unresponsive, it may delay the processing of these signals, potentially blocking the separation thread.

To minimize the chances of the GUI thread blocking the GPU processing thread, you can consider the following:

  1. Ensure that the GUI thread remains responsive and avoids long-running or blocking operations. Optimize the rendering and updating logic in the GUI, especially in the file queue handling code, to reduce the chances of the GUI thread becoming unresponsive.

  2. Review the save_callback function and any other callbacks passed to the separation thread. Make sure they don't perform any blocking operations or interact with the GUI thread directly. If necessary, use separate threads or asynchronous programming techniques to handle file saving and other operations.

  3. Consider using a separate thread or a thread pool for handling the progress updates and GUI element updates. Instead of directly emitting signals from the separation thread, you can queue the updates and process them on a dedicated thread. This can help decouple the separation thread from the GUI thread and reduce the chances of blocking.

  4. If the separation process is still being blocked by the GUI thread, you may need to investigate further and profile the application to identify specific bottlenecks or areas where the threads are interacting in a way that causes blocking.

It's important to note that the provided code snippets don't include the complete implementation of all the methods and classes involved, so there might be other places where the GUI thread and the separation thread interact that are not visible in the given code.

To fully diagnose and resolve the issue, it would be helpful to have access to the complete codebase and perform thorough testing and profiling to identify the specific points where the GUI thread may be blocking the GPU processing thread.

CarlGao4 commented 5 months ago

Updating progress or UI must be done in the main thread, and I made sure that during this process, the thread called those functions must be blocked so the main thread won't be queued with a lot of callbacks... Besides, when I first wrote this program, I thought that there would only be very few people who would load thousands of files at the same time... So I even didn't create a list to store the file queue, but read the table and check the progress bar status one by one from the top of it, because this would be much easier and the effect can be really small if we only add no more than about 1000 items Currently I'll only suggest users to switch to other tabs to avoid that

Mrw33554432 commented 5 months ago

Updating progress or UI must be done in the main thread, and I made sure that during this process, the thread called those functions must be blocked so the main thread won't be queued with a lot of callbacks... Besides, when I first wrote this program, I thought that there would only be very few people who would load thousands of files at the same time... So I even didn't create a list to store the file queue, but read the table and check the progress bar status one by one from the top of it, because this would be much easier and the effect can be really small if we only add no more than about 1000 items Currently I'll only suggest users to switch to other tabs to avoid that

Yeah I agree. Actually the best way to handle lot of audio files is using a custom Dataset object and manually handle batch in -> batch out -> save to audio, but the Demucs project is a little bit too complex and containing many code integrations, which make the function a little bit hard to implement. And as it will only take about 30% speed up but requires lot of time to implement, I will just stick with GUI for now XD (the Cli is even a little slower than GUI)

CarlGao4 commented 5 months ago

I'll consider adding a warning in the next version when the user adds too many files to the queue (like the first time it reaches 500) and tell what to do The most basic cause of this is just I thought nobody would add thousands of files at the same time

ferropop commented 3 months ago

Lots of us out here ripping huge libraries! Any efforts to mitigate the slowdown would be ever appreciated!