Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Concurrency for the script #448

Open
Paladynee opened this issue Nov 16, 2024 · 1 comment
Open

[Feature]: Concurrency for the script #448

Paladynee opened this issue Nov 16, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Paladynee
Copy link

Paladynee commented Nov 16, 2024

Problem statement

I am skimming through the resulting script from the Standard preset for Windows. Looking for a culprit responsible for the low performance, and the first educated guess is most tweaks firing up a powershell instance. Sure, it works good enough but we can do better by leveraging concurrency for the tweaks, since none (or a negligible amount) of the tweaks depend on each other.

Proposed solution

approach 1

The implementation is up to the developer, however, a simple framework could be one that generates subscripts of privacy.sexy in a child folder in the current working directory and spreads tweaks evenly between many scripts. The "amount of tweaks" surely isn't a good metric to approximate the resulting performance but it will be good enough™. Then, we can fire up multiple child processes that run these split-scripts for more concurrency, possibly leveraging more threads.

approach 2

However, if approach 1 does not work, or the tweak code generation is different, a queue approach can be taken. We will open some amount of child processes, and each process will access a specific tweak using the process index from a shared queue, and then run those tweaks.

  • disambiguation pseudocode:
    queue[completed_tweaks * total_processes + i] // where i is the current tweak index

    visual example
    image

Additional information

Resolving the matter of "tweaks that depend on eachother" can be solved by putting tweaks that depend on each other, next to eachother in the same sub-script/queue entry.

Challenges could include code generation for the script, and figuring out the runtime.

The concurrency feature can be added as an optional feature in the web version. It will require a checkbox and optionally a specific amount of processes.

Feature pros and cons

+ Will improve performance on powershell-heavy scripts (and other blocking commands)
+ Little overhead
+ Privacy.sexy already uses a script-generator, this can easily be used for the concurrency

- Will not improve performance on CPU bottlenecked targets
- Slightly harder to maintain (which tweaks depend on eachother?)
- Possible introduction of races

@Paladynee Paladynee added the enhancement New feature or request label Nov 16, 2024
@Paladynee Paladynee changed the title [Feature]: Script parallelization [Feature]: Concurrency Nov 16, 2024
@Paladynee Paladynee changed the title [Feature]: Concurrency [Feature]: Concurrency for the script Nov 16, 2024
@undergroundwires
Copy link
Owner

This is great suggestion. I will implement this in a feature release when I have the time (no timelines promised unfortunately due to many TODOs). Thank you @Paladynee.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants