TournamentStreamHelper
TournamentStreamHelper copied to clipboard
Loading sets from start.gg, and swapping players with a lot of data loaded, makes TSH take way too much CPU time
Basically, TSH might export a LOT of things now when working with start.gg, program_state.json is a huge file, and writing / changing a lot of things in it at once (which happens when loading and swapping) really takes a lot of CPU time. On some computers simply swapping the players sends TSH to 100% CPU Usage, while OBS starts dropping frames until TSH finishes swapping, which takes a few seconds.
Solutions to that would be :
- Splitting the state JSON into different files (for example : scoreboard (without history) ; match/tournament history / bracket / player list / stream queue )
- Avoiding complete rewrites when swapping
my program_state.json is 28k. big, but no computer should have difficulty writing that file quickly, especially when it never did before. However, my scoreboard pulls from the individual .txt files for name and data. Nothing is even accessing the huge .json file, but rather it appears the entire process of TSH writing files in general pushes full load. the last tournament I used TSH was September 9th and this problem didn't exist. I updated TSH the morning of October 14th's tournament and this happened with every single data update. especially bad because when you load a new set, it does not reset the score automatically anymore, which means I have to click 'reset score' and it locks the stream for 4-5 seconds EVERY time.
@mastermind6000 which version were you using before and which one are you using now?
@mastermind6000 which version were you using before and which one are you using now?
5.73. using 5.72 right now works just fine.
@mastermind6000 which version were you using before and which one are you using now?
5.73. using 5.72 right now works just fine.
Do you mean the release itself or main
?
@mastermind6000 which version were you using before and which one are you using now?
5.73. using 5.72 right now works just fine.
Do you mean the release itself or
main
?
I updated from inside the software. you tell me.
this still exists in 5.75. what's the best part? I can't go back to 5.72 anymore, because it's no longer capable of downloading sets!
Start.gg changed their API for loading sets, meaning changes had to be made unfortunately. We could definitely make an LTS release for 5.72 but the latest that fixed this issue (afaik) is 5.741
5.741 and 5.75 still exhibit the CPU spikes. it's different, like they may not be as total, but it's till a huge spike and it will affect other processes, like OBS.
We have downgraded Python back to 3.10 on the beta branch (See https://github.com/joaorb64/TournamentStreamHelper/commit/08312ddbfdf4ccbdc7b6c2b2966e335f04e2f162)
@mastermind6000 If you download the build linked here, does this mitigate CPU spikes on your end?
Yes, that appears to address the bug. The names and scores in TSH screen are updated immediately, without pause. the score is updated the same. Swap teams is instantaneous, and there are no visible CPU spikes. However none of my scoreboard pages work with 5.75, because I have not looked into that update yet :)
Possibly related, documented performance regression in Unicode concatenation in Python 3.11:
https://stackoverflow.com/questions/74605279/python-3-11-worse-optimized-than-3-10
https://github.com/python/cpython/issues/99862
Ah indeed, that's very likely to be a major (if not the only) cause. Damn you Python.