Commit 9699287
committed
Bundle parser-sdk into one js file to speed up startup time
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>1 parent ce2db15 commit 9699287
4 files changed
Lines changed: 16 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | | - | |
17 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments