Speed up parser execution time by up to 2x & reduce cpu load by up to 5x by bundling parser-sdk #3137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Using bun here over esbuild as bun generates correct esm code which works. esbuild right now outputs a weird mixture bundles which fails with cryptic "stream cannot be required dynamically" node error messages.
The performance speedup here is quit substantial:
(tester using hyperfine with a mocked out parser (always returning emtpy results), result files are fetched from a github gist and pushed to some webhook testing site.
e.g.
hyperfine --runs 25 -i 'SCAN_NAME=nmap NAMESPACE=default node --enable-source-maps parser-wrapper.js https://gist.githubusercontent.com/J12934/6440478a5005dafdf52c1236c859eed0/raw/bc212dffbdaaf03cdf119b60b0c5211533677b36/scanme-nmap-org.xml hyperfine --runs 25 -i 'SCAN_NAME=nmap NAMESPACE=default node --enable-source-maps parser-wrapper.js https://gist.githubusercontent.com/J12934/6440478a5005dafdf52c1236c859eed0/raw/bc212dffbdaaf03cdf119b60b0c5211533677b36/scanme-nmap-org.xml https://webhook.site/...
Results:
Regular:
Bundled:
So total runtime dropped from 467ms to 232ms, but even more significant system time dropped from ~100ms to ~20ms. So it should require a lot less cpu cycles and resources to execute 🥳
Checklist