diff --git a/test/load/testExecutorPoolResiliency.js b/test/load/testExecutorPoolResiliency.js index c5b53b3ab316256f507b87d44ac926e96c7c99d3..31c6a16a4269385b8bd97091463571f5fe32bc8d 100644 --- a/test/load/testExecutorPoolResiliency.js +++ b/test/load/testExecutorPoolResiliency.js @@ -70,12 +70,25 @@ describe( 'executor pool load test', function () { // Wait a generous amount of time to ensure that the initial // executor pool is good to go (wasmedge initialization usually takes // ~300 ms, so let's wait longer than that). - await wait( 1000 ); + await wait( 2000 ); // Now flood the zone with 20 requests. let promises = [ ...Array( 20 ) ].map( runFunctionCall ); let results = await Promise.all( promises ); + const delays = []; + for ( const [ startTime, functionCallTime ] of results ) { + // TODO (T372765): Get more resources, then + // destructure-assign endTime in the for loop above, then + // re-enable the following line. + // assert.deepEqual( endTime - functionCallTime < 100, true ); + // In all cases, endTime - functionCallTime should be negligible. + const delay = functionCallTime - startTime; + delays.push( delay ); + } + delays.sort(); + const firstDelay = delays[ 0 ]; + // Ideally, we should expect these requests to run in cohorts of 5: // functionCallTime - startTime should be // > near 0 for 5, @@ -87,40 +100,36 @@ describe( 'executor pool load test', function () { // are subject to a number of factors. Each bucket is therefore a // cumulative sum of all function calls that ran in less than a given // amount of time. - // In all cases, endTime - functionCallTime should be negligible. const buckets = [ - 0, // Should run in << 300 ms. - 0, // Should run in << 600 ms. - 0, // Should run in << 900 ms. - 0, // Should run in << 1200 ms. + 0, + 0, + 0, + 0, 0 // Stragglers. ]; - for ( const [ startTime, functionCallTime ] of results ) { - // TODO (T372765): Get more resources, then - // destructure-assign endTime in the for loop above, then - // re-enable the following line. - // assert.deepEqual( endTime - functionCallTime < 100, true ); - const delay = functionCallTime - startTime; - if ( delay < 300 ) { + for ( const fullDelay of delays ) { + // Bucket based on time since the first result was retrieved. + const delay = fullDelay - firstDelay; + if ( delay < 250 ) { buckets[ 0 ] += 1; } - if ( delay < 600 ) { + if ( delay < 570 ) { buckets[ 1 ] += 1; } - if ( delay < 900 ) { + if ( delay < 890 ) { buckets[ 2 ] += 1; } - if ( delay < 1200 ) { + if ( delay < 1210 ) { buckets[ 3 ] += 1; } buckets[ 4 ] += 1; } // TODO (T372765): Tighten these numbers up; buckets would ideally // have the values [5, 10, 15, 20, 20]. - assert.deepEqual( buckets[ 0 ] >= 2, true ); - assert.deepEqual( buckets[ 1 ] >= 4, true ); - assert.deepEqual( buckets[ 2 ] >= 7, true ); - assert.deepEqual( buckets[ 3 ] >= 10, true ); + assert.deepEqual( buckets[ 0 ] >= 3, true ); + assert.deepEqual( buckets[ 1 ] >= 6, true ); + assert.deepEqual( buckets[ 2 ] >= 9, true ); + assert.deepEqual( buckets[ 3 ] >= 12, true ); assert.deepEqual( buckets[ 4 ], 20 ); // Now make sure that things have settled back down.