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

Generate Daily Benchmark Results #2367

Merged
merged 121 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
2ef4fa4
draft changes
jdjaustin Dec 15, 2022
f51fb6e
calcs of import time and validation time
jdjaustin Jan 11, 2023
9ea68e4
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Jan 11, 2023
a6e686f
Add to db bench script a LotusBenchmark class
elmattic Jan 12, 2023
5eca13c
Add online validation for daily benchmark mode
elmattic Jan 13, 2023
b21c4aa
remove `snapshot_dir` and refactor `snapshot_path`
jdjaustin Jan 17, 2023
ed2584d
write metrics to CSV
jdjaustin Jan 18, 2023
5f3bb29
[WIP] impl Forest online validation methods
jdjaustin Jan 19, 2023
b73268d
Fix typo
elmattic Jan 20, 2023
f4dcde1
Add support for downloading snapshot
elmattic Jan 20, 2023
3b7312a
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic Jan 20, 2023
3105afe
Add support for Forest online validation
elmattic Jan 23, 2023
d17fdb9
Add support for db_size and db_clean for Lotus
elmattic Jan 23, 2023
1eea197
Add writing to csv file
elmattic Jan 23, 2023
63ec759
Use a shorter time for calibnet online validation
elmattic Jan 23, 2023
0280d2e
rubocop
elmattic Jan 24, 2023
3c64f8b
rubocop
elmattic Jan 25, 2023
9b8c6be
rubocop
elmattic Jan 25, 2023
346fbae
Add more reasonable rubocop settings
elmattic Jan 25, 2023
7e0768b
Change to use Layout
elmattic Jan 27, 2023
51cd5f8
Add base Benchmark class
elmattic Jan 27, 2023
f1b02d1
add git clone and tmp folder Forest install
jdjaustin Feb 9, 2023
0e2927d
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic Feb 16, 2023
1b99d3c
Fix writing result
elmattic Feb 17, 2023
1a1319f
Add two new benchmark classes for Forest
elmattic Feb 17, 2023
8a37541
Fix Forest benchmarks
elmattic Feb 17, 2023
95be033
Add back Lotus benchmark
elmattic Feb 17, 2023
a8ec257
Hoist chdir in commands
elmattic Feb 17, 2023
6282348
Better comments
elmattic Feb 21, 2023
32c3eba
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Feb 22, 2023
9582031
rubocop
elmattic Feb 22, 2023
4363c09
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic Feb 22, 2023
301ff03
Remove tmp dir for data dir
elmattic Mar 7, 2023
9996465
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic Mar 7, 2023
97e539f
Reduce online validation time for testing purposes
elmattic Mar 7, 2023
f852c8c
fix auto download feature
jdjaustin Mar 7, 2023
7b13dab
rubocop
elmattic Mar 8, 2023
f95408c
Fix forest db bench and fix rubocop errors
elmattic Mar 8, 2023
ea4344c
add fetchparams to Forest run
jdjaustin Mar 8, 2023
351070d
Merge branch 'jdjaustin/issue-2208-generate-daily-benchmark-results' …
jdjaustin Mar 8, 2023
e5f991a
rubocop
elmattic Mar 8, 2023
0a1dc0e
Remove old script
elmattic Mar 8, 2023
62486e7
add conditional to init_command
jdjaustin Mar 8, 2023
7a7cf2f
Fix rubocop error and uncomment forest benchmark
elmattic Mar 8, 2023
0662bd5
rubocop
elmattic Mar 8, 2023
668d9c5
Fix script
elmattic Mar 8, 2023
787e1bf
add `--tempdir` option
jdjaustin Mar 8, 2023
f4595b5
Merge branch 'jdjaustin/issue-2208-generate-daily-benchmark-results' …
jdjaustin Mar 8, 2023
3b485b2
Small refactor and rubocop fix
elmattic Mar 9, 2023
da9ff8d
Refactor out dry_run param
elmattic Mar 9, 2023
0e3318f
Refactor forest benchmark list
elmattic Mar 9, 2023
1903428
Fix wrong class name
elmattic Mar 9, 2023
b115706
rubocop fixes
jdjaustin Mar 9, 2023
6ad1fae
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Mar 9, 2023
bfc094d
Inline function
elmattic Mar 9, 2023
cb329c2
Fix nil error when in fetching messages stage
elmattic Mar 10, 2023
416fa5f
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Mar 10, 2023
b1c07de
changes to readme, add `--daily` flag, remove `ParityBenchmark`
jdjaustin Mar 13, 2023
e698bea
update regex to handle tmp directory path
jdjaustin Mar 14, 2023
46499d3
rubocop
jdjaustin Mar 14, 2023
722a076
add `config` option to `LotusBenchmark`
jdjaustin Mar 14, 2023
1f55e06
Lotus config changes
jdjaustin Mar 14, 2023
7e46698
add concurrency, rm TODOs, add sleep on fresh snapshot
jdjaustin Mar 15, 2023
86f9484
update `Gemfile`
jdjaustin Mar 15, 2023
f194982
update `pathname` in `Gemfile`
jdjaustin Mar 16, 2023
ca35f18
updates to readme
jdjaustin Mar 16, 2023
4808022
update README
jdjaustin Mar 16, 2023
d16f619
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Mar 16, 2023
2fe7d65
run Prettier
jdjaustin Mar 16, 2023
d692e3c
Merge branch 'jdjaustin/issue-2208-generate-daily-benchmark-results' …
jdjaustin Mar 16, 2023
f954900
rerun Prettier due to merge
jdjaustin Mar 16, 2023
e0fc2c3
Remove pathname and update Gemfile
elmattic Mar 24, 2023
cfb4236
Fixes for testing memory allocators
elmattic Mar 24, 2023
f6dd786
Add support for VSZ in db benchmarks
elmattic Mar 24, 2023
a6e48cb
Fix heights to validate to 40
elmattic Mar 24, 2023
053f45b
rubocop
elmattic Mar 27, 2023
6bc9897
Restore main branch for Forest benchmark
elmattic Mar 27, 2023
662f6c4
rm unused `pathname` dep
jdjaustin Apr 10, 2023
1db08c3
Apply suggestions from code review
jdjaustin Apr 10, 2023
9c6b582
update `get_last_epoch`
jdjaustin Apr 10, 2023
09614f5
changes from code review
jdjaustin Apr 10, 2023
d71ef72
update `README`
jdjaustin Apr 10, 2023
5c6a26e
Update `README`
jdjaustin Apr 18, 2023
0383b20
add `mkdir_p`
jdjaustin Apr 24, 2023
94bd3eb
Update gem lock file
elmattic Apr 24, 2023
3303ed3
move `mkdir_p` for `tempdir`
jdjaustin Apr 24, 2023
a1f975f
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic Apr 24, 2023
20aad47
refactor script into multiple files
jdjaustin Apr 24, 2023
6eba476
Merge branch 'jdjaustin/issue-2208-generate-daily-benchmark-results' …
jdjaustin Apr 24, 2023
cc0e903
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Apr 24, 2023
d3db5de
update `README.md`
jdjaustin Apr 24, 2023
e58503a
add mixins
jdjaustin Apr 25, 2023
e4b51c3
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin Apr 27, 2023
cf703a3
Add proper logging
jdjaustin Apr 27, 2023
897bc73
add err handling during snapshot download
jdjaustin May 2, 2023
385c466
modify snapshot download err handling
jdjaustin May 2, 2023
cf943ec
add err handling to benchmarks
jdjaustin May 2, 2023
3ec56df
add logger messages during err rescues
jdjaustin May 3, 2023
e98f3cd
rubocop
jdjaustin May 3, 2023
e48de04
updates to err handling
jdjaustin May 3, 2023
518e6fb
add interrupt handling to `proc_monitor`
jdjaustin May 3, 2023
5e5c785
revert `pid` var scope
jdjaustin May 4, 2023
9ad93f5
delete downloaded repo in case of error
jdjaustin May 4, 2023
2842c38
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin May 4, 2023
2be8aca
add steps to clean repos after metrics
jdjaustin May 8, 2023
2732da5
add step to delete downloaded snapshot at end
jdjaustin May 9, 2023
a346ee9
changes to snapshot download
jdjaustin May 9, 2023
cd82df2
modify snapshot dl with tempdir
jdjaustin May 9, 2023
25d1815
changes to fix permissions issue
jdjaustin May 10, 2023
2b5e77f
normalize units to seconds
jdjaustin May 10, 2023
df2a585
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
jdjaustin May 11, 2023
73b102e
changes to correct lotus_path with tempdir
jdjaustin May 11, 2023
fa14a0f
additional comments in `bench.rb`
jdjaustin May 12, 2023
f83aa93
Additional comments
jdjaustin May 12, 2023
d59a21b
truncate validation time decimal places
jdjaustin May 12, 2023
fd0842c
update `.gitignore`
jdjaustin May 16, 2023
fe10fa1
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic May 19, 2023
c809ea3
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic May 22, 2023
1f0d76e
update `Gemfile.lock`
jdjaustin May 22, 2023
931b112
modify `fetch-params` command
jdjaustin May 22, 2023
8860d51
Merge branch 'main' into jdjaustin/issue-2208-generate-daily-benchmar…
elmattic May 23, 2023
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ genesis.json
node/rpc-api/static/ast.ron
documentation/book/**/*
node_modules
/scripts/benchmark_db/.bundle/
/scripts/benchmark_db/vendor/
/scripts/benchmark_db/*.md
/scripts/benchmark_db/*.csv
6 changes: 6 additions & 0 deletions scripts/benchmark_db/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AllCops:
NewCops: enable
Layout/LineLength:
Max: 120
Metrics/MethodLength:
Max: 20
9 changes: 9 additions & 0 deletions scripts/benchmark_db/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@ source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'concurrent-ruby', '~> 1.2', '>= 1.2.2'
gem 'csv', '~> 3.2', '>= 3.2.6'
gem 'deep_merge', '~> 1.2', '>= 1.2.2'
gem 'fileutils', '~> 1.7'
gem 'logger', '~> 1.5', '>= 1.5.3'
gem 'open3', '~> 0.1.2'
gem 'optparse', '~> 0.3.1'
gem 'set', '~> 1.0', '>= 1.0.3'
gem 'tmpdir', '~> 0.1.3'
gem 'toml-rb', '~> 2.2'
gem 'tomlrb', '~> 2.0', '>= 2.0.3'
34 changes: 34 additions & 0 deletions scripts/benchmark_db/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
jdjaustin marked this conversation as resolved.
Show resolved Hide resolved
citrus (3.0.2)
concurrent-ruby (1.2.2)
csv (3.2.6)
deep_merge (1.2.2)
fileutils (1.7.0)
open3 (0.1.2)
optparse (0.3.1)
set (1.0.3)
tmpdir (0.1.3)
fileutils
toml-rb (2.2.0)
citrus (~> 3.0, > 3.0)
tomlrb (2.0.3)

PLATFORMS
arm64-darwin-21

DEPENDENCIES
concurrent-ruby (~> 1.2, >= 1.2.2)
csv (~> 3.2, >= 3.2.6)
deep_merge (~> 1.2, >= 1.2.2)
fileutils (~> 1.7)
open3 (~> 0.1.2)
optparse (~> 0.3.1)
set (~> 1.0, >= 1.0.3)
tmpdir (~> 0.1.3)
toml-rb (~> 2.2)
tomlrb (~> 2.0, >= 2.0.3)

BUNDLED WITH
2.4.6
115 changes: 91 additions & 24 deletions scripts/benchmark_db/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,116 @@
# Forest benchmark db script

This script is here to help with testing of Forest db backends and their
configuration.
This script was developed to help with testing of Forest db backends and their
configuration; the script now also allows benchmarking ("daily" benchmarks) of
Forest and Lotus snapshot import times (in sec) and validation times (in
tipsets/sec).

## Install dependencies
jdjaustin marked this conversation as resolved.
Show resolved Hide resolved

You will need to install Ruby first. Then go into `benchmark_db` and type:
[Install Ruby](https://www.ruby-lang.org/en/documentation/installation/) first.
Then go into `scripts/benchmark_db` and execute the following commands:

```
$ bundle config set --local path 'vendor/bundle'
$ bundle install
```

Note: depending upon your Ruby installation, it may be necessary to execute
`gem install bundler` first. In case of any issues with "native extensions"
during `bundle install` on a \*nix machine, it may also be necessary to execute
jdjaustin marked this conversation as resolved.
Show resolved Hide resolved
`apt-get update && apt-get install -y build-essential ruby-dev`.

The daily benchmarks also require the installation of
[aria2](https://github.com/aria2/aria2) and
[zstd](https://github.com/facebook/zstd), as well as dependencies required for
the installation of [Forest](https://github.com/ChainSafe/forest) and
[Lotus](https://github.com/filecoin-project/lotus) (note that the script handles
installation of the Forest and Lotus binaries).

## Run benchmarks

You need to run the script at the root of the repository. Ie:
Run the script at the root of the repository. I.e.,:

```
$ ./benchmark_db/bench.rb 2369040_2022_11_25t12_00_00z.car
$ ./scripts/benchmark_db/bench.rb <path to snapshot> <optional flags>
```

You can create a selection of benchmarks using the `--pattern` flag. If used in
conjunction with `--dry-run` you will see what commands will be run:
If the user does not specify a path to a snapshot, the script will automatically
download a fresh snapshot, then pause for 5 minutes to allow the network to
advance to ensure that enough time will be spent in the `message sync` stage for
proper calculation of the validation time metric. Also note that if `--chain` is
specified, the user must provide a script matching the specified `<chain>` (the
script defaults to `mainnet`, so if `--chain` is not specified, provide a
`mainnet` snapshot).

If the `--daily` flag is included in the command line arguments, the script will
run the daily benchmarks specified earlier; otherwise the script will run the
backend metrics.

On many machines, running the script with `--chain mainnet` may require more
space than allocated to the `tmp` partition. To address this, specify the
`--tempdir` flag with a user-defined directory (which will automatically be
created if it does not already exist).

To create a selection of benchmarks, use the `--pattern` flag (current defined
patterns are `'*'`, `'baseline'`, `'jemalloc'`, and `'mimalloc'`). Using
`--dry-run` outputs to the terminal the commands the script will run (without
actually running the commands):

```
$ ./scripts/benchmark_db/bench.rb 2369040_2022_11_25t12_00_00z.car --pattern 'baseline*,paritydb' --dry-run
Running bench: baseline
$ ./scripts/benchmark_db/bench.rb <path to snapshot> --chain calibnet --pattern jemalloc --dry-run
(I) Using snapshot: <path to snapshot>
(I) WORKING_DIR: <generated directory>

(I) Running bench: jemalloc
(I) Building artefacts...
(I) Cloning repository
$ git clone https://github.com/ChainSafe/forest.git forest
(I) Clean and build client
$ cargo clean
$ cargo build --release
$ ./target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import
$ ./target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import --skip-load --height 2368640
Wiping db
$ cargo build --release --no-default-features --features forest_fil_cns,jemalloc
$ ./forest/target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import
$ ./forest/target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import --skip-load=true --height <height>
(I) Clean db
$ ./forest/target/release/forest-cli -c <path>
toml db clean --force

Running bench: baseline-with-stats
(I) Wrote result_<time>.md
```

```
$ ./scripts/benchmark_db/bench.rb <path to snapshot> --chain calibnet --dry-run --daily
(I) Using snapshot: <path to snapshot>
(I) WORKING_DIR: <generated directory>

(I) Running bench: forest
(I) Building artefacts...
(I) Cloning repository
$ git clone https://github.com/ChainSafe/forest.git forest
(I) Clean and build client
$ cargo clean
$ cargo build --release
$ ./target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import
$ ./target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import --skip-load --height 2368640
Wiping db
$ ./forest/target/release/forest-cli fetch-params --keys
$ ./forest/target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import
$ ./forest/target/release/forest --config <tbd> --encrypt-keystore false
(I) Clean db
$ ./forest/target/release/forest-cli -c <path> db clean --force

Running bench: paritydb
$ cargo clean
$ cargo build --release --no-default-features --features forest_fil_cns,paritydb
$ ./target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import
$ ./target/release/forest --config <tbd> --encrypt-keystore false --import-snapshot <tbd> --halt-after-import --skip-load --height 2368640
Wiping db
(I) Running bench: lotus
(I) Building artefacts...
(I) Cloning repository
$ git clone https://github.com/filecoin-project/lotus.git lotus
(I) Clean and build client
$ make clean
$ make calibnet
$ ./lotus/lotus daemon --import-snapshot <tbd> --halt-after-import
$ ./lotus/lotus daemon
(I) Clean db

Wrote result_<time>.csv
```

Benchmark results will be written to a markdown file at the end.
As seen in these examples, if `--daily` is passed in the command line, daily
benchmark results are written to a CSV in the current directory with naming
format `result_<time>.csv`. Otherwise, backend benchmark results will be written
to a markdown file with a similar naming convention.
Loading