PerimeterX / restringer

A Javascript Deobfuscator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Config to use multiple threads

0x3dev opened this issue · comments

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.

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;
}