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

Modernization, CI Enhancements & Benchmark Improvements #6

Merged
merged 10 commits into from
Feb 14, 2025

Conversation

naomijub
Copy link
Contributor

This are changes from my own usage of Knossos, I will upstream them in steps so we can discuss the API as I suggest changed from my usages. I want to say congrats on the work, you maze library seems to be the best thought between the ones I analyzed.

I made quite a few changes that dont break the API:

  • Modernized clippy.
  • Removed dev-dependencies from the dependencies folder.
  • Extended the CI and introduced typos CI.
  • Functions that could be constant were converted to constant.
  • cargo update.
  • Replaced test::bencher with criterion, this removes the necessity of using nightly.
  • rng.gen::<bool>() was replaced by rng.random_bool(0.5). Named 0.5 as BOOL_TRUE_PROBABILITY, which is the probability to get a true, 50%.

@naomijub
Copy link
Contributor Author

naomijub commented Jan 29, 2025

Benchmarks in my computer, which mean nothing really, due to the tool changes and the computer changed:

Benchmarks Benchmarking aldous_broder/generate_10_x_10: Collecting 100 samples in estimatedaldous_broder/generate_10_x_10 time: [32.052 µs 32.119 µs 32.192 µs] Found 8 outliers among 100 measurements (8.00%) 2 (2.00%) low severe 2 (2.00%) high mild 4 (4.00%) high severe

Benchmarking aldous_broder/generate_100_x_100: Collecting 100 samples in estimataldous_broder/generate_100_x_100
time: [9.1910 ms 9.3691 ms 9.5503 ms]

Benchmarking binary_tree/generate_10_x_10: Collecting 100 samples in estimated 5binary_tree/generate_10_x_10
time: [2.6617 µs 2.6665 µs 2.6720 µs]
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe

Benchmarking binary_tree/generate_100_x_100: Collecting 100 samples in estimatedbinary_tree/generate_100_x_100
time: [246.95 µs 247.17 µs 247.42 µs]
Found 7 outliers among 100 measurements (7.00%)
7 (7.00%) high mild

Benchmarking eller//generate_10_x_10: Collecting 100 samples in estimated 5.0287eller//generate_10_x_10 time: [16.266 µs 16.286 µs 16.308 µs]
Found 6 outliers among 100 measurements (6.00%)
6 (6.00%) high mild

Benchmarking eller//generate_100_x_100: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.6s, enable flat sampling, or reduce sample count to 50.
Benchmarking eller//generate_100_x_100: Collecting 100 samples in estimated 7.60eller//generate_100_x_100
time: [1.5029 ms 1.5059 ms 1.5092 ms]
Found 7 outliers among 100 measurements (7.00%)
1 (1.00%) low mild
5 (5.00%) high mild
1 (1.00%) high severe

Benchmarking growing_tree_method_random/generate_10_x_10: Warming up for 3.0000 Benchmarking growing_tree_method_random/generate_10_x_10: Collecting 100 samplesgrowing_tree_method_random/generate_10_x_10
time: [9.7570 µs 9.7696 µs 9.7836 µs]
Found 9 outliers among 100 measurements (9.00%)
8 (8.00%) high mild
1 (1.00%) high severe

Benchmarking growing_tree_method_random/generate_100_x_100: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 6.0s, enable flat sampling, or reduce sample count to 60.
Benchmarking growing_tree_method_random/generate_100_x_100: Collecting 100 samplgrowing_tree_method_random/generate_100_x_100
time: [1.1988 ms 1.2016 ms 1.2044 ms]
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

Benchmarking growing_tree_method_oldest/generate_10_x_10: Warming up for 3.0000 Benchmarking growing_tree_method_oldest/generate_10_x_10: Collecting 100 samplesgrowing_tree_method_oldest/generate_10_x_10
time: [8.6662 µs 8.6834 µs 8.7025 µs]
Found 4 outliers among 100 measurements (4.00%)
3 (3.00%) high mild
1 (1.00%) high severe

Benchmarking growing_tree_method_oldest/generate_100_x_100: Warming up for 3.000Benchmarking growing_tree_method_oldest/generate_100_x_100: Collecting 100 samplgrowing_tree_method_oldest/generate_100_x_100
time: [902.72 µs 904.00 µs 905.23 µs]
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) low mild
2 (2.00%) high mild

Benchmarking growing_tree_method_newest/generate_10_x_10: Warming up for 3.0000 Benchmarking growing_tree_method_newest/generate_10_x_10: Collecting 100 samplesgrowing_tree_method_newest/generate_10_x_10
time: [7.8753 µs 7.8838 µs 7.8923 µs]
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

Benchmarking growing_tree_method_newest/generate_100_x_100: Warming up for 3.000Benchmarking growing_tree_method_newest/generate_100_x_100: Collecting 100 samplgrowing_tree_method_newest/generate_100_x_100
time: [738.54 µs 739.44 µs 740.33 µs]
Found 3 outliers among 100 measurements (3.00%)
3 (3.00%) high mild

Benchmarking growing_tree_method_middle/generate_10_x_10: Warming up for 3.0000 Benchmarking growing_tree_method_middle/generate_10_x_10: Collecting 100 samplesgrowing_tree_method_middle/generate_10_x_10
time: [8.7030 µs 8.7125 µs 8.7227 µs]
Found 6 outliers among 100 measurements (6.00%)
6 (6.00%) high mild

Benchmarking growing_tree_method_middle/generate_100_x_100: Warming up for 3.000Benchmarking growing_tree_method_middle/generate_100_x_100: Collecting 100 samplgrowing_tree_method_middle/generate_100_x_100
time: [907.82 µs 909.41 µs 911.08 µs]
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) low mild

Benchmarking hunt_and_kill/generate_10_x_10: Collecting 100 samples in estimatedhunt_and_kill/generate_10_x_10
time: [3.6012 µs 3.6070 µs 3.6137 µs]
Found 9 outliers among 100 measurements (9.00%)
6 (6.00%) high mild
3 (3.00%) high severe

Benchmarking hunt_and_kill/generate_100_x_100: Collecting 100 samples in estimathunt_and_kill/generate_100_x_100
time: [393.20 µs 394.57 µs 395.99 µs]
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) low mild
2 (2.00%) high mild

Benchmarking kruskal/generate_10_x_10: Collecting 100 samples in estimated 5.004kruskal/generate_10_x_10
time: [8.1560 µs 8.1705 µs 8.1868 µs]
Found 4 outliers among 100 measurements (4.00%)
3 (3.00%) high mild
1 (1.00%) high severe

Benchmarking kruskal/generate_100_x_100: Collecting 100 samples in estimated 7.2kruskal/generate_100_x_100
time: [36.054 ms 36.378 ms 36.707 ms]

Benchmarking prim/generate_10_x_10: Collecting 100 samples in estimated 5.0085 sprim/generate_10_x_10 time: [7.6122 µs 7.7627 µs 8.0397 µs]
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe

Benchmarking prim/generate_100_x_100: Collecting 100 samples in estimated 5.1459prim/generate_100_x_100 time: [2.0352 ms 2.0444 ms 2.0538 ms]

Benchmarking recursive_backtracking/generate_10_x_10: Collecting 100 samples in recursive_backtracking/generate_10_x_10
time: [4.7008 µs 4.7099 µs 4.7196 µs]
Found 7 outliers among 100 measurements (7.00%)
1 (1.00%) low mild
5 (5.00%) high mild
1 (1.00%) high severe

Benchmarking recursive_backtracking/generate_100_x_100: Collecting 100 samples irecursive_backtracking/generate_100_x_100
time: [475.41 µs 476.93 µs 478.57 µs]
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe

Benchmarking recursive_division/generate_10_x_10: Collecting 100 samples in estirecursive_division/generate_10_x_10
time: [1.3529 µs 1.3572 µs 1.3624 µs]
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) high mild
1 (1.00%) high severe

Benchmarking recursive_division/generate_100_x_100: Collecting 100 samples in esrecursive_division/generate_100_x_100
time: [134.55 µs 134.89 µs 135.24 µs]
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe

Benchmarking sidewinder/generate_10_x_10: Collecting 100 samples in estimated 5.sidewinder/generate_10_x_10
time: [1.1596 µs 1.1614 µs 1.1633 µs]
Found 5 outliers among 100 measurements (5.00%)
5 (5.00%) high mild

Benchmarking sidewinder/generate_100_x_100: Collecting 100 samples in estimated sidewinder/generate_100_x_100
time: [111.48 µs 111.66 µs 111.87 µs]
Found 4 outliers among 100 measurements (4.00%)
3 (3.00%) high mild
1 (1.00%) high severe

 Running benches/formatters.rs (target/release/deps/formatters-f15ba3b8a200822f)

Gnuplot not found, using plotters backend
Benchmarking game_map/format_10_x_10: Collecting 100 samples in estimated 5.6406game_map/format_10_x_10 time: [386.92 µs 393.71 µs 401.63 µs]
Found 10 outliers among 100 measurements (10.00%)
1 (1.00%) low mild
5 (5.00%) high mild
4 (4.00%) high severe

Benchmarking game_map/format_100_x_100: Collecting 100 samples in estimated 5.03game_map/format_100_x_100
time: [3.5811 ms 3.6110 ms 3.6439 ms]
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) high mild
2 (2.00%) high severe

Benchmarking ascii_broad/format_10_x_10: Collecting 100 samples in estimated 5.4ascii_broad/format_10_x_10
time: [352.55 µs 354.65 µs 356.93 µs]
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) high mild
1 (1.00%) high severe

Benchmarking ascii_broad/format_100_x_100: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 6.1s, enable flat sampling, or reduce sample count to 60.
Benchmarking ascii_broad/format_100_x_100: Collecting 100 samples in estimated 6ascii_broad/format_100_x_100
time: [1.1872 ms 1.2110 ms 1.2495 ms]
Found 5 outliers among 100 measurements (5.00%)
3 (3.00%) high mild
2 (2.00%) high severe

Benchmarking ascii_narrow/format_10_x_10: Collecting 100 samples in estimated 5.ascii_narrow/format_10_x_10
time: [355.66 µs 358.75 µs 361.87 µs]

Benchmarking ascii_narrow/format_100_x_100: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 5.8s, enable flat sampling, or reduce sample count to 60.
Benchmarking ascii_narrow/format_100_x_100: Collecting 100 samples in estimated ascii_narrow/format_100_x_100
time: [1.1319 ms 1.1410 ms 1.1504 ms]
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe

Benchmarking image/format_10_x_10: Collecting 100 samples in estimated 5.2780 s image/format_10_x_10 time: [7.5186 ms 7.5650 ms 7.6212 ms]
Found 4 outliers among 100 measurements (4.00%)
1 (1.00%) high mild
3 (3.00%) high severe

Benchmarking image/format_50_x_50: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 14.8s, or reduce sample count to 30.
Benchmarking image/format_50_x_50: Collecting 100 samples in estimated 14.807 s image/format_50_x_50 time: [148.37 ms 148.85 ms 149.36 ms]
Found 5 outliers among 100 measurements (5.00%)
3 (3.00%) high mild
2 (2.00%) high severe

@unrenamed
Copy link
Owner

hey @naomijub. really appreciate you acknowledging my work. thank you!

I've noticed some inconsistencies and would like to clarify a few things before merging. I'll leave comments in the review.

In the meantime, could you update the commit messages to follow the Conventional Commits spec? Also, please separate the benchmark updates from the rest of the PR into a separate one—it should make the review process much smoother.

@naomijub
Copy link
Contributor Author

Conventional Commits spec?

Benchmarks dont compile without nightly and I'm not open to add nightly for this. But I can do the MR blindly if you prefer.

Also, may I suggest adding a CONTRIBUTING.md to include the Conventional Commits spec? as convention for commits. Similar to other libraries like https://github.com/nats-io/nats.rs/blob/main/CONTRIBUTING.md

@naomijub
Copy link
Contributor Author

@unrenamed commit messages addressed

src/maze/grid/cell.rs Show resolved Hide resolved
src/maze/formatters/game_map.rs Outdated Show resolved Hide resolved
rustfmt.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@unrenamed
Copy link
Owner

Benchmarks dont compile without nightly and I'm not open to add nightly for this. But I can do the MR blindly if you prefer.

I might be missing smth, but how did you get the bench results before then?

Also, may I suggest adding a CONTRIBUTING.md...?

sounds great 👍 Feel free to add one in this PR.

.github/workflows/build.yml Show resolved Hide resolved
.github/workflows/build.yml Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@unrenamed
Copy link
Owner

unrenamed commented Jan 30, 2025

@unrenamed commit messages addressed

For consistency, may I ask you apply these changes as well. You may also want to reflect this in CONTRIBUTING.md:

  • use imperative mood only, e.g. apply, not applied
  • start a commit description (after the tag and scope) with lowercase letters
  • same for the list items

Example:

ci: increase the CI usage
- add ...
- add ...
- make...
image

@naomijub
Copy link
Contributor Author

Benchmarks dont compile without nightly and I'm not open to add nightly for this. But I can do the MR blindly if you prefer.

I might be missing smth, but how did you get the bench results before then?

Also, may I suggest adding a CONTRIBUTING.md...?

sounds great 👍 Feel free to add one in this PR.

I didnt, that is why I mentioned they were not really useful haha

@naomijub
Copy link
Contributor Author

you also might want to approve CI workflow for third parties Learn more about approving workflows.

@unrenamed unrenamed changed the title Update Modernization, CI Enhancements & Benchmark Improvements Jan 30, 2025
@unrenamed
Copy link
Owner

unrenamed commented Jan 30, 2025

you also might want to approve CI workflow for third parties Learn more about approving workflows.

yeah, it's a good idea. thanks for the link.

as for your fixes, everything looks good. Validating benches and workflow runs will be the final steps. One thing though: please review your commit messages again — titles look better now, but the bodies still violate the convention.

p.s. and fix typos like this one: Add stadand derive crates for public library

benches/algorithms.rs Outdated Show resolved Hide resolved
Copy link
Owner

@unrenamed unrenamed left a comment

Choose a reason for hiding this comment

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

CI spell checker's already proven useful 👍

image

Copy link
Owner

@unrenamed unrenamed left a comment

Choose a reason for hiding this comment

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

I've run cargo bench on my machine several times and noticed some warnings I'm concerned about. I can see those in the logs you've shared as well:

Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.6s, enable flat sampling, or reduce sample count to 50.

tbh I'm not OK with leaving them since those benches seem to be useless now and give no valuable info for users.

as far as I'm concerned criterion.rs provides some advanced configuration which might help fix the benches that produce warnings. WDYT?

@naomijub
Copy link
Contributor Author

naomijub commented Feb 1, 2025

I've run cargo bench on my machine several times and noticed some warnings I'm concerned about. I can see those in the logs you've shared as well:

Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.6s, enable flat sampling, or reduce sample count to 50.

tbh I'm not OK with leaving them since those benches seem to be useless now and give no valuable info for users.

as far as I'm concerned criterion.rs provides some advanced configuration which might help fix the benches that produce warnings. WDYT?

Sorry, I'm on Vacation for the next days and won't have access to my computer. I'll take a look at that when I'm back. Those warnings mostly mean that the bench tool was not able to run all the predefined benchmark executions in time. It usually executes 100 in x seconds and the maze generation takes longer than that. This seems completely reasonable considering the natura of a maze generation algorithm

@unrenamed
Copy link
Owner

I've run cargo bench on my machine several times and noticed some warnings I'm concerned about. I can see those in the logs you've shared as well:

Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.6s, enable flat sampling, or reduce sample count to 50.

tbh I'm not OK with leaving them since those benches seem to be useless now and give no valuable info for users.
as far as I'm concerned criterion.rs provides some advanced configuration which might help fix the benches that produce warnings. WDYT?

Sorry, I'm on Vacation for the next days and won't have access to my computer. I'll take a look at that when I'm back. Those warnings mostly mean that the bench tool was not able to run all the predefined benchmark executions in time. It usually executes 100 in x seconds and the maze generation takes longer than that. This seems completely reasonable considering the natura of a maze generation algorithm

I fully agree with you. Moreover, the algorithms' performance can vary due to random distribution, which criterion.rs makes easy to test by running benchmarks consecutively.

Right now, the warnings indicate some benchmarks are omitted. We should adjust those taking longer by reducing the sample count or increasing execution time to ensure they complete and produce results without warnings.

P.S. Enjoy your vacation!

@unrenamed
Copy link
Owner

@naomijub I'd be happy to merge this PR as it is so I can proceed with my other PRs and make some minor adjustments to the codebase. However, since some checks are currently failing—particularly due to a typo—I’m unable to do so at the moment.

Let me know if you're still available to fix them. Also, please use lowercase for this commit message: refactor: remove magic values.

@naomijub
Copy link
Contributor Author

I will be back Sunday, then I'm happy to make the adjustments as this MR was done with another user that I don't have in this machine

@naomijub
Copy link
Contributor Author

Hey @unrenamed I managed to fix the commits without the credentials for that computer. Hope everything works now

Copy link
Owner

@unrenamed unrenamed left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@unrenamed unrenamed merged commit 768dd9d into unrenamed:main Feb 14, 2025
7 checks passed
@naomijub
Copy link
Contributor Author

LGTM 👍

In my bevy branch I have an indexing and iterating solution. Do you want me upstream it?

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.

2 participants