From: Jérôme Benoit Date: Mon, 10 Oct 2022 16:12:18 +0000 (+0200) Subject: Add WRR worker choice strategy to benchmark X-Git-Tag: v2.3.1~39 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2d401b2d21b1d9225c9168f85e32234353feb0c3;p=poolifier.git Add WRR worker choice strategy to benchmark Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/internal/bench.js b/benchmarks/internal/bench.js index e965574c..7d33fcc5 100644 --- a/benchmarks/internal/bench.js +++ b/benchmarks/internal/bench.js @@ -2,22 +2,26 @@ const Benchmark = require('benchmark') const { dynamicClusterTest, dynamicClusterTestFairShare, - dynamicClusterTestLessRecentlyUsed + dynamicClusterTestLessRecentlyUsed, + dynamicClusterTestWeightedRoundRobin } = require('./cluster/dynamic') const { fixedClusterTest, fixedClusterTestFairShare, - fixedClusterTestLessRecentlyUsed + fixedClusterTestLessRecentlyUsed, + fixedClusterTestWeightedRoundRobin } = require('./cluster/fixed') const { dynamicThreadTest, dynamicThreadTestFairShare, - dynamicThreadTestLessRecentlyUsed + dynamicThreadTestLessRecentlyUsed, + dynamicThreadTestWeightedRoundRobin } = require('./thread/dynamic') const { fixedThreadTest, fixedThreadTestFairShare, - fixedThreadTestLessRecentlyUsed + fixedThreadTestLessRecentlyUsed, + fixedThreadTestWeightedRoundRobin } = require('./thread/fixed') const { LIST_FORMATTER } = require('./benchmark-utils') @@ -37,6 +41,9 @@ async function test () { .add('Poolifier:Fixed:ThreadPool:LessRecentlyUsed', async function () { await fixedThreadTestLessRecentlyUsed() }) + .add('Poolifier:Fixed:ThreadPool:WeightedRoundRobin', async function () { + await fixedThreadTestWeightedRoundRobin() + }) .add('Poolifier:Fixed:ThreadPool:FairShare', async function () { await fixedThreadTestFairShare() }) @@ -46,6 +53,9 @@ async function test () { .add('Poolifier:Dynamic:ThreadPool:LessRecentlyUsed', async function () { await dynamicThreadTestLessRecentlyUsed() }) + .add('Poolifier:Dynamic:ThreadPool:WeightedRoundRobin', async function () { + await dynamicThreadTestWeightedRoundRobin() + }) .add('Poolifier:Dynamic:ThreadPool:FairShare', async function () { await dynamicThreadTestFairShare() }) @@ -55,6 +65,9 @@ async function test () { .add('Poolifier:Fixed:ClusterPool:LessRecentlyUsed', async function () { await fixedClusterTestLessRecentlyUsed() }) + .add('Poolifier:Fixed:ClusterPool:WeightedRoundRobin', async function () { + await fixedClusterTestWeightedRoundRobin + }) .add('Poolifier:Fixed:ClusterPool:FairShare', async function () { await fixedClusterTestFairShare() }) @@ -64,6 +77,9 @@ async function test () { .add('Poolifier:Dynamic:ClusterPool:LessRecentlyUsed', async function () { await dynamicClusterTestLessRecentlyUsed() }) + .add('Poolifier:Dynamic:ClusterPool:WeightedRoundRobin', async function () { + await dynamicClusterTestWeightedRoundRobin + }) .add('Poolifier:Dynamic:ClusterPool:FairShare', async function () { await dynamicClusterTestFairShare() }) diff --git a/benchmarks/internal/cluster/dynamic.js b/benchmarks/internal/cluster/dynamic.js index 581bf4ac..dc0f7cf3 100644 --- a/benchmarks/internal/cluster/dynamic.js +++ b/benchmarks/internal/cluster/dynamic.js @@ -20,6 +20,13 @@ const dynamicPoolLessRecentlyUsed = new DynamicClusterPool( { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } ) +const dynamicPoolWeightedRoundRobin = new DynamicClusterPool( + size / 2, + size * 3, + './benchmarks/internal/cluster/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN } +) + const dynamicPoolFairShare = new DynamicClusterPool( size / 2, size * 3, @@ -39,6 +46,12 @@ async function dynamicClusterTestLessRecentlyUsed ( return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData }) } +async function dynamicClusterTestWeightedRoundRobin ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(dynamicPoolWeightedRoundRobin, { tasks, workerData }) +} + async function dynamicClusterTestFairShare ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { @@ -47,6 +60,7 @@ async function dynamicClusterTestFairShare ( module.exports = { dynamicClusterTest, - dynamicClusterTestFairShare, - dynamicClusterTestLessRecentlyUsed + dynamicClusterTestLessRecentlyUsed, + dynamicClusterTestWeightedRoundRobin, + dynamicClusterTestFairShare } diff --git a/benchmarks/internal/cluster/fixed.js b/benchmarks/internal/cluster/fixed.js index 548ed9f9..388689a3 100644 --- a/benchmarks/internal/cluster/fixed.js +++ b/benchmarks/internal/cluster/fixed.js @@ -18,6 +18,12 @@ const fixedPoolLessRecentlyUsed = new FixedClusterPool( { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } ) +const fixedPoolWeightedRoundRobin = new FixedClusterPool( + size, + './benchmarks/internal/cluster/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN } +) + const fixedPoolFairShare = new FixedClusterPool( size, './benchmarks/internal/cluster/worker.js', @@ -36,6 +42,12 @@ async function fixedClusterTestLessRecentlyUsed ( return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) } +async function fixedClusterTestWeightedRoundRobin ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData }) +} + async function fixedClusterTestFairShare ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { @@ -44,6 +56,7 @@ async function fixedClusterTestFairShare ( module.exports = { fixedClusterTest, - fixedClusterTestFairShare, - fixedClusterTestLessRecentlyUsed + fixedClusterTestLessRecentlyUsed, + fixedClusterTestWeightedRoundRobin, + fixedClusterTestFairShare } diff --git a/benchmarks/internal/thread/dynamic.js b/benchmarks/internal/thread/dynamic.js index 24740f27..a4185453 100644 --- a/benchmarks/internal/thread/dynamic.js +++ b/benchmarks/internal/thread/dynamic.js @@ -20,6 +20,13 @@ const dynamicPoolLessRecentlyUsed = new DynamicThreadPool( { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } ) +const dynamicPoolWeightedRoundRobin = new DynamicThreadPool( + size / 2, + size * 3, + './benchmarks/internal/thread/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN } +) + const dynamicPoolFairShare = new DynamicThreadPool( size / 2, size * 3, @@ -39,6 +46,12 @@ async function dynamicThreadTestLessRecentlyUsed ( return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData }) } +async function dynamicThreadTestWeightedRoundRobin ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(dynamicPoolWeightedRoundRobin, { tasks, workerData }) +} + async function dynamicThreadTestFairShare ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { @@ -47,6 +60,7 @@ async function dynamicThreadTestFairShare ( module.exports = { dynamicThreadTest, - dynamicThreadTestFairShare, - dynamicThreadTestLessRecentlyUsed + dynamicThreadTestLessRecentlyUsed, + dynamicThreadTestWeightedRoundRobin, + dynamicThreadTestFairShare } diff --git a/benchmarks/internal/thread/fixed.js b/benchmarks/internal/thread/fixed.js index 1db9c0b6..37635237 100644 --- a/benchmarks/internal/thread/fixed.js +++ b/benchmarks/internal/thread/fixed.js @@ -18,6 +18,12 @@ const fixedPoolLessRecentlyUsed = new FixedThreadPool( { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } ) +const fixedPoolWeightedRoundRobin = new FixedThreadPool( + size, + './benchmarks/internal/thread/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN } +) + const fixedPoolFairShare = new FixedThreadPool( size, './benchmarks/internal/thread/worker.js', @@ -36,6 +42,12 @@ async function fixedThreadTestLessRecentlyUsed ( return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) } +async function fixedThreadTestWeightedRoundRobin ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData }) +} + async function fixedThreadTestFairShare ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { @@ -44,6 +56,7 @@ async function fixedThreadTestFairShare ( module.exports = { fixedThreadTest, - fixedThreadTestFairShare, - fixedThreadTestLessRecentlyUsed + fixedThreadTestLessRecentlyUsed, + fixedThreadTestWeightedRoundRobin, + fixedThreadTestFairShare }