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

Config to use multiple threads #51

Open
0x3dev opened this issue Dec 12, 2022 · 1 comment
Open

Config to use multiple threads #51

0x3dev opened this issue Dec 12, 2022 · 1 comment
Labels
Feature Request New feature or request help wanted Extra attention is needed

Comments

@0x3dev
Copy link

0x3dev commented Dec 12, 2022

The overall work is pretty slow on a 20k lines file so making use of worker_threads module and adding a param to specify threads count should help a lot.

@BenBaryoPX
Copy link
Collaborator

That's a good ask. I'll leave it open if someone wants to take it as it will take time to implement and test.
Here's my take on how to implement it:

  • Modules must run in order so the modules themselves shouldn't be threaded or running async.
  • What can be processed in parallel is the loop iterating over each modules' candidates.
  • Each candidate will be sent to a thread / async function, and the module will wait until the last thread is finished in order to return to runLoop.
    For Example:
async function someModule(arb, ...) {
  const candidates = arb.ast.filter // ...
  const runningFuncs = [];
  for (const c of candidates) {
    runningFuncs.push(async function(c) {
      // logic
    });
  }
  await Promise.all(runningFuncs);
  return arb;
}

@BenBaryoPX BenBaryoPX added Feature Request New feature or request help wanted Extra attention is needed labels Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants