Speed up parser execution time by up to 2x & reduce cpu load by up to 5x by bundling parser-sdk#3137
Merged
Weltraumschaf merged 1 commit intosecureCodeBox:mainfrom Jul 16, 2025
Conversation
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. ```sh 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: Time (mean ± σ): 467.0 ms ± 47.2 ms [User: 443.8 ms, System: 97.7 ms] Range (min … max): 443.2 ms … 692.0 ms 25 runs Bundled: Time (mean ± σ): 246.0 ms ± 16.3 ms [User: 176.6 ms, System: 16.9 ms] Range (min … max): 232.7 ms … 319.7 ms 25 runs So total runtime dropped from 443ms 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 🥳 Signed-off-by: Jannik Hollenbach <jannik.hollenbach@iteratec.com>
✅ Deploy Preview for docs-securecodebox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Weltraumschaf
approved these changes
Jul 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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