-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
feat(process/scanner): offload scanning to a worker thread #133
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! The server only runs on Node so you can just use node:worker_threads
. Honestly, I think this is better done on Vesktop's side just running all of arrpc in another thread but let me know what you think.
Makes sense.
I think it's probably technically possible to implement in Vesktop, but the arrpc server object emits events, some of which ( By putting the entire arrpc server in a |
I'm open to implementing it in arRPC, just wanted some clarifications on why it is needed here instead of in users. That makes sense to me, I didn't consider how annoying serialization is with |
No worries. Honestly, its going to be annoying regardless of where it's done because of Vesktop's bundling anyway |
I think to do it properly in arRPC, it might also be good to detect if the |
This is a patch for Vencord/Vesktop#1009, which I can reliably reproduce.
It aims to remove any possibility of stutter on the main thread by offloading process scanning to a worker_thread or Web Worker.
I used the threads.js library, because it (should) automatically handle detecting which type of worker to use depending on where you're running (
worker_threads
for node, Web Worker for a browser).I've only tried this on Vesktop (electron/node) and it works well (although, I have to include a patch so that the ESBuild bundler that they use can load the worker script properly — I don't think there's a good alternative solution for this other than maybe adding a build step to this package).
The
patches/threads+1.7.0.patch
file is not strictly necessary, and only helps with typings, since that project is not exporting them properly.