CBPS Forums

Console Hacking => PS Vita => Topic started by: Graphene on June 21, 2020, 12:48:17 AM

Title: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on June 21, 2020, 12:48:17 AM
Thread optimizer is plugin + config application set that allows you to adjust thread priority and CPU affinity mask of any threads created by game to achieve maximum performance.

Disclaimer:

This plugin is intended for users who at the very least understand the concept of threading.
If you have no idea what you are doing, you have the option to wait until someone else shares their preset for the game you want.


I am not responsible for any lost game progress or corrupted savedata caused by improper thread adjustments.

Please read all instructions carefully before installing!

1. Required plugins:

Thread Optimizer requires following plugins to be installed on your system:
- CoreUnlocker80000H (https://forum.devchroma.nl/index.php/topic,203.0.html (https://forum.devchroma.nl/index.php/topic,203.0.html)).
- ioPlus (https://forum.devchroma.nl/index.php/topic,205.0.html (https://forum.devchroma.nl/index.php/topic,205.0.html)).

Make sure you have both of them installed before continuing.

2. What is snapshot?

Snapshot is the file that holds information about all threads that game has created. Once snapshot has been made, it is also used as preset to store user-edited thread parameters.
Snapshot contains following information for each of the threads:
- CRC16 (checksum used to identify thread)
- Thread entry function address (used only to calculate CRC16)
- Thread name
- Thread priority <- can be edited in config app
- Thread CPU affinity mask <- can be edited in config app

3. Thread parameters that you can change:

- CPU afiinity mask
Determines wich CPU cores will be allowed to run the thread.

- Priority
Determines thread priority. Lower the number, higher the priority. It is not recommended to adjust it unless you know what you are doing.

4. Usage procedure:

- Install plugin and application.
Plugin can be installed under *ALL or under games you want to use it with.

- Launch the game you want to create preset for.

- Take a snapshot of game threads by holding LTRIGGER + RTRIGGER + SQUARE until you see notification.
Since snapshot accumulates all thread data since the game start, it is recommended that you at least get into the actual gameplay before taking a snapshot.
You can delete snapshot you just created by holding LTRIGGER + RTRIGGER + TRIANGLE. However, snapshots that has been taken in different game session can only be deleted from config app.

- Exit the game, open config app and adjust thread parameters of the snapshot and save it.

- Open the game again. New thread parameters will be applied automatically.

- You can delete snapshot from config application if you are not happy with your adjustments and start from scratch.

- Snapshots are stored in ux0:data/ThreadOptimizer/*titleid*/
Snapshots do not contain any personal data and can be shared with other users.

5. Current limitations:

- Parameters of the main thread cannot be adjusted.
- Threads that have same name, entry function address, priority and CPU affinity mask are considered to be the same.

TO usage guide: https://forum.devchroma.nl/index.php/topic,210.msg627.html#msg627 (https://forum.devchroma.nl/index.php/topic,210.msg627.html#msg627)

Download here: https://github.com/GrapheneCt/ThreadOptimizer/releases (https://github.com/GrapheneCt/ThreadOptimizer/releases)

Example of good snapshot profile (download link in the video description):

With Thread Optimizer:



Same level without Thread Optimizer:

Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on June 21, 2020, 03:19:42 AM
Fixed an issue that caused some games not registering an input.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on June 21, 2020, 05:28:57 PM
Thread Optimizer has been updated:

- Adds support for threads created by PTHREAD_PRX module (unity games).
- Adds support for threads created by SceLibc module (??? games).

Only plugin was updated, no need to reinstall .vpk if you already have it installed.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on June 21, 2020, 07:50:44 PM
Thread Optimizer has been updated yet again:

- Fixed thread detection (previuosly entry function address was used, now CRC16 is used)
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on July 02, 2020, 08:37:07 PM
Due to the popular demand, here is the good example of TO profile for Killzone Mercenary made by zanderman2009.
Download link in the video description:

With Thread Optimizer:



Same level without Thread Optimizer:

Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: ZeeThirtyTwo on July 04, 2020, 03:44:02 AM
So I played around with the snapshot for Jak and Daxter: The Precursor Legacy US version (PCSA00080) for a few hours and have all four cores being used quite heavily. I have tested the first four areas, not including Misty Island, at native resolution, capped at 30fps via Vitagrafix and 500Mhz through PSVshell v1.1. The game runs at 30fps most of the time and drops to about 25fps when drawing long distances. The game typically hovers between about 30fps to 45fps sometimes hitting 60fps when the cap is raised and resolution lowered. Raising the cap to 60fps makes the game run at half speed when the framerate is chugging along between 30fps to 45fps, so realistically we won't be able to play the game at 60fps ever.

I'm sure there's still plenty of tweaking to be done with better understanding of what the threads I'm assigning to cores actually do. I have not compared this to stock clocks without Thread Optimizer enabled since I know the game shipped sub native resolution with a 20fps cap. I plan on continuing to try to improve performance in this and other games on my spare time and would love to see what others can achieve with this awesome plugin. Many thanks to Graphene.

I have attached my current modified snapshot to this post (07/03/2020). Copy and paste the unzipped folder to your ux:0/data/ThreadOptimizer folder. Let me know how this works out for you and maybe we can achieve a locked 30fps at native resolution in the future!
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on July 04, 2020, 04:45:56 PM
Hey, I've made more progress on Killzone Mercenearies - I'm a bit of a perfectionist so I've made a console like profile - super smooth, consistent FPS - and a combat profile - lightning fast combat and low input latency by the looks of it, it'll keep up however fast you can shoot ;)

I've attacvhed the high performance profiles and only called them that because of the performance. I've tested them a good bit and the vita never breaks a sweat or ever freezes or crashes and never goes above 31c which is standard temps without a profile, the vita is a cracking piece of hardware.

Here's what the combat profile looks like
https://youtu.be/DtmWfZvLMdE

And this is the console profile:
https://youtu.be/db4VnDdPJJg

Both profiles are attached to this post


NOTE: Turning off native resolution is fantastic
https://youtu.be/jbW1U4kqWdQ

EDIT NOTE: This is all on 444mhz clock speed, I find it plays smoother. It doesnt happen all the time but it can feel like 500mhz can throw the profile a curve ball and it'll sometimes slowdown, that and I tested the profile exclusively on 444mhz :)
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on July 04, 2020, 09:53:14 PM
I messed around with Uncharted for a little bit, the problem is getting the cpu to rev up at all but I managed a bit more cpu usage. I was thinking it might be better trying single cores for each thread as multicore seems to kill cpu usage.

Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on July 10, 2020, 03:27:45 PM
Wipeout 2048 Profiles. I've made two profiles again, this time for Wipeout 2048

Just realised that I uploaded two high intensity profiles. I havent had time lately to make any videos but I've attached my final attempt at Wipeout.

I'll include the previous profile as well. The High Intensity version is really good, the Final Version is slightly tweaked for smoothness and speed and has some FPS increases and improvements in average FPS

Link attached to post.

VIDEO @444mhz, 960x540, 60 FPS, Sharpscale Point filter, Wipeout High Intensity Profile
https://youtu.be/yuoqiTVryDE
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on July 11, 2020, 05:10:40 PM
TIPS AND TRICKS

Attaching the tips and tricks as a text file to make scrolling less annoying and tidied up and made the tips a bit clearer.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: kristianity77 on July 13, 2020, 09:04:55 PM
Any chance this can work with retroarch to squeeze a bit more performance out on consoles like snes to iron out the few games that don't quite hit 60fps consistently?
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: teakhanirons on July 13, 2020, 10:47:51 PM
Any chance this can work with retroarch to squeeze a bit more performance out on consoles like snes to iron out the few games that don't quite hit 60fps consistently?
Emulation in RetroArch is single threaded if I'm not wrong.
In any case, it'd be better to have 4th core support added to homebrew properly in their own source codes. Detection code for it is present in its config app.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on July 16, 2020, 09:14:00 PM
Spiderman keeps crashing so i cant get a full playthrough or all of the level threads.

Graphene how difficult would it be to add threads to already existing profiles? Thats the only way i could see to get all the level threads

Unless someone can manage a full playthrough, take a snapshot after the final boss and post the profile, i've tried 3 times and i dont see it happening
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on July 21, 2020, 11:15:19 PM
I've attached a Spiderman Profile with something I just found out 10 minutes ago...

Enable all four cores on the level threads in Spiderman and lower the priority, to be honest I dont think it matters that much what values you enter, as long as they're between 100 and 160

The values in the profile are the first values I entered and it plays incredibly. The sound crackles at some points but thats because this is a profile I worked on before and didnt fix the sound but its nowhere near game breaking.

A profile could be made in parts.
- play an hour of the game and take a snapshot
-Repeat for the rest of the game
- enable allc ores and enter a priority between 100 and 160 at a guess

Thats it. If every game was made like this we'd have a super console. Spiderman is actually one of the best made games on the vita. Textures get added the faster the game plays. The spider boss is slightly more textured.

Demo Profile attached

VIDEO:
https://youtu.be/TTuQ9fEGnV4
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on August 02, 2020, 10:53:45 PM
Does anyone have any ideas for good underrated games that had framerate issues?
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: youbyoubouri on August 03, 2020, 10:54:19 AM
Does anyone have any ideas for good underrated games that had framerate issues?
Hi, borderland 2 would be awesome
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on August 05, 2020, 04:48:24 PM
Some games dont use the 4th core AT ALL, but will still let you enable the 4th core in thread optimizer.

I xdisabled core unlocker, killzone and wipeout either got stuck loading or didnt start, but attack on titan played fine with a profile enabling the 4th core.

@graphene do you think a 3 core mode in thread optimizer would help with the sound issues in some games? Where it would just be able to configure the 3 cores with core unlocker disabled

Some games even if they do enable the 4th core will roughly only use up to 25% in some cases. So its a good test for which games are enabling the 4th core and what ones arent using it at all and saves a bit of time trying to profile for 4 cores.

Wipeout definitely uses the 4th core but the highest i could get it was about 27% so there may be degrees of 4th core cpu usage.

Just spitballin ideas for these sound issues
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on August 05, 2020, 04:58:43 PM
Hi, borderland 2 would be awesome

😂 Its definitely underrated. As soon as a snapahot is taken it develops sound issues, same with gow, res evil revelations 2, attack on titan 1 (2 seems fine), xcom's sound issues might be able to be worked around but i dont know yet and there may be others

I'm waiting on a vitagrafix update for minecraft's latest patch so i can get started playing around with that.

I'm profiling ratchet and clank Qforce, AoT2, epic mickey and hollow realisation which will take a while because its an rpg and takes longer to test. Spiderman is too big a task roght now and thats about it

Oh and try the games with no profile. Some games that do utilise the 4th core to a decent degree usually get an fps boost purely from coreunlocker
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on August 05, 2020, 05:15:55 PM
Please don't spread misinformation. Retail games can't possibly utilize 4th core without CoreUnlocker:
1. Official Sony SDK doesn't expose CPU affinity mask value for 4th core for game developers.
2. Even if the devs would somehow guess the value, all thread-related functions have check in them that makes them error out if 4th core is attempted to use in game application.
The purpose of CoreUnlocker plugin is to disable that check.

It makes no sense for devs to use 4th core CPU affinity mask value (again, if they somehow guessed it), because all of the thread-related functions will simply error out. Games can't be programmed to use 4th core out of the box. That's the purpose of Thread Optimizer.

If some games do manage to run without CoreUnlocker and with 4th core enabled, that's because they have good exception handling and are able to work even if some thread-related functions don't work and return errors.

The reason you see 20 - 30% usage of 4th core without CoreUnlocker is because while games can't directly use it, SceShell and background applications use it, as well as some shared system modules.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: justalex on August 05, 2020, 05:45:17 PM
Please don't spread misinformation. Retail games can't possibly utilize 4th core without CoreUnlocker:
1. Official Sony SDK doesn't expose CPU affinity mask value for 4th core for game developers.
2. Even if the devs would somehow guess the value, all thread-related functions have check in them that makes them error out if 4th core is attempted to use in game application.
The purpose of CoreUnlocker plugin is to disable that check.

It makes no sense for devs to use 4th core CPU affinity mask value (again, if they somehow guessed it), because all of the thread-related functions will simply error out. Games can't be programmed to use 4th core out of the box. That's the purpose of Thread Optimizer.

If some games do manage to run without CoreUnlocker and with 4th core enabled, that's because they have good exception handling and are able to work even if some thread-related functions don't work and return errors.

The reason you see 20 - 30% usage of 4th core without CoreUnlocker is because while games can't directly use it, SceShell and background applications use it, as well as some shared system modules.


You've misread the post.

I'm saying that some games dont use the 4th core at all with core unlocker enabled and a TO profile with the 4th core assigned on threads but will still start up (which is what you said yourselfand that some games that definitely utilise the 4th core - confirmed with cpu usage - obviously wont start.

The important part is that it might be connected to sound issues - forcing a game to use the 4th core when the threada could be hard coded and create problems like sound issies.

Anyway, dont think i'll be posting here anymore if this is how you react to feedback on your work
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Graphene on August 05, 2020, 06:29:19 PM
Here is what I think about audio-related issues: these are probably caused by Thread Optimizer interpreting 1:1 threads as same and applying similar settings to all of them. In some games where devs were too lazy to give each thread distinctive feautures (like different names), that may cause some issues. Unfortunately I don't see a way of fixing that issue without implementing some compilicated thread differentiation algorithms which will degrade game performance.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: Gyro2006 on August 07, 2020, 10:12:22 AM
Does anyone have any ideas for good underrated games that had framerate issues?
Hey, thank you for your contributions :) . Don't know if you are interested but i'd love to see nfs most wanted at native resolution with stable fps
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: oldhouse on August 16, 2020, 11:21:50 AM
Does anyone have any ideas for good underrated games that had framerate issues?

Would Timespinner be a good candidate? Without overclocking it has some heavy FPS drop so maybe it would be nice to use all 4 cpu.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: dkrmdi on August 18, 2020, 09:19:57 AM
Here are some list...

Assasin's creed Liberation.
NFS Most wanted
Sword Art Online Hollow Realization
Atelier Sophie, Firis, Lydie & Suelle
Night of Azure 1 and 2
Blue Reflection
Ys 8 and Ys celceta
Sonic Transformed
Fate/Extella Link
Attack on Titan 2
Gundam Breaker 3
Disney Epic Mickey 2
Unit 13

AC Liberation seriously needs some work.
Title: Re: [Release] Thread Optimizer - adjust thread parameters to achieve max performance
Post by: dkrmdi on August 18, 2020, 09:27:13 AM
Project Diva series does not have PFS problems, but I'd be glad if more improvements can be made.