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 perf metrics utilities for write 1 / read 3 #1855

Merged
merged 10 commits into from
May 10, 2022

Conversation

ddelgrosso1
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@ddelgrosso1 ddelgrosso1 requested review from a team as code owners April 8, 2022 14:12
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/nodejs-storage API. labels Apr 8, 2022
@ddelgrosso1 ddelgrosso1 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 8, 2022
@ddelgrosso1
Copy link
Contributor Author

This is dependent on worker_threads which is not available until we drop node 10 support. Marking it as do not merge in the meantime.

@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. and removed size: m Pull request size is medium. labels Apr 8, 2022
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: xs Pull request size is extra small. labels Apr 8, 2022

const randomInteger = (minInclusive: number, maxInclusive: number) => {
return (
Math.floor(Math.random() * (maxInclusive - minInclusive + 1)) + minInclusive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment or rename randomInteger to specify Uniform Distribution is expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const sizeInBytes = generateRandomFile(fileName);

const stg = new Storage({
projectId: 'ddelgrosso-test',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to supply this value if it comes from ServiceAccount.json file. I would remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed and made configurable from command line.

appBufferSize: BLOCK_SIZE_IN_BYTES,
libBufferSize: 16384, //Node default
crc32Enabled: false,
md5Enabled: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't validation not used for uploads? I thought it was enabled by default for uploads. Python and Go validate checksums on upload as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it uses same as download now.

@@ -0,0 +1,157 @@
/*!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend creating a README.md similar to Python to clarify this is for dev team usage:

Python: https://github.com/googleapis/python-storage/blob/9dea065241f893e7d5eef22d70671ef0f860bb23/tests/perf/README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

} else if (checkType === 1) {
iterationResult.crc32Enabled = true;
start = performance.now();
await file.download({validation: 'crc32c'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does crc32c validation in this case expect that nodejs-storage is using the fast-crc32c package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't expect anything. Validation is currently being offloaded to another library. If fast-crc32c is available it will use it, if not it uses its own logic. See here: https://github.com/stephenplusplus/hash-stream-validation/blob/0aa27468552a2b12cff1813b5ef63ecb4e903621/index.js#L5

const checkType = randomInteger(0, 2);
if (checkType === 0) {
start = performance.now();
await bucket.file(`${fileName}`).download({validation: false});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per meeting: download to file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

op: 'WRITE',
objectSize: sizeInBytes,
appBufferSize: BLOCK_SIZE_IN_BYTES,
libBufferSize: 16384, //Node default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assign 16384 to a constant variable and link to the where this is defined in the Node.js library for future us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 13, 2022

bucket = stg.bucket(argv.bucket, {
preconditionOpts: {
ifGenerationMatch: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should go on bucket.upload() call no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we implemented preconditions due to constraints with common (i.e. we couldn't pass preconditions per function), we had to pass them at the constructor level. One of the upcoming refactors with internalizing common is adding the ability to pass these per function. If you look at the code below these lines you will see I re-declare the bucket as necessary to remove the preconditions where appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I literally just spoke with @shaffeeullah and she clarified this as well (in-person no way!!); thanks for clarifying, it will get better just didn't realize this was a trade off with not internalizing common. It's okay, not great but at least it's possible to pass in the precondition.

@ddelgrosso1 ddelgrosso1 changed the base branch from main to dropNode10 April 28, 2022 16:09
@ddelgrosso1 ddelgrosso1 added do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Apr 28, 2022
@ddelgrosso1 ddelgrosso1 removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 2, 2022
Copy link
Contributor

@shaffeeullah shaffeeullah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed mostly for code clarity. Will lean on @frankyn to take a closer look at the functionality.

@@ -0,0 +1,44 @@
# nodejs-storage benchmarking

**This is not an officially supported Google product**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change This is not an officially supported Google product to This is not a supported Google product. It's not unofficially supported either.


**This is not an officially supported Google product**

This benchmarking script is used by Storage client library maintainers to benchmark various workloads and collect metrics in order to improve performance of the library.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This benchmarking script is used by Storage client" -> "This benchmarking script intended for use by Storage client"

parentPort?.postMessage(results);
}

async function performWriteReadTest(): Promise<TestResult[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: add a small docstring for each function

@ddelgrosso1
Copy link
Contributor Author

I've repointed this at the dropNode10 branch since it utilizes Node 12 specific features. I still had to disable the warning regarding worker_threads as this was not supported in the initial release of Node 12. However, since we added a warning that this is unsupported I feel this is an acceptable compromise to get this merged.

@ddelgrosso1
Copy link
Contributor Author

@frankyn any further comments? I would like to get this merged for release with the drop in support for node 10.

@ddelgrosso1 ddelgrosso1 merged commit ec56333 into googleapis:dropNode10 May 10, 2022
@ddelgrosso1 ddelgrosso1 deleted the perf-metrics branch May 10, 2022 14:20
ddelgrosso1 added a commit to ddelgrosso1/nodejs-storage that referenced this pull request May 23, 2022
* test: add performance measuring

* add threading support to performance tests

* linter fixes

* rename folder

* add precondition to uploads, write to file for downloads

* fix pathing

* review feedback

* linter

* disable no unsupported features error now node 10 is unsupported

* add jsdoc headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants