From: Jérôme Benoit Date: Fri, 22 Sep 2023 16:12:08 +0000 (+0200) Subject: refactor: move benchmark vs external pools into its own repo X-Git-Tag: v2.7.2~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2b74d91aac700f35b6449bcfebcd11ea7ce42782;p=poolifier.git refactor: move benchmark vs external pools into its own repo Signed-off-by: Jérôme Benoit --- diff --git a/.eslintrc.js b/.eslintrc.js index 4f57c1e2..c1ed3c71 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -166,19 +166,6 @@ module.exports = defineConfig({ 'jsdoc/require-jsdoc': 'off' } }, - { - files: ['benchmarks/versus-external-pools/**/*.js'], - rules: { - 'n/no-missing-require': 'off' - } - }, - { - files: ['benchmarks/versus-external-pools/**/*.mjs'], - rules: { - 'n/no-missing-import': 'off', - 'import/no-unresolved': 'off' - } - }, { files: ['examples/javascript/**/*.js'], rules: { diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2c346ebc..b1d16022 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -20,17 +20,6 @@ updates: - 'pioardi' - 'jerome-benoit' versioning-strategy: increase - - package-ecosystem: 'npm' - directory: '/benchmarks/versus-external-pools' - schedule: - interval: 'daily' - labels: - - 'dependencies' - - 'benchmarks' - reviewers: - - 'pioardi' - - 'jerome-benoit' - versioning-strategy: increase - package-ecosystem: 'npm' directory: '/examples/typescript/http-client-pool' schedule: diff --git a/.github/workflows/external-benchmark.yml b/.github/workflows/external-benchmark.yml deleted file mode 100644 index bc64f897..00000000 --- a/.github/workflows/external-benchmark.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: External benchmark - -on: - workflow_dispatch: - schedule: - - cron: '0 3 * * *' - -jobs: - external-benchmark: - if: github.repository == 'poolifier/poolifier' - runs-on: [self-hosted, external-benchmark] - defaults: - run: - working-directory: benchmarks/versus-external-pools - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - with: - version: 8 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.x' - cache: 'pnpm' - - name: Install dependencies - run: pnpm install --ignore-scripts - - name: Run benchmark - uses: blacha/hyperfine-action@v1 - with: - benchmark-config: '.hyperfine.json' - count: 500 - benchmark-branch: 'gh-pages' - benchmark-output: './benchmarks.json' - benchmark-html: './benchmarks.html' - master-branch: 'master' - github-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Run benchmark - # if: github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' - # run: ./bench.sh - # - name: Commit files - # if: github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' - # env: - # COMMIT_MESSAGE: 'docs: update benchmark versus external pools results' - # COMMIT_AUTHOR: Benchmark Bot - # COMMIT_EMAIL: benchmark-bot@users.noreply.github.com - # run: | - # git config --local user.name "${{ env.COMMIT_AUTHOR }}" - # git config --local user.email "${{ env.COMMIT_EMAIL }}" - # git pull - # git add ./BENCH-100000.md ./BENCH-100000.json - # git commit -a -m "${{ env.COMMIT_MESSAGE }}" - # - name: Push changes - # if: github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' - # uses: CasperWA/push-protected@v2 - # with: - # token: ${{ secrets.GH_TOKEN_PROTECTED }} - # branch: ${{ github.event.repository.default_branch }} diff --git a/.prettierignore b/.prettierignore index e1d4787d..cc503c8c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ .nyc_output/ -benchmarks/versus-external-pools/BENCH-100000.* coverage/ docs/**/*.css docs/**/*.html diff --git a/benchmarks/README.md b/benchmarks/README.md index f0788a4f..602b9e91 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -1,13 +1,12 @@ -# Poolifier Benchmarks +# Poolifier benchmarks Welcome to poolifier benchmarks and thanks to look into this project. ## Folder Structure -The [internal](./internal) folder contains poolifier internal benchmark. -The [versus-external-pools](./versus-external-pools) folder contains benchmark versus other Node.js pools. +The [internal](./internal) folder contains poolifier internal benchmark. -## Poolifier vs other pools benchmark +## Poolifier benchmark versus other worker pools To compare poolifier pools performance vs other pools performance we chose to use [hyperfine](https://github.com/sharkdp/hyperfine). We chose to use this tool because it allows to run isolated Node.js processes so each pool does not impact each other. @@ -23,7 +22,7 @@ We chose to use this tool because it allows to run isolated Node.js processes so Those are our results: - - CPU Intensive task with 100k operations submitted to each pool: [BENCH-100000.md](./versus-external-pools/BENCH-100000.md). + - CPU Intensive task with 100k operations submitted to each pool: [BENCH-100000.md](https://github.com/poolifier/benchmark/BENCH-100000.md). - External pools with which we used to compare the poolifier results: @@ -36,7 +35,7 @@ We chose to use this tool because it allows to run isolated Node.js processes so > :warning: **We would need funds to run our benchmark more often and on Cloud VMs, please consider to sponsor this project** -Read the [README.md](./versus-external-pools/README.md) to know how to run the benchmark. +Read the [README.md](https://github.com/poolifier/benchmark#README.md) to know how to run the benchmark. ## Poolifier internal benchmark diff --git a/benchmarks/versus-external-pools/.hyperfine.json b/benchmarks/versus-external-pools/.hyperfine.json deleted file mode 100644 index 4a4453ee..00000000 --- a/benchmarks/versus-external-pools/.hyperfine.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { "name": "Poolifier dynamic", "command": "node dynamic-poolifier.mjs" }, - { "name": "Poolifier fixed", "command": "node fixed-poolifier.mjs" }, - { "name": "Piscina dynamic", "command": "node dynamic-piscina.mjs" }, - { "name": "Piscina fixed", "command": "node fixed-piscina.mjs" }, - { "name": "Tinypool dynamic", "command": "node dynamic-tinypool.mjs" }, - { "name": "Tinypool fixed", "command": "node fixed-tinypool.mjs" }, - { "name": "Workerpool dynamic", "command": "node dynamic-workerpool.mjs" }, - { "name": "Workerpool fixed", "command": "node fixed-workerpool.mjs" }, - { "name": "Worker nodes dynamic", "command": "node dynamic-worker-nodes.js" }, - { "name": "Worker nodes fixed", "command": "node fixed-worker-nodes.js" }, - { - "name": "Node worker threads pool dynamic", - "command": "node dynamic-node-worker-threads-pool.mjs" - }, - { - "name": "Node worker threads pool static", - "command": "node static-node-worker-threads-pool.mjs" - }, - { "name": "Nanothreads fixed", "command": "node fixed-nanothreads.mjs" } -] diff --git a/benchmarks/versus-external-pools/BENCH-100000.json b/benchmarks/versus-external-pools/BENCH-100000.json deleted file mode 100644 index f529ffee..00000000 --- a/benchmarks/versus-external-pools/BENCH-100000.json +++ /dev/null @@ -1,706 +0,0 @@ -{ - "results": [ - { - "command": "node dynamic-poolifier.mjs", - "mean": 11.55075054077, - "stddev": 0.20784293767846143, - "median": 11.54467570412, - "user": 84.0660399, - "system": 0.5622882199999999, - "min": 11.208749281620001, - "max": 12.25473233162, - "times": [ - 11.49684047062, - 11.56312437962, - 11.208749281620001, - 11.67328100762, - 12.25473233162, - 11.54428540062, - 11.46021319862, - 11.44752011262, - 11.59018277462, - 11.628013105620001, - 11.44637723462, - 11.649140772620001, - 11.60700196362, - 11.28643609162, - 11.581596236620001, - 11.545066007620001, - 11.69568724462, - 11.49889742162, - 11.49206031562, - 11.34580546362 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node fixed-poolifier.mjs", - "mean": 11.613179987920002, - "stddev": 0.26505522925356295, - "median": 11.55083026362, - "user": 84.7942242, - "system": 0.55555797, - "min": 11.29344093662, - "max": 12.12779164362, - "times": [ - 12.00907242062, - 11.36196327262, - 11.53659212462, - 11.59175335362, - 11.63676922962, - 11.51177642162, - 11.56506840262, - 11.375838938620001, - 12.06459027962, - 11.67329544262, - 11.430171919620001, - 12.00614824362, - 11.44961893662, - 11.32179300862, - 11.29344093662, - 11.64870515262, - 11.31450366462, - 12.12779164362, - 11.85632421162, - 11.48838215462 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node dynamic-piscina.mjs", - "mean": 13.973407722470004, - "stddev": 0.12606064145604856, - "median": 13.96243489162, - "user": 83.8592749, - "system": 0.8513755699999999, - "min": 13.818597114620001, - "max": 14.19692715462, - "times": [ - 14.06185216562, - 13.92105195962, - 14.06125208562, - 13.818597114620001, - 13.847389768620001, - 14.04154631562, - 13.83880104562, - 13.83042812062, - 14.19692715462, - 13.835554932620001, - 14.07950664062, - 14.19050766862, - 13.843402922620001, - 13.889904660620001, - 14.00672743562, - 14.10822115462, - 13.91654367762, - 14.10098146662, - 14.00381782362, - 13.875140335620001 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node fixed-piscina.mjs", - "mean": 14.053764739920002, - "stddev": 0.23959786134968566, - "median": 13.95764937112, - "user": 84.02636405, - "system": 0.87365207, - "min": 13.85794257062, - "max": 14.72543876362, - "times": [ - 14.038924638620001, - 14.05329965862, - 13.93005735762, - 14.523645955620001, - 14.31483429462, - 13.96267422562, - 14.00971030162, - 13.88331723162, - 13.879136070620001, - 13.92886326862, - 13.947792811620001, - 14.06202611762, - 13.923721671620001, - 13.85794257062, - 14.36705413962, - 13.86885786562, - 13.86680788262, - 13.97856545562, - 13.95262451662, - 14.72543876362 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node dynamic-tinypool.mjs", - "mean": 14.192497767819997, - "stddev": 0.19898661212872024, - "median": 14.11589190162, - "user": 84.1778193, - "system": 1.7365379699999999, - "min": 13.94773604262, - "max": 14.80781905662, - "times": [ - 14.20720532062, - 14.04648268462, - 14.104579256620001, - 14.04690160262, - 14.01935088262, - 14.058559025620001, - 13.94773604262, - 14.094982635620001, - 14.24299566062, - 14.06452185362, - 14.322297324620001, - 14.12720454662, - 14.80781905662, - 14.46353298062, - 14.22939591562, - 14.28063325362, - 14.37698363062, - 14.08703260862, - 14.02650351062, - 14.29523756362 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node fixed-tinypool.mjs", - "mean": 14.09691643987, - "stddev": 0.1504750906527409, - "median": 14.04235217862, - "user": 84.05017995, - "system": 1.7184885700000003, - "min": 13.94850102362, - "max": 14.62660283162, - "times": [ - 14.04177983062, - 14.08265744262, - 14.04292452662, - 14.04115693162, - 14.62660283162, - 14.20428710862, - 14.03022654662, - 14.10612761262, - 13.97973396762, - 14.15177939462, - 14.11761993362, - 14.024605341620001, - 14.161442815620001, - 14.02377354362, - 13.989944769620001, - 14.16264722262, - 13.98007053662, - 13.94850102362, - 14.253614819620001, - 13.96883259762 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node dynamic-workerpool.mjs", - "mean": 14.67497597497, - "stddev": 0.1370350339095064, - "median": 14.65934658912, - "user": 86.53396505, - "system": 1.2622574700000002, - "min": 14.52780176562, - "max": 15.14487437562, - "times": [ - 14.66725246662, - 14.799724129620001, - 14.68276268462, - 14.65987088462, - 14.72250008262, - 14.52780176562, - 14.64081424762, - 14.553551029620001, - 14.54776240462, - 14.558504302620001, - 14.77122116262, - 14.59935780662, - 15.14487437562, - 14.750654324620001, - 14.591429702620001, - 14.56554472262, - 14.60317633562, - 14.72992723562, - 14.65882229362, - 14.72396754162 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node fixed-workerpool.mjs", - "mean": 14.69457236522, - "stddev": 0.1232975199525343, - "median": 14.66410519462, - "user": 86.51533105000001, - "system": 1.2781065699999998, - "min": 14.550273241620001, - "max": 15.00217120962, - "times": [ - 14.76833047162, - 14.62487165762, - 14.550273241620001, - 14.760369668620001, - 14.78581828762, - 14.856696578620001, - 14.76110289762, - 14.64749807662, - 14.59037134662, - 14.86512815562, - 14.72713868462, - 14.58603997362, - 15.00217120962, - 14.61677551462, - 14.57624728462, - 14.75706327362, - 14.57927932762, - 14.58032688562, - 14.68071231262, - 14.57523245562 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node dynamic-worker-nodes.js", - "mean": 14.048048310819999, - "stddev": 0.14723886254177104, - "median": 14.025298082119999, - "user": 84.35732225, - "system": 0.9675568199999999, - "min": 13.838983238620001, - "max": 14.40751339162, - "times": [ - 13.98548984062, - 14.08970463962, - 13.87836158462, - 13.99712773862, - 14.07679108862, - 13.939836404620001, - 13.838983238620001, - 13.85229790262, - 14.064703445620001, - 14.200368300620001, - 13.898175762620001, - 14.02633352062, - 14.40751339162, - 14.190043108620001, - 14.207460342620001, - 14.02383271262, - 14.18817273162, - 14.02426264362, - 14.173625984620001, - 13.89788183362 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node fixed-worker-nodes.js", - "mean": 13.996590398470001, - "stddev": 0.16909745188188294, - "median": 13.994809645620002, - "user": 84.36044275, - "system": 0.9485802700000001, - "min": 13.761760496620001, - "max": 14.53081241762, - "times": [ - 13.86936892962, - 13.90594915762, - 14.13784491862, - 13.826044532620001, - 13.98525799662, - 14.53081241762, - 14.04641502362, - 14.07292816162, - 13.99386185962, - 13.80695795762, - 14.095169697620001, - 13.995757431620001, - 13.89231966062, - 14.131793033620001, - 13.908948240620001, - 14.07733845862, - 14.01897876262, - 14.047289388620001, - 13.827011843620001, - 13.761760496620001 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node dynamic-node-worker-threads-pool.mjs", - "mean": 21.97662583142, - "stddev": 0.6672546633141192, - "median": 21.82985098262, - "user": 131.04691445000003, - "system": 3.0887052199999996, - "min": 21.28345642562, - "max": 24.28272923262, - "times": [ - 21.50610942462, - 21.804103540619998, - 21.536169493619997, - 21.87821395962, - 21.595659144619997, - 21.36212944262, - 21.28345642562, - 21.88421341662, - 21.73865415062, - 22.431645293619997, - 21.41537478462, - 21.85559842462, - 21.99412199862, - 21.74829523262, - 21.54830455862, - 22.52473501362, - 22.48596393662, - 22.190858179619998, - 22.46618097462, - 24.28272923262 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node static-node-worker-threads-pool.mjs", - "mean": 14.306202341619999, - "stddev": 0.2632666059144555, - "median": 14.21780076962, - "user": 85.15384659999998, - "system": 1.07572542, - "min": 14.08138596362, - "max": 15.22225964962, - "times": [ - 14.16626518162, - 14.14619240662, - 14.36406147262, - 14.289970632620001, - 14.14798653062, - 15.22225964962, - 14.167416942620001, - 14.11097538862, - 14.29138366262, - 14.16712937262, - 14.19873346362, - 14.32046836662, - 14.69497677562, - 14.39514647662, - 14.54020019162, - 14.23686807562, - 14.08138596362, - 14.12801243562, - 14.19700797862, - 14.25760586462 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - }, - { - "command": "node fixed-nanothreads.mjs", - "mean": 13.275570773070001, - "stddev": 0.17261045049305512, - "median": 13.20598138862, - "user": 82.18376609999999, - "system": 0.8734752699999998, - "min": 13.09431488162, - "max": 13.69663597462, - "times": [ - 13.12369985862, - 13.43738152862, - 13.23992474462, - 13.09431488162, - 13.40385113962, - 13.69663597462, - 13.58119932362, - 13.17113666662, - 13.26585302162, - 13.17042117862, - 13.09451195862, - 13.485352284620001, - 13.20894043762, - 13.19463970562, - 13.43447609162, - 13.158138580620001, - 13.13018234862, - 13.28430560562, - 13.20302233962, - 13.13342779062 - ], - "exit_codes": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - } - ] -} diff --git a/benchmarks/versus-external-pools/BENCH-100000.md b/benchmarks/versus-external-pools/BENCH-100000.md deleted file mode 100644 index 4aadc325..00000000 --- a/benchmarks/versus-external-pools/BENCH-100000.md +++ /dev/null @@ -1,15 +0,0 @@ -| Command | Mean [s] | Min [s] | Max [s] | Relative | -|:---|---:|---:|---:|---:| -| `node dynamic-poolifier.mjs` | 11.551 ± 0.208 | 11.209 | 12.255 | 1.00 | -| `node fixed-poolifier.mjs` | 11.613 ± 0.265 | 11.293 | 12.128 | 1.01 ± 0.03 | -| `node dynamic-piscina.mjs` | 13.973 ± 0.126 | 13.819 | 14.197 | 1.21 ± 0.02 | -| `node fixed-piscina.mjs` | 14.054 ± 0.240 | 13.858 | 14.725 | 1.22 ± 0.03 | -| `node dynamic-tinypool.mjs` | 14.192 ± 0.199 | 13.948 | 14.808 | 1.23 ± 0.03 | -| `node fixed-tinypool.mjs` | 14.097 ± 0.150 | 13.949 | 14.627 | 1.22 ± 0.03 | -| `node dynamic-workerpool.mjs` | 14.675 ± 0.137 | 14.528 | 15.145 | 1.27 ± 0.03 | -| `node fixed-workerpool.mjs` | 14.695 ± 0.123 | 14.550 | 15.002 | 1.27 ± 0.03 | -| `node dynamic-worker-nodes.js` | 14.048 ± 0.147 | 13.839 | 14.408 | 1.22 ± 0.03 | -| `node fixed-worker-nodes.js` | 13.997 ± 0.169 | 13.762 | 14.531 | 1.21 ± 0.03 | -| `node dynamic-node-worker-threads-pool.mjs` | 21.977 ± 0.667 | 21.283 | 24.283 | 1.90 ± 0.07 | -| `node static-node-worker-threads-pool.mjs` | 14.306 ± 0.263 | 14.081 | 15.222 | 1.24 ± 0.03 | -| `node fixed-nanothreads.mjs` | 13.276 ± 0.173 | 13.094 | 13.697 | 1.15 ± 0.03 | diff --git a/benchmarks/versus-external-pools/README.md b/benchmarks/versus-external-pools/README.md deleted file mode 100644 index 1511dcd4..00000000 --- a/benchmarks/versus-external-pools/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Poolifier benchmarks versus other pools - -To run the benchmark versus other pools you will need to: - -- [Install hyperfine](https://github.com/sharkdp/hyperfine#installation) -- Run `pnpm install` into the `versus-external-pools` folder -- Run the `./bench.sh` script into the `versus-external-pools` folder - -> :warning: **Please be sure to use a quiet PC when you run the benchmarks** diff --git a/benchmarks/versus-external-pools/bench.sh b/benchmarks/versus-external-pools/bench.sh deleted file mode 100755 index eeefbe80..00000000 --- a/benchmarks/versus-external-pools/bench.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -usage() { - echo "Usage: $0 [-s -i -t ] [-n ]" 1>&2 - exit 1 -} - -while getopts "s:i:t:n:h" option -do - case "${option}" in - s) - poolSize=${OPTARG} - ;; - i) - iterations=${OPTARG} - ;; - t) - taskType=${OPTARG} - ;; - n) - taskSize=${OPTARG} - ;; - :) - echo "Error: Missing option argument for '-${OPTARG}'" >&2; - usage - ;; - \?) - # Invalid option - echo "Error: Unknown or invalid option for '-${OPTARG}'" >&2; - usage - ;; - *|h) - usage - ;; - esac -done - -taskType=${taskType:-'CPU_INTENSIVE'} -taskSize=${taskSize:-5000} -poolSize=${poolSize:-$(nproc --all)} -numIterations=${iterations:-100000} - -echo 'Running benchmarks with pool size:' ${poolSize}', number of iterations:' ${numIterations}', task type:' ${taskType} 'and task size:' ${taskSize} -export NODE_ENV=production -export TASK_TYPE=${taskType} -export TASK_SIZE=${taskSize} -export POOL_SIZE=${poolSize} -export NUM_ITERATIONS=${numIterations} -case "$OSTYPE" in - darwin*) - caffeinate ./hyperfine_benchmarks.sh - ;; - linux*) - systemd-inhibit --what=idle ./hyperfine_benchmarks.sh - ;; - *) - echo "Unsupported $OSTYPE" - ;; -esac diff --git a/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs b/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs deleted file mode 100644 index 7b7361d0..00000000 --- a/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import { DynamicPool } from 'node-worker-threads-pool' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' -import functionToBench from './functions/function-to-bench.js' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const dynamicPool = new DynamicPool(size) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add( - dynamicPool.exec({ - task: functionToBench, - param: data, - timeout: 60000 // this is the same as poolifier default - }) - ) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/dynamic-piscina.mjs b/benchmarks/versus-external-pools/dynamic-piscina.mjs deleted file mode 100644 index 4567714e..00000000 --- a/benchmarks/versus-external-pools/dynamic-piscina.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import Piscina from 'piscina' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const piscina = new Piscina({ - filename: './workers/piscina/function-to-bench-worker.mjs', - minThreads: Math.floor(size / 2), - maxThreads: size, - idleTimeout: 60000 // this is the same as poolifier default -}) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(piscina.run(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/dynamic-poolifier.mjs b/benchmarks/versus-external-pools/dynamic-poolifier.mjs deleted file mode 100644 index 0251de2f..00000000 --- a/benchmarks/versus-external-pools/dynamic-poolifier.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import { DynamicThreadPool } from 'poolifier' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const dynamicThreadPool = new DynamicThreadPool( - Math.floor(size / 2), - size, - './workers/poolifier/function-to-bench-worker.mjs', - { - enableTasksQueue: false - } -) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(dynamicThreadPool.execute(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/dynamic-tinypool.mjs b/benchmarks/versus-external-pools/dynamic-tinypool.mjs deleted file mode 100644 index 9043d1a0..00000000 --- a/benchmarks/versus-external-pools/dynamic-tinypool.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import Tinypool from 'tinypool' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const tinypool = new Tinypool({ - filename: './workers/tinypool/function-to-bench-worker.mjs', - minThreads: Math.floor(size / 2), - maxThreads: size, - idleTimeout: 60000 // this is the same as poolifier default -}) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(tinypool.run(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/dynamic-worker-nodes.js b/benchmarks/versus-external-pools/dynamic-worker-nodes.js deleted file mode 100644 index a67adb7f..00000000 --- a/benchmarks/versus-external-pools/dynamic-worker-nodes.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict' -const WorkerNodes = require('worker-nodes') -const { BenchmarkDefaults } = require('./utils.mjs') - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const workerNodes = new WorkerNodes( - require.resolve('./workers/worker-nodes/function-to-bench-worker'), - { - minWorkers: Math.floor(size / 2), - maxWorkers: size, - taskTimeout: 60000 // this is the same as poolifier default - } -) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(workerNodes.call.functionToBench(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -(async () => { - try { - await run() - } catch (e) { - console.error(e) - // eslint-disable-next-line n/no-process-exit - process.exit(1) - } -})() diff --git a/benchmarks/versus-external-pools/dynamic-workerpool.mjs b/benchmarks/versus-external-pools/dynamic-workerpool.mjs deleted file mode 100644 index bd68c035..00000000 --- a/benchmarks/versus-external-pools/dynamic-workerpool.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import workerpool from 'workerpool' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const dataArray = [ - 'MYBENCH', - process.env.TASK_TYPE || BenchmarkDefaults.taskType, - parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -] - -const workerPool = workerpool.pool( - './workers/workerpool/function-to-bench-worker.mjs', - { - minWorkers: Math.floor(size / 2), - maxWorkers: size, - workerType: 'thread' - } -) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(workerPool.exec('functionToBench', dataArray)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/fixed-nanothreads.mjs b/benchmarks/versus-external-pools/fixed-nanothreads.mjs deleted file mode 100644 index 3b497af5..00000000 --- a/benchmarks/versus-external-pools/fixed-nanothreads.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import { ThreadPool } from 'nanothreads' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' -import functionToBench from './functions/function-to-bench.js' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const threadPool = new ThreadPool({ - task: functionToBench, - count: size -}) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(threadPool.exec(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/fixed-piscina.mjs b/benchmarks/versus-external-pools/fixed-piscina.mjs deleted file mode 100644 index ad9b938a..00000000 --- a/benchmarks/versus-external-pools/fixed-piscina.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import Piscina from 'piscina' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const piscina = new Piscina({ - filename: './workers/piscina/function-to-bench-worker.mjs', - minThreads: size, - maxThreads: size, - idleTimeout: 60000 // this is the same as poolifier default -}) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(piscina.run(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/fixed-poolifier.mjs b/benchmarks/versus-external-pools/fixed-poolifier.mjs deleted file mode 100644 index a25b7fe4..00000000 --- a/benchmarks/versus-external-pools/fixed-poolifier.mjs +++ /dev/null @@ -1,31 +0,0 @@ -import { FixedThreadPool } from 'poolifier' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const fixedThreadPool = new FixedThreadPool( - size, - './workers/poolifier/function-to-bench-worker.mjs', - { - enableTasksQueue: false - } -) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(fixedThreadPool.execute(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/fixed-tinypool.mjs b/benchmarks/versus-external-pools/fixed-tinypool.mjs deleted file mode 100644 index 5e41d40b..00000000 --- a/benchmarks/versus-external-pools/fixed-tinypool.mjs +++ /dev/null @@ -1,30 +0,0 @@ -import Tinypool from 'tinypool' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const tinypool = new Tinypool({ - filename: './workers/tinypool/function-to-bench-worker.mjs', - minThreads: size, - maxThreads: size, - idleTimeout: 60000 // this is the same as poolifier default -}) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(tinypool.run(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/fixed-worker-nodes.js b/benchmarks/versus-external-pools/fixed-worker-nodes.js deleted file mode 100644 index 9af2936b..00000000 --- a/benchmarks/versus-external-pools/fixed-worker-nodes.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict' -const WorkerNodes = require('worker-nodes') -const { BenchmarkDefaults } = require('./utils.mjs') - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const workerNodes = new WorkerNodes( - require.resolve('./workers/worker-nodes/function-to-bench-worker'), - { - minWorkers: size, - maxWorkers: size, - taskTimeout: 60000 // this is the same as poolifier default - } -) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(workerNodes.call.functionToBench(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -(async () => { - try { - await run() - } catch (e) { - console.error(e) - // eslint-disable-next-line n/no-process-exit - process.exit(1) - } -})() diff --git a/benchmarks/versus-external-pools/fixed-workerpool.mjs b/benchmarks/versus-external-pools/fixed-workerpool.mjs deleted file mode 100644 index 6ebc0d69..00000000 --- a/benchmarks/versus-external-pools/fixed-workerpool.mjs +++ /dev/null @@ -1,32 +0,0 @@ -import workerpool from 'workerpool' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const dataArray = [ - 'MYBENCH', - process.env.TASK_TYPE || BenchmarkDefaults.taskType, - parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -] - -const workerPool = workerpool.pool( - './workers/workerpool/function-to-bench-worker.mjs', - { - minWorkers: size, - maxWorkers: size, - workerType: 'thread' - } -) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(workerPool.exec('functionToBench', dataArray)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/functions/function-to-bench.js b/benchmarks/versus-external-pools/functions/function-to-bench.js deleted file mode 100644 index ff13bc9e..00000000 --- a/benchmarks/versus-external-pools/functions/function-to-bench.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict' -/** - * The task function to execute during pools benchmarks. - * NOTE: This function requires to be self-contained, thread-safe and re-entrant (node-worker-threads-pool requirement). - * @param {*} data The worker data. - * @returns {*} The result. - */ -const functionToBench = data => { - const crypto = require('node:crypto') - const fs = require('node:fs') - const TaskTypes = { - CPU_INTENSIVE: 'CPU_INTENSIVE', - IO_INTENSIVE: 'IO_INTENSIVE' - } - data = data || {} - data.taskType = data.taskType || TaskTypes.CPU_INTENSIVE - data.taskSize = data.taskSize || 5000 - const baseDirectory = `/tmp/poolifier-benchmarks/${crypto.randomInt( - 281474976710655 - )}` - switch (data.taskType) { - case TaskTypes.CPU_INTENSIVE: - // CPU intensive task - for (let i = 0; i < data.taskSize; i++) { - const o = { - a: i - } - JSON.stringify(o) - } - return { ok: 1 } - case TaskTypes.IO_INTENSIVE: - // IO intensive task - if (fs.existsSync(baseDirectory) === true) { - fs.rmSync(baseDirectory, { recursive: true }) - } - fs.mkdirSync(baseDirectory, { recursive: true }) - for (let i = 0; i < data.taskSize; i++) { - const filePath = `${baseDirectory}/${i}` - fs.writeFileSync(filePath, i.toString(), { - encoding: 'utf8', - flag: 'a' - }) - fs.readFileSync(filePath, 'utf8') - } - fs.rmSync(baseDirectory, { recursive: true }) - return { ok: 1 } - default: - throw new Error(`Unknown task type: ${data.taskType}`) - } -} - -module.exports = functionToBench diff --git a/benchmarks/versus-external-pools/hyperfine_benchmarks.sh b/benchmarks/versus-external-pools/hyperfine_benchmarks.sh deleted file mode 100755 index 507ea91f..00000000 --- a/benchmarks/versus-external-pools/hyperfine_benchmarks.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -hyperfine --export-markdown BENCH-100000.md --export-json BENCH-100000.json --min-runs 20 --prepare 'sleep 5' --warmup 3 --show-output \ - 'node dynamic-poolifier.mjs' \ - 'node fixed-poolifier.mjs' \ - 'node dynamic-piscina.mjs' \ - 'node fixed-piscina.mjs' \ - 'node dynamic-tinypool.mjs' \ - 'node fixed-tinypool.mjs' \ - 'node dynamic-workerpool.mjs' \ - 'node fixed-workerpool.mjs' \ - 'node dynamic-worker-nodes.js' \ - 'node fixed-worker-nodes.js' \ - 'node dynamic-node-worker-threads-pool.mjs' \ - 'node static-node-worker-threads-pool.mjs' \ - 'node fixed-nanothreads.mjs' diff --git a/benchmarks/versus-external-pools/package.json b/benchmarks/versus-external-pools/package.json deleted file mode 100644 index 7675b4bf..00000000 --- a/benchmarks/versus-external-pools/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/package", - "name": "poolifier-benchmarks", - "version": "1.0.0", - "description": "This project contains benchmarks for the most used and popular Node.js worker_threads/cluster worker pools implementations", - "private": true, - "main": "index.js", - "author": "pioardi", - "engines": { - "node": ">=16.14.0", - "pnpm": ">=8.6.0" - }, - "volta": { - "node": "18.18.0", - "pnpm": "8.7.6" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { - "nanothreads": "0.3.7", - "node-worker-threads-pool": "1.5.1", - "piscina": "4.1.0", - "poolifier": "2.7.1", - "tinypool": "0.8.1", - "worker-nodes": "2.6.0", - "workerpool": "6.5.0" - } -} diff --git a/benchmarks/versus-external-pools/pnpm-lock.yaml b/benchmarks/versus-external-pools/pnpm-lock.yaml deleted file mode 100644 index f5bbef60..00000000 --- a/benchmarks/versus-external-pools/pnpm-lock.yaml +++ /dev/null @@ -1,147 +0,0 @@ -lockfileVersion: '6.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -dependencies: - nanothreads: - specifier: 0.3.7 - version: 0.3.7 - node-worker-threads-pool: - specifier: 1.5.1 - version: 1.5.1 - piscina: - specifier: 4.1.0 - version: 4.1.0 - poolifier: - specifier: 2.7.1 - version: 2.7.1 - tinypool: - specifier: 0.8.1 - version: 0.8.1 - worker-nodes: - specifier: 2.6.0 - version: 2.6.0 - workerpool: - specifier: 6.5.0 - version: 6.5.0 - -packages: - - /@assemblyscript/loader@0.10.1: - resolution: {integrity: sha512-H71nDOOL8Y7kWRLqf6Sums+01Q5msqBW2KhDUTemh1tvY04eSkSXrK0uj/4mmY0Xr16/3zyZmsrxN7CKuRbNRg==} - dev: false - - /base64-js@1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - dev: false - - /event-lite@0.1.3: - resolution: {integrity: sha512-8qz9nOz5VeD2z96elrEKD2U433+L3DWdUdDkOINLGOJvx1GsMBbMn0aCeu28y8/e85A6mCigBiFlYMnTBEGlSw==} - dev: false - - /eventemitter-asyncresource@1.0.0: - resolution: {integrity: sha512-39F7TBIV0G7gTelxwbEqnwhp90eqCPON1k0NwNfwhgKn4Co4ybUbj2pECcXT0B3ztRKZ7Pw1JujUUgmQJHcVAQ==} - dev: false - - /hdr-histogram-js@2.0.3: - resolution: {integrity: sha512-Hkn78wwzWHNCp2uarhzQ2SGFLU3JY8SBDDd3TAABK4fc30wm+MuPOrg5QVFVfkKOQd6Bfz3ukJEI+q9sXEkK1g==} - dependencies: - '@assemblyscript/loader': 0.10.1 - base64-js: 1.5.1 - pako: 1.0.11 - dev: false - - /hdr-histogram-percentiles-obj@3.0.0: - resolution: {integrity: sha512-7kIufnBqdsBGcSZLPJwqHT3yhk1QTsSlFsVD3kx5ixH/AlgBs9yM1q6DPhXZ8f8gtdqgh7N7/5btRLpQsS2gHw==} - dev: false - - /ieee754@1.2.1: - resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - dev: false - - /int64-buffer@0.1.10: - resolution: {integrity: sha512-v7cSY1J8ydZ0GyjUHqF+1bshJ6cnEVLo9EnjB8p+4HDRPZc9N5jjmvUV7NvEsqQOKyH0pmIBFWXVQbiS0+OBbA==} - dev: false - - /isarray@1.0.0: - resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} - dev: false - - /msgpack-lite@0.1.26: - resolution: {integrity: sha512-SZ2IxeqZ1oRFGo0xFGbvBJWMp3yLIY9rlIJyxy8CGrwZn1f0ZK4r6jV/AM1r0FZMDUkWkglOk/eeKIL9g77Nxw==} - hasBin: true - dependencies: - event-lite: 0.1.3 - ieee754: 1.2.1 - int64-buffer: 0.1.10 - isarray: 1.0.0 - dev: false - - /nanothreads@0.3.7: - resolution: {integrity: sha512-l/gbxnQBeMGspLoa+JKhqDrsBtqMW4G5ElsEgbVigR5gl6IBHzBjpM7URGeu0UQN4k7DK0o+J3GmHgaXv+aDQw==} - dev: false - - /nice-napi@1.0.2: - resolution: {integrity: sha512-px/KnJAJZf5RuBGcfD+Sp2pAKq0ytz8j+1NehvgIGFkvtvFrDM3T8E4x/JJODXK9WZow8RRGrbA9QQ3hs+pDhA==} - os: ['!win32'] - requiresBuild: true - dependencies: - node-addon-api: 3.2.1 - node-gyp-build: 4.6.1 - dev: false - optional: true - - /node-addon-api@3.2.1: - resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==} - requiresBuild: true - dev: false - optional: true - - /node-gyp-build@4.6.1: - resolution: {integrity: sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==} - hasBin: true - requiresBuild: true - dev: false - optional: true - - /node-worker-threads-pool@1.5.1: - resolution: {integrity: sha512-7TXAhpMm+jO4MfESxYLtMGSnJWv+itdNHMdaFmeZuPXxwFGU90mtEB42BciUULXOUAxYBfXILAuvrSG3rQZ7mw==} - dev: false - - /pako@1.0.11: - resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} - dev: false - - /piscina@4.1.0: - resolution: {integrity: sha512-sjbLMi3sokkie+qmtZpkfMCUJTpbxJm/wvaPzU28vmYSsTSW8xk9JcFUsbqGJdtPpIQ9tuj+iDcTtgZjwnOSig==} - dependencies: - eventemitter-asyncresource: 1.0.0 - hdr-histogram-js: 2.0.3 - hdr-histogram-percentiles-obj: 3.0.0 - optionalDependencies: - nice-napi: 1.0.2 - dev: false - - /poolifier@2.7.1: - resolution: {integrity: sha512-GUo7sdUMvHyjMGHE5oMmmzlBYTASMQGznS6Nohl5eVsuLCZTIM5UyozRH47WYMAk9cqzEeoVzKKWpsQes/pCtg==} - engines: {node: '>=16.14.0', pnpm: '>=8.6.0'} - requiresBuild: true - dev: false - - /tinypool@0.8.1: - resolution: {integrity: sha512-zBTCK0cCgRROxvs9c0CGK838sPkeokNGdQVUUwHAbynHFlmyJYj825f/oRs528HaIJ97lo0pLIlDUzwN+IorWg==} - engines: {node: '>=14.0.0'} - dev: false - - /worker-nodes@2.6.0: - resolution: {integrity: sha512-mL4PR1fktwqYQFfzsH613MdHcfi9GeXuwvl2lWIrNvr3JMmrtBBfbbhc/qSK3oZDAQ2gTd7qZbAJktto+3ZeFw==} - engines: {node: '>=11.7.0'} - dependencies: - msgpack-lite: 0.1.26 - dev: false - - /workerpool@6.5.0: - resolution: {integrity: sha512-r64Ea3glXY2RVzMeNxB+4J+0YHAVzUdV4cM5nHi4BBC2LvnO1pWFAIYKYuGcPElbg1/7eEiaPtZ/jzCjIUuGBg==} - dev: false diff --git a/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs b/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs deleted file mode 100644 index 0868d26c..00000000 --- a/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import { StaticPool } from 'node-worker-threads-pool' -import { BenchmarkDefaults, executeAsyncFn } from './utils.mjs' -import functionToBench from './functions/function-to-bench.js' - -const size = parseInt(process.env.POOL_SIZE) || BenchmarkDefaults.poolSize -const numIterations = - parseInt(process.env.NUM_ITERATIONS) || BenchmarkDefaults.numIterations -const data = { - test: 'MYBENCH', - taskType: process.env.TASK_TYPE || BenchmarkDefaults.taskType, - taskSize: parseInt(process.env.TASK_SIZE) || BenchmarkDefaults.taskSize -} - -const staticPool = new StaticPool({ - size, - task: functionToBench -}) - -async function run () { - const promises = new Set() - for (let i = 0; i < numIterations; i++) { - promises.add(staticPool.exec(data)) - } - await Promise.all(promises) - // eslint-disable-next-line n/no-process-exit - process.exit() -} - -await executeAsyncFn(run) diff --git a/benchmarks/versus-external-pools/utils.mjs b/benchmarks/versus-external-pools/utils.mjs deleted file mode 100644 index 8d58ded7..00000000 --- a/benchmarks/versus-external-pools/utils.mjs +++ /dev/null @@ -1,18 +0,0 @@ -import { availableParallelism } from 'poolifier' - -export const executeAsyncFn = async fn => { - try { - await fn() - } catch (e) { - console.error(e) - // eslint-disable-next-line n/no-process-exit - process.exit(1) - } -} - -export const BenchmarkDefaults = { - poolSize: availableParallelism(), - numIterations: 100000, - taskType: 'CPU_INTENSIVE', - taskSize: 5000 -} diff --git a/benchmarks/versus-external-pools/workers/piscina/function-to-bench-worker.mjs b/benchmarks/versus-external-pools/workers/piscina/function-to-bench-worker.mjs deleted file mode 100644 index 41f6fd79..00000000 --- a/benchmarks/versus-external-pools/workers/piscina/function-to-bench-worker.mjs +++ /dev/null @@ -1,2 +0,0 @@ -import functionToBench from '../../functions/function-to-bench.js' -export default functionToBench diff --git a/benchmarks/versus-external-pools/workers/poolifier/function-to-bench-worker.mjs b/benchmarks/versus-external-pools/workers/poolifier/function-to-bench-worker.mjs deleted file mode 100644 index 3b058629..00000000 --- a/benchmarks/versus-external-pools/workers/poolifier/function-to-bench-worker.mjs +++ /dev/null @@ -1,3 +0,0 @@ -import { ThreadWorker } from 'poolifier' -import functionToBench from '../../functions/function-to-bench.js' -export default new ThreadWorker(functionToBench) diff --git a/benchmarks/versus-external-pools/workers/tinypool/function-to-bench-worker.mjs b/benchmarks/versus-external-pools/workers/tinypool/function-to-bench-worker.mjs deleted file mode 100644 index 41f6fd79..00000000 --- a/benchmarks/versus-external-pools/workers/tinypool/function-to-bench-worker.mjs +++ /dev/null @@ -1,2 +0,0 @@ -import functionToBench from '../../functions/function-to-bench.js' -export default functionToBench diff --git a/benchmarks/versus-external-pools/workers/worker-nodes/function-to-bench-worker.js b/benchmarks/versus-external-pools/workers/worker-nodes/function-to-bench-worker.js deleted file mode 100644 index b9a9ea26..00000000 --- a/benchmarks/versus-external-pools/workers/worker-nodes/function-to-bench-worker.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict' -const functionToBench = require('../../functions/function-to-bench') -module.exports = { functionToBench } diff --git a/benchmarks/versus-external-pools/workers/workerpool/function-to-bench-worker.mjs b/benchmarks/versus-external-pools/workers/workerpool/function-to-bench-worker.mjs deleted file mode 100644 index 8515b1dc..00000000 --- a/benchmarks/versus-external-pools/workers/workerpool/function-to-bench-worker.mjs +++ /dev/null @@ -1,14 +0,0 @@ -import workerpool from 'workerpool' -import functionToBench from '../../functions/function-to-bench.js' - -const functionToBenchWrapper = (testName, taskType, taskSize) => { - return functionToBench({ - test: testName, - taskType, - taskSize - }) -} - -workerpool.worker({ - functionToBench: functionToBenchWrapper -}) diff --git a/biome.json b/biome.json index 776ee217..a30cbdd7 100644 --- a/biome.json +++ b/biome.json @@ -30,7 +30,6 @@ "files": { "ignore": [ ".nyc_output/", - "benchmarks/versus-external-pools/BENCH-100000.*", "coverage/", "docs/**/*.css", "docs/**/*.html",