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

improve(benchmarks): support multiple values + visualizing runtimes #316

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

0xNineteen
Copy link
Contributor

@0xNineteen 0xNineteen commented Oct 17, 2024

  • docs in docs/benchmarks.md
  • scripts for visualizing scripts/view_bench.py
  • completely new benchmarking output from src/benchmarks.zig
  • add new tests to benchmarks
    • fixes to leaks throughout the benchmarks (some require larger changes -- left for another PR)
  • changes to snapshot downloading (from previous PR/rex)
    • closes account files after mmaping their data in - reducing open file limit errors (data is never modified so its ok) - this also lets us map it in with the PRIVATE flag
    • reduce the accounts-db-snapshot benchmarks to only a single method which benchmarks loading and validation in one go
    • improve snapshot download code

support multiple values from a benchmark

benchmark, read_time_min, read_time_max, read_time_mean, read_time_variance, benchmark, write_time_min, write_time_max, write_time_mean, write_time_variance, 
readWriteAccounts(100k accounts (1_slot - ram index - ram accounts)), 172156041, 158767959, 162868245, 15183799545214, 303852750, 286908417, 292925858, 39820330697776, 
readWriteAccounts(100k accounts (1_slot - disk index - ram accounts)), 165480250, 156170500, 160821658, 7611019088428, 319935833, 286708833, 304248199, 113169780175088,

NOTE: for multiple value outputs its not human readable at all - but i think thats ok -- most of our confirmations of speed ups/slow downs shouldnt be human checked, it should be computed and the increase/decrease should be human checked (which this PR allows for you to do easily)

support viewing all runtimes (-r)

{benchmark_name} ({field}), {runtime1}, {runtime2}, ...

readWriteAccounts(100k accounts (1_slot - ram index - ram accounts)) (read_time), 41451000, 40685750, 41123125, 40722417, 40743667
readWriteAccounts(100k accounts (1_slot - ram index - ram accounts)) (write_time), 81834042, 75340000, 76776125, 74969958, 74682792

visualizing all runtimes

./zig-out/bin/benchmark accounts_db_readwrite -r 2>&1 | tee b_results.txt # save output to file
python scripts/view_bench.py b_results.txt # view runtimes as a charts with one file source
python scripts/view_bench.py b_results.txt b_results2.txt # compare runtimes against two *equivalent* files
  • we support as many files as given from the cli

example output:

Viewing ['b_results.txt', 'b_results2.txt']
Saved to results/readWriteAccounts(100k accounts (1_slot - ram index - ram accounts)) (read_time).png
Saved to results/readWriteAccounts(100k accounts (1_slot - ram index - ram accounts)) (write_time).png
Saved to results/readWriteAccounts(100k accounts (1_slot - disk index - ram accounts)) (read_time).png
Saved to results/readWriteAccounts(100k accounts (1_slot - disk index - ram accounts)) (write_time).png
...

readWriteAccounts(100k accounts (1_slot - ram index - ram accounts)) (write_time)

  • each point on y-axis=0 is a runtime
  • the point on y-axis=1 is the mean with the bar surrounding it being the standard deviation

note: builds off #289 -- i switched to mainly working on this feat so moved it to my own branch (instead of rexi's)

@0xNineteen 0xNineteen marked this pull request as ready for review October 17, 2024 21:35
@0xNineteen 0xNineteen linked an issue Oct 17, 2024 that may be closed by this pull request
@0xNineteen 0xNineteen changed the title feat(benchmarks): improve results improve(benchmarks): support multiple values + visualizing runtimes Oct 22, 2024
Copy link
Contributor

@Sobeston Sobeston left a comment

Choose a reason for hiding this comment

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

Seems good overall, but some issues:

Comment on lines +26 to +33

```bash
./zig-out/bin/benchmark accounts_db_readwrite -r 2>&1 | tee bench_results.txt # save output to file
# NOTE: need to format doc to below
python scripts/view_bench.py bench_results.txt # view runtimes as a charts with one file source
python scripts/view_bench.py bench_results.txt b_results2.txt # compare runtimes against two *equivalent* files
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Just went to run this example and got a type error, leaving me without any data (?)

TypeError: unsupported operand type(s) for /: 'str' and 'int'

image

Copy link
Contributor Author

@0xNineteen 0xNineteen Oct 24, 2024

Choose a reason for hiding this comment

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

Comment on lines 35 to 47
for df_i, df in enumerate(dfs):
benchmark_runtimes = df.T[1:][i]
# convert to milliseconds
if units == 'ms':
benchmark_runtimes = benchmark_runtimes / 1_000_000
if units == 's':
benchmark_runtimes = benchmark_runtimes / 1_000_000_000
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to be the source of the error in my previous comment

    benchmark_runtimes = benchmark_runtimes / 1_000_000
                         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

Copy link
Contributor Author

@0xNineteen 0xNineteen Oct 24, 2024

Choose a reason for hiding this comment

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

src/accountsdb/accounts_file.zig Show resolved Hide resolved
Comment on lines 3903 to 3904
// defer logger.deinit();
// logger.spawn();
Copy link
Contributor

Choose a reason for hiding this comment

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

dangling comments

Copy link
Contributor Author

@0xNineteen 0xNineteen Oct 24, 2024

Choose a reason for hiding this comment

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

});

return write_time;
// const read_faster_or_slower = if (read_speedup < 1.0) "slower" else "faster";
Copy link
Contributor

Choose a reason for hiding this comment

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

dangling comment

Copy link
Contributor Author

@0xNineteen 0xNineteen Oct 24, 2024

Choose a reason for hiding this comment

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

Comment on lines +3442 to +3455
// test "benchmarkPullRequests" {
// _ = try BenchmarkGossipServicePullRequests.benchmarkPullRequests(.{
// .name = "1k_data_1k_pull_reqs",
// .n_data_populated = 10,
// .n_pull_requests = 2,
// });
// }

// test "benchmarkGossipService" {
// _ = try BenchmarkGossipServiceGeneral.benchmarkGossipService(.{
// .message_counts = .{
// .n_ping = 10,
// .n_push_message = 10,
// .n_pull_response = 10,
// },
// });
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we fixing and re-enabling these, or removing these?

Copy link
Contributor Author

@0xNineteen 0xNineteen Oct 24, 2024

Choose a reason for hiding this comment

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

left a comment - right now they leak when run with the testing allocator -- will fix the leak in another PR since its a bit more involved to fix

c5d914b

https://github.com/orgs/Syndica/projects/2/views/10?pane=issue&itemId=84676970

@0xNineteen
Copy link
Contributor Author

discussed offline - changes to be included:

  • print human-readable format by default
  • output csv to a file (latest commit version & timestamp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

test(accountsdb): benchmark snapshot loading and validation
3 participants