chore(storage): add storage benchmark tool for Gaxios refactor comparison#8341
chore(storage): add storage benchmark tool for Gaxios refactor comparison#8341thiyaguk09 wants to merge 12 commits into
Conversation
…sport (googleapis#8283) - Remove Service.ts and common.ts files from handwritten/storage - Migrate remaining functionality to StorageTransport - chore(ci): upgrade conformance tests to Node 18
…otprint against baseline versions
…sport (googleapis#8283) - Remove Service.ts and common.ts files from handwritten/storage - Migrate remaining functionality to StorageTransport - chore(ci): upgrade conformance tests to Node 18
…4856049-gaxios-benchmark
…4856049-gaxios-benchmark
There was a problem hiding this comment.
Code Review
This pull request introduces a new benchmarking tool in handwritten/storage/internal-tooling/benchmark.ts along with updated documentation in the README. The tool enables comparative latency and memory benchmarking between the current codebase and a specified baseline NPM version of @google-cloud/storage. Feedback focuses on improving the robustness of dynamic imports for module compatibility, replacing hardcoded values with constants, enhancing type safety by avoiding any[], and refining the throughput calculation logic.
…xible module resolution
| async function runBenchmark(StorageClass: typeof Storage, name: string, bucketName: string) { | ||
| // 2. Pass custom project ID to the storage client |
There was a problem hiding this comment.
Nit: Is this comment required ? What do the numbers on the comment refer to ?
There was a problem hiding this comment.
Removed prefix numbers (e.g., // 1., // 2.) from all comments and simplified them to clean, standard developer comments.
|
|
||
| | Parameter | Description | Requirement | Default | | ||
| | --------- | ----------- | :---: | :---: | | ||
| | `--project` | Google Cloud Project ID | **Required** | - | |
There was a problem hiding this comment.
Nit: Can we use projectId as the flag name like the other files in this folder for standardization ?
There was a problem hiding this comment.
Changed the --project option in benchmark.ts to --projectid.
|
|
||
| try { | ||
| // Scenario 1: Upload Small File | ||
| console.log('Starting Scenario 1: Upload (1KB)...'); |
There was a problem hiding this comment.
Consider dividing this into helper functions for each test scenario.
There was a problem hiding this comment.
Extracted individual scenario logic out of the main runBenchmark function into distinct, reusable async helper functions:
runUploadScenario(bucket, content, name, uploadedFiles)runMetadataScenario(mainFile)runDownloadScenario(mainFile)
| logMemory('After Metadata'); | ||
|
|
||
| // Scenario 3: Download Small File | ||
| console.log('Starting Scenario 3: Download (1KB)...'); |
There was a problem hiding this comment.
Is there a reason for only choosing only 1KB file size? Can we make this parameterized for other file sizes as well ?
There was a problem hiding this comment.
Are there other operations which are affected by the migration ?
Some possible examples: Large file transfers, Resumable uploads. If yes we should be benchmarking them as well to make sure we do not see any regression in them due to the migration
There was a problem hiding this comment.
Is there a reason for only choosing only 1KB file size? Can we make this parameterized for other file sizes as well ?
Introduced the --fileSize option (defaulting to 1024 bytes) in yargs. The file size buffer is now allocated dynamically (Buffer.alloc(argv.fileSize, 'a')), and throughput calculations adapt to the configured file size.
There was a problem hiding this comment.
Are there other operations which are affected by the migration ? Some possible examples: Large file transfers, Resumable uploads. If yes we should be benchmarking them as well to make sure we do not see any regression in them due to the migration
Agreed! Our resumable uploads currently only support/rely on Gaxios, so testing this path is crucial. To support better benchmarking here, I've added a --resumable boolean flag option. Under the hood, runUploadScenario passes this flag to the storage iterFile.save(content, { resumable: argv.resumable }) option, enabling targeted performance testing of resumable uploads.
eacb087 to
0c58a9a
Compare
…4856049-gaxios-benchmark
…4856049-gaxios-benchmark
…d resumable uploads while updating transport retry defaults
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:
Fixes #<issue_number_goes_here> 🦕