TournamentStreamHelper icon indicating copy to clipboard operation
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

Open TwilCynder opened this issue 1 year ago • 12 comments

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

TwilCynder avatar Sep 20 '23 09:09 TwilCynder

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. obs64_8UzkuLcg6Q obs64_CdqFs2fpJl obs64_CI51ec6FC6

mastermind6000 avatar Oct 16 '23 22:10 mastermind6000

@mastermind6000 which version were you using before and which one are you using now?

joaorb64 avatar Oct 18 '23 21:10 joaorb64

@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 avatar Oct 18 '23 21:10 mastermind6000

@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?

joaorb64 avatar Oct 19 '23 20:10 joaorb64

@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.

mastermind6000 avatar Oct 19 '23 21:10 mastermind6000

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!

mastermind6000 avatar Jan 14 '24 07:01 mastermind6000

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

sticks-stuff avatar Jan 15 '24 14:01 sticks-stuff

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. ProcessHacker_0wXBroalss ProcessHacker_f7crd4alxA obs64_fKw9n8Ii5B

mastermind6000 avatar Jan 15 '24 19:01 mastermind6000

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?

Wolfy76700 avatar Jan 15 '24 22:01 Wolfy76700

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 :)

mastermind6000 avatar Jan 16 '24 07:01 mastermind6000

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

Widdershin avatar Jan 21 '24 03:01 Widdershin

Ah indeed, that's very likely to be a major (if not the only) cause. Damn you Python.

TwilCynder avatar Jan 29 '24 14:01 TwilCynder