Skip to content
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

test: add ability to test many files without transfer manager #2357

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 94 additions & 1 deletion internal-tooling/performPerformanceTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
PERFORMANCE_TEST_TYPES,
TestResult,
} from './performanceUtils.js';
import {Bucket} from '../src/index.js';
import {Bucket, File} from '../src/index.js';
import {getDirName} from '../src/util.js';

const TEST_NAME_STRING = 'nodejs-perf-metrics';
Expand Down Expand Up @@ -64,6 +64,9 @@ async function main() {
case PERFORMANCE_TEST_TYPES.RANGE_READ:
results = await performRangedReadTest();
break;
case PERFORMANCE_TEST_TYPES.MANY_SMALL:
results = await performManyFilesTest();
break;
default:
break;
}
Expand Down Expand Up @@ -214,4 +217,94 @@ async function performWriteReadTest(): Promise<TestResult[]> {
return results;
}

/**
* Performs an iteration of the many files test.
*
* @returns {Promise<TestResult[]>} Promise that resolves to an array of test results for the iteration.
*/
async function performManyFilesTest(): Promise<TestResult[]> {
const results: TestResult[] = [];
const fileSizeRange = getLowHighFileSize(argv.object_size as string);
const fileMap = new Map<string, File>();
let totalSizeInBytes = 0;

for (let i = 0; i < (argv.num_objects as number); i++) {
const fileName = generateRandomFileName(TEST_NAME_STRING);
const file = bucket.file(`${fileName}`);
totalSizeInBytes += generateRandomFile(
fileName,
fileSizeRange.low,
fileSizeRange.high,
getDirName()
);
fileMap.set(fileName, file);
}

let iterationResult: TestResult = {
op: 'WRITE',
objectSize: totalSizeInBytes,
appBufferSize: NODE_DEFAULT_HIGHWATER_MARK_BYTES,
crc32cEnabled: checkType === 'crc32c',
md5Enabled: checkType === 'md5',
api: 'JSON',
elapsedTimeUs: 0,
cpuTimeUs: -1,
status: 'OK',
chunkSize: totalSizeInBytes,
workers: argv.workers as number,
library: 'nodejs',
transferSize: totalSizeInBytes,
transferOffset: 0,
bucketName: bucket.name,
};

let start = performance.now();
for (const curFileName of fileMap.keys()) {
await bucket.upload(`${getDirName()}/${curFileName}`, {
validation: checkType,
});
}
let end = performance.now();
iterationResult.elapsedTimeUs = Math.round((end - start) * 1000);
results.push(iterationResult);

iterationResult = {
op: 'READ[0]',
objectSize: totalSizeInBytes,
appBufferSize: NODE_DEFAULT_HIGHWATER_MARK_BYTES,
crc32cEnabled: checkType === 'crc32c',
md5Enabled: checkType === 'md5',
api: 'JSON',
elapsedTimeUs: 0,
cpuTimeUs: -1,
status: 'OK',
chunkSize: totalSizeInBytes,
workers: argv.workers as number,
library: 'nodejs',
transferSize: totalSizeInBytes,
transferOffset: 0,
bucketName: bucket.name,
};

for (let i = 0; i < DEFAULT_NUMBER_OF_READS; i++) {
start = performance.now();
for (const curToDownload of fileMap.values()) {
await curToDownload.download({
validation: checkType,
destination: path.join(getDirName(), curToDownload.name),
});
}
end = performance.now();
}

iterationResult.elapsedTimeUs = Math.round((end - start) * 1000);
results.push(iterationResult);
for (const curToDelete of fileMap.values()) {
await curToDelete.delete({ignoreNotFound: true});
cleanupFile(curToDelete.name, getDirName());
}

return results;
}

main();
11 changes: 6 additions & 5 deletions internal-tooling/performanceTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function main() {
* When the worker passes back the results, they are appended to the results file.
*/
function createWorker() {
const dirName = getDirName().replace('/src', '/internal-tooling');
iterationsRemaining--;
log(
`Starting new iteration. Current iterations remaining: ${iterationsRemaining}`,
Expand All @@ -68,9 +69,10 @@ function createWorker() {
let testPath = '';
if (
argv.test_type === PERFORMANCE_TEST_TYPES.WRITE_ONE_READ_THREE ||
argv.test_type === PERFORMANCE_TEST_TYPES.RANGE_READ
argv.test_type === PERFORMANCE_TEST_TYPES.RANGE_READ ||
argv.test_type === PERFORMANCE_TEST_TYPES.MANY_SMALL
) {
testPath = `${getDirName()}/performPerformanceTest.js`;
testPath = `${dirName}/performPerformanceTest.js`;
} else if (
argv.test_type ===
PERFORMANCE_TEST_TYPES.TRANSFER_MANAGER_UPLOAD_MANY_FILES ||
Expand All @@ -79,17 +81,16 @@ function createWorker() {
argv.test_type ===
PERFORMANCE_TEST_TYPES.TRANSFER_MANAGER_DOWNLOAD_MANY_FILES
) {
testPath = `${getDirName()}/performTransferManagerTest.js`;
testPath = `${dirName}/performTransferManagerTest.js`;
} else if (
argv.test_type ===
PERFORMANCE_TEST_TYPES.APPLICATION_UPLOAD_MULTIPLE_OBJECTS ||
argv.test_type === PERFORMANCE_TEST_TYPES.APPLICATION_LARGE_FILE_DOWNLOAD ||
argv.test_type ===
PERFORMANCE_TEST_TYPES.APPLICATION_DOWNLOAD_MULTIPLE_OBJECTS
) {
testPath = `${getDirName()}/performApplicationPerformanceTest.js`;
testPath = `${dirName}/performApplicationPerformanceTest.js`;
}

const w = new Worker(testPath, {
argv: process.argv.slice(2),
});
Expand Down
1 change: 1 addition & 0 deletions internal-tooling/performanceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const OUTPUT_FORMATS = {
export const PERFORMANCE_TEST_TYPES = {
WRITE_ONE_READ_THREE: 'w1r3',
RANGE_READ: 'range-read',
MANY_SMALL: 'many-small',
TRANSFER_MANAGER_UPLOAD_MANY_FILES: 'tm-upload',
TRANSFER_MANAGER_DOWNLOAD_MANY_FILES: 'tm-download',
TRANSFER_MANAGER_CHUNKED_FILE_DOWNLOAD: 'tm-chunked',
Expand Down