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

Add benchmark script to compare two different builds of s5cmd #471

Merged
merged 43 commits into from Aug 22, 2022

Conversation

boraberke
Copy link
Contributor

@boraberke boraberke commented Jul 22, 2022

This python script allow us to compare two different build (from either version tag, PR number or commit tag) performance under various scenarios. These scenarios include:

  1. Upload, Download, Remove many small sized file
  2. Upload, Download, Remove large file
  3. Upload, Download, Remove very large file

To change the scenarios, you should edit it inside the bench.py for now. In the future, this could be read from a file. From each scenario, user should not forget to change the file size and file count keeping in mind the restrictions of their system.

To run use the following syntax:

usage: bench.py [-h] [-s OLD NEW] [-w WARMUP] [-r RUNS] [-o OUTPUT_FILE_NAME] -b BUCKET [-l LOCAL_PATH] [-p PREFIX] [-hf HYPERFINE_EXTRA_FLAGS] [-sf S5CMD_EXTRA_FLAGS]

Compare performance of two different builds of s5cmd.

optional arguments:
  -h, --help            show this help message and exit
  -s OLD NEW, --s5cmd OLD NEW
                        Reference to old and new s5cmd.It can be a decimal indicating PR number,any of the version tags like v2.0.0 or any commit tag. Additionally it can be 'latest_release' or
                        'master'. (default: ('latest_release', 'master'))
  -w WARMUP, --warmup WARMUP
                        Number of program executions before the actual benchmark: (default: 2)
  -r RUNS, --runs RUNS  Number of runs to perform for each command (default: 10)
  -o OUTPUT_FILE_NAME, --output_file_name OUTPUT_FILE_NAME
                        Name of the output file (default: summary.md)
  -b BUCKET, --bucket BUCKET
                        Name of the bucket in remote (default: None)
  -l LOCAL_PATH, --local-path LOCAL_PATH
                        specify a local path for temporary files to be loaded. (default: None)
  -p PREFIX, --prefix PREFIX
                        Key prefix to be used while uploading to a specified bucket (default: s5cmd-benchmarks-)
  -hf HYPERFINE_EXTRA_FLAGS, --hyperfine-extra-flags HYPERFINE_EXTRA_FLAGS
                        hyperfine global extra flags. Write in between quotation marks and start with a space to avoid bugs. (default: None)
  -sf S5CMD_EXTRA_FLAGS, --s5cmd-extra-flags S5CMD_EXTRA_FLAGS
                        s5cmd global extra flags. Write in between quotation marks and start with a space to avoid bugs. (default: None)

Examples

./bench.py --bucket tempbucket --s5cmd v2.0.0 456 --warmup 2 --runs 10 

Above command will compare v2.0.0 to PR:456 with 2 warmup runs and 10 benchmark runs.

./bench.py --bucket tempbucket --s5cmd v2.0.0 456 --warmup 2 --runs 10 -sf " --log error" -hf " --show-output"

When using -hf and -sf flags, use quotes like above and start with an empty space. If not started with an empty space, it might give an error. This is a known issue with argparse and this discussion can be useful to understand the problem deeper.

kucukaslan and others added 11 commits July 19, 2022 14:17
Assumes that user has two copies of s5cmd one is default commandline app, second one is in the current directory.

A bucket name MUST be provided with -b flag.

User can optionally:
- add a key prefix with -k flag.
- specify hyperfine warmup counts with -w flag
- specify hyperfine runs counts with -r flag.

Example calls
`./benchmark.sh -b mcanktmpbuck`

`./benchmark.sh -w 1 -r 4 -b mcanktmpbuck -k example_key_prefix `
… the tests.

user can specify either version(tag), commit hash, or the PR number of the s5cmd that are to be used in the tests.
Two versions of the s5cmd will be used namely old and new. They can be specified by -o and -n flags, respectively.
Though version specified by o does not have to be older than that of specified by -n flag.

Default values of versions are v1.4.0 for old (-o), and v2.0.0 for new (-n).

Example execution that compares performance of peak#456 with the v1.4.0:
` ./benchmark.sh -b mys5cmbuck -n 456 -o v1.4.0 -k 1829`

Also note that user must provide a proper bucket which she has write/read/delete access.

Co-Authored-By: boraberke <67373739+boraberke@users.noreply.github.com>
- Measure the download and delete speeds
- quote shell variables, see also "shellcheck(SC2086)"
@boraberke boraberke requested a review from a team as a code owner July 22, 2022 11:26
@boraberke boraberke requested review from igungor and sonmezonur and removed request for a team July 22, 2022 11:26
@boraberke
Copy link
Contributor Author

boraberke commented Jul 22, 2022

Results will be both printed out to console and saved to bench_results.md file, which looks like below:

Benchmark summary:

Scenario Summary
upload small files 'PR:473' ran 2.65 times faster than 'version:v2.0.0'
download small files 'PR:473' ran 1.03 times faster than 'version:v2.0.0'
upload large files 'version:v2.0.0' ran 1.09 times faster than 'PR:473'
download large files 'PR:473' ran 1.24 times faster than 'version:v2.0.0'
remove small files 'PR:473' ran 1.07 times faster than 'version:v2.0.0'
remove large files 'PR:473' ran 1.11 times faster than 'version:v2.0.0'

Detailed summary:

Scenario Command Mean [ms] Min [ms] Max [ms] Relative
upload small files PR:473 241.2 241.2 241.2 1.00
upload small files version:v2.0.0 639.9 639.9 639.9 2.65
download small files PR:473 19.0 19.0 19.0 1.00
download small files version:v2.0.0 19.5 19.5 19.5 1.03
upload large files PR:473 153.2 153.2 153.2 1.09
upload large files version:v2.0.0 140.0 140.0 140.0 1.00
download large files PR:473 20.3 20.3 20.3 1.00
download large files version:v2.0.0 25.2 25.2 25.2 1.24
remove small files PR:473 28.1 28.1 28.1 1.00
remove small files version:v2.0.0 30.0 30.0 30.0 1.07
remove large files PR:473 27.5 27.5 27.5 1.00
remove large files version:v2.0.0 30.6 30.6 30.6 1.11

Copy link
Member

@sonmezonur sonmezonur left a comment

Choose a reason for hiding this comment

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

Please add --help command to your benchmark script. Otherwise users need to read this documentation before using this script

@boraberke boraberke changed the title Add benchmark script to compare Upload/Download/Remove speed Add benchmark script to compare two different builds of s5cmd Jul 27, 2022
@boraberke
Copy link
Contributor Author

boraberke commented Jul 27, 2022

Please add --help command to your benchmark script. Otherwise users need to read this documentation before using this script

Just updated from shell script to python script. Users now can use --help command to see the usage of this script 👍

benchmark/bench.py Outdated Show resolved Hide resolved
benchmark/bench.py Outdated Show resolved Hide resolved
Before this commit, for each individual command, a scenario was required. These scenarios were dependent to each other.

However, with this commit, any scenario will run `upload`, `download`, `remove` commands for a specified file size and file count.
Add a wait of 10 seconds after preparation to overcome errors due to eventual consistency of s3
sonmezonur
sonmezonur previously approved these changes Aug 13, 2022
benchmark/bench.py Show resolved Hide resolved
benchmark/bench.py Outdated Show resolved Hide resolved
benchmark/bench.py Outdated Show resolved Hide resolved
benchmark/bench.py Outdated Show resolved Hide resolved
benchmark/bench.py Outdated Show resolved Hide resolved
ilkinulas
ilkinulas previously approved these changes Aug 16, 2022
@igungor igungor merged commit 914e701 into peak:master Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants