-
Notifications
You must be signed in to change notification settings - Fork 3
Experiment with concurrency levels #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adespawn
wants to merge
4
commits into
scylladb:main
Choose a base branch
from
adespawn:experiment-with-concurrency-levels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,41 @@ | ||
| "use strict"; | ||
| const async = require("async"); | ||
| // Possible values of argv[2] (driver) are scylladb-driver-alpha and cassandra-driver. | ||
| const cassandra = require(process.argv[2]); | ||
| const utils = require("./utils"); | ||
| const { exit } = require("process"); | ||
| const assert = require("assert"); | ||
|
|
||
| const client = new cassandra.Client(utils.getClientArgs()); | ||
| const iterCnt = parseInt(process.argv[3]); | ||
| // Expectantly determined max batch size, that doesn't cause database error. | ||
| const step = 3971; | ||
| module.exports = function (cassandra, client, stepCount, _concurrencyLevel) { | ||
| // REMEMBER: update benchmark config.yml when changing the constant value. | ||
| const iterCnt = stepCount || 3000000; | ||
| // Experimentally determined max batch size that doesn't cause database error. | ||
| const batchSize = 3971; | ||
|
|
||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaBasic, next); | ||
| }, | ||
| async function insert(next) { | ||
| // Limit batch size to step size | ||
| for (let z = 0; z * step < iterCnt; z++) { | ||
| let queries = []; | ||
| for (let i = 0; i < Math.min(iterCnt - (z * step), step); i++) { | ||
| queries.push({ | ||
| query: 'INSERT INTO benchmarks.basic (id, val) VALUES (?, ?)', | ||
| params: [cassandra.types.Uuid.random(), 10] | ||
| }); | ||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaBasic, next); | ||
| }, | ||
| async function insert(next) { | ||
| for (let z = 0; z * batchSize < iterCnt; z++) { | ||
| let queries = []; | ||
| for (let i = 0; i < Math.min(iterCnt - (z * batchSize), batchSize); i++) { | ||
| queries.push({ | ||
| query: 'INSERT INTO benchmarks.basic (id, val) VALUES (?, ?)', | ||
| params: [cassandra.types.Uuid.random(), 10] | ||
| }); | ||
| } | ||
| try { | ||
| await client.batch(queries, { prepare: true }); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| } | ||
| try { | ||
| await client.batch(queries, { prepare: true }); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| } | ||
| next(); | ||
| }, | ||
| async function test(next) { | ||
| const query = "SELECT COUNT(1) FROM benchmarks.basic USING TIMEOUT 120s;"; | ||
| try { | ||
| let res = await client.execute(query); | ||
| assert(res.rows[0].count == iterCnt); | ||
| } catch (err) { | ||
| return next(err); | ||
| next(); | ||
| }, | ||
| async function test(next) { | ||
| utils.checkRowCount(client, iterCnt, next); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| next(); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| ], utils.onError); | ||
| ], utils.onError); | ||
| }; | ||
adespawn marked this conversation as resolved.
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Single entry point for all benchmarks. | ||
| // This file takes the name of the benchmark, including driver name, step count and concurrency level | ||
| // and runs the corresponding benchmark logic, loaded at runtime. | ||
|
|
||
| "use strict"; | ||
| const { exit } = require("process"); | ||
| const utils = require("./utils"); | ||
|
|
||
| const defaultConcurrencyLevel = 100; | ||
|
|
||
| const driverName = process.argv[2]; | ||
| const benchmarkName = process.argv[3]; | ||
| // Each individual benchmark has a default step count defined. | ||
| // See the explanation in config.yml for more details. | ||
| const stepCount = process.argv[4] !== "default" ? parseInt(process.argv[4], 10) : undefined; | ||
| const concurrencyLevel = process.argv[5] !== "default" ? parseInt(process.argv[5], 10) : defaultConcurrencyLevel; | ||
|
|
||
| if (!driverName || !benchmarkName) { | ||
| console.error("Usage: node benchmark.js <driver> <benchmark-name> [step-count] [concurrency]"); | ||
| exit(1); | ||
| } | ||
|
|
||
| const cassandra = require(driverName); | ||
| const client = new cassandra.Client(utils.getClientArgs()); | ||
|
|
||
| const benchmark = require(`./${benchmarkName}`); | ||
| benchmark(cassandra, client, stepCount, concurrencyLevel); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,51 @@ | ||
| "use strict"; | ||
| const async = require("async"); | ||
| // Possible values of argv[2] (driver) are scylladb-driver-alpha and cassandra-driver. | ||
| const cassandra = require(process.argv[2]); | ||
| const utils = require("./utils"); | ||
| const { exit } = require("process"); | ||
| const assert = require("assert"); | ||
|
|
||
| const client = new cassandra.Client(utils.getClientArgs()); | ||
| const iterCnt = parseInt(process.argv[3]); | ||
| module.exports = function (cassandra, client, stepCount, concurrencyLevel) { | ||
| // REMEMBER: update benchmark config.yml when changing the constant value. | ||
| const iterCnt = stepCount || 2000; | ||
|
|
||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaDeSer, next); | ||
| }, | ||
| async function insert(next) { | ||
| let allParameters = utils.insertConcurrentDeSer(cassandra, iterCnt); | ||
| try { | ||
| const _result = await cassandra.concurrent.executeConcurrent(client, allParameters, { prepare: true }); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| next(); | ||
| }, | ||
| async function select(next) { | ||
| let remaining = iterCnt; | ||
| while (remaining > 0) { | ||
| let currentStep = Math.min(remaining, 500); | ||
| remaining -= currentStep; | ||
| let allParameters = []; | ||
| for (let i = 0; i < currentStep; i++) { | ||
| allParameters.push({ | ||
| query: 'SELECT * FROM benchmarks.basic', | ||
| }); | ||
| } | ||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaDeSer, next); | ||
| }, | ||
| async function insert(next) { | ||
| let allParameters = utils.insertConcurrentDeSer(cassandra, iterCnt); | ||
| try { | ||
| const result = await cassandra.concurrent.executeConcurrent(client, allParameters, { prepare: true, collectResults: true }); | ||
| for (let singleResult of result.resultItems) { | ||
| assert.equal(singleResult.rowLength, iterCnt); | ||
| } | ||
| const _result = await cassandra.concurrent.executeConcurrent(client, allParameters, { prepare: true, concurrencyLevel }); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| next(); | ||
| }, | ||
| async function select(next) { | ||
| let remaining = iterCnt; | ||
| while (remaining > 0) { | ||
| let currentStep = Math.min(remaining, 500); | ||
| remaining -= currentStep; | ||
| let allParameters = []; | ||
| for (let i = 0; i < currentStep; i++) { | ||
| allParameters.push({ | ||
| query: 'SELECT * FROM benchmarks.basic', | ||
| }); | ||
| } | ||
| try { | ||
| const result = await cassandra.concurrent.executeConcurrent(client, allParameters, { prepare: true, collectResults: true, concurrencyLevel }); | ||
| for (let singleResult of result.resultItems) { | ||
| assert.equal(singleResult.rowLength, iterCnt); | ||
| } | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| } | ||
| next(); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| next(); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| ], utils.onError); | ||
|
|
||
| ], utils.onError); | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,41 @@ | ||
| "use strict"; | ||
| const async = require("async"); | ||
| // Possible values of argv[2] (driver) are scylladb-driver-alpha and cassandra-driver. | ||
| const cassandra = require(process.argv[2]); | ||
| const utils = require("./utils"); | ||
| const { exit } = require("process"); | ||
|
|
||
| const client = new cassandra.Client(utils.getClientArgs()); | ||
| const iterCnt = parseInt(process.argv[3]); | ||
| module.exports = function (cassandra, client, stepCount, concurrencyLevel) { | ||
| // REMEMBER: update benchmark config.yml when changing the constant value. | ||
| const iterCnt = stepCount || 4000000; | ||
|
|
||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaBasic, next); | ||
| }, | ||
| async function insert(next) { | ||
| let limited = async function (steps) { | ||
| let allParameters = []; | ||
| for (let i = 0; i < steps; i++) { | ||
| allParameters.push({ | ||
| query: 'INSERT INTO benchmarks.basic (id, val) VALUES (?, ?)', | ||
| params: [cassandra.types.Uuid.random(), 10] | ||
| }); | ||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaBasic, next); | ||
| }, | ||
| async function insert(next) { | ||
| let limited = async function (steps) { | ||
| let allParameters = []; | ||
| for (let i = 0; i < steps; i++) { | ||
| allParameters.push({ | ||
| query: 'INSERT INTO benchmarks.basic (id, val) VALUES (?, ?)', | ||
| params: [cassandra.types.Uuid.random(), 10] | ||
| }); | ||
| } | ||
| try { | ||
| const _result = await cassandra.concurrent.executeConcurrent(client, allParameters, { prepare: true, concurrencyLevel }); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| } | ||
| try { | ||
| const _result = await cassandra.concurrent.executeConcurrent(client, allParameters, { prepare: true }); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| } | ||
| await utils.repeatCapped(limited, iterCnt); | ||
|
|
||
| next(); | ||
| }, | ||
| async function test(next) { | ||
| utils.checkRowCount(client, iterCnt, next); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| ], utils.onError); | ||
| await utils.repeatCapped(limited, iterCnt); | ||
|
|
||
| next(); | ||
| }, | ||
| async function test(next) { | ||
| utils.checkRowCount(client, iterCnt, next); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| ], utils.onError); | ||
| }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,46 @@ | ||
| "use strict"; | ||
| const async = require("async"); | ||
| // Possible values of argv[2] (driver) are scylladb-nodejs-rs-driver and cassandra-driver. | ||
| const cassandra = require(process.argv[2]); | ||
| const utils = require("./utils"); | ||
| const { exit } = require("process"); | ||
| const { assert } = require("console"); | ||
| const assert = require("assert"); | ||
|
|
||
| const client = new cassandra.Client(utils.getClientArgs()); | ||
| const iterCnt = parseInt(process.argv[3]); | ||
| const concurrencyLevel = 20; | ||
| module.exports = function (cassandra, client, stepCount, concurrencyLevel) { | ||
| // REMEMBER: update benchmark config.yml when changing the constant value. | ||
| const iterCnt = stepCount || 1280; | ||
|
|
||
adespawn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaBasic, next); | ||
| }, | ||
| async function insert(next) { | ||
| utils.insertSimple(client, 50, next); | ||
| }, | ||
| async function select(next) { | ||
| let limited = async function (steps) { | ||
| for (let i = 0; i < steps; i++) { | ||
| try { | ||
| let s = 0; | ||
| let q = await client.execute('SELECT * FROM benchmarks.basic', [], { prepare: true, fetchSize: 1 }); | ||
| for await (const row of q) { | ||
| s += row['val']; | ||
| async.series( | ||
| [ | ||
| function initialize(next) { | ||
| utils.prepareDatabase(client, utils.tableSchemaBasic, next); | ||
| }, | ||
| async function insert(next) { | ||
| utils.insertSimple(client, 50, next); | ||
| }, | ||
| async function select(next) { | ||
| let limited = async function (steps) { | ||
| for (let i = 0; i < steps; i++) { | ||
| try { | ||
| let s = 0; | ||
| let q = await client.execute('SELECT * FROM benchmarks.basic', [], { prepare: true, fetchSize: 1 }); | ||
| for await (const row of q) { | ||
| s += row['val']; | ||
| } | ||
| assert(s === 5000); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
| assert(s === 5000); | ||
| } catch (err) { | ||
| return next(err); | ||
| } | ||
|
|
||
| } | ||
| await utils.executeMultipleRepeatCapped(limited, iterCnt, concurrencyLevel); | ||
| next(); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| ], function (err) { | ||
| if (err) { | ||
| console.error("Error: ", err.message, err.stack); | ||
| exit(1); | ||
| } | ||
| await utils.executeMultipleRepeatCapped(limited, iterCnt, concurrencyLevel); | ||
| next(); | ||
| }, | ||
| function r() { | ||
| exit(0); | ||
| } | ||
| ], function (err) { | ||
| if (err) { | ||
| console.error("Error: ", err.message, err.stack); | ||
| exit(1); | ||
| } | ||
| },); | ||
| }); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Here you use underscore in
_concurrencyLevel, and elsewhere not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In non concurrent benchmarks I ignore this parameter. For this reason I use underscore to indicate that