Skip to content

Programs do the benching#365

Closed
PEZ wants to merge 62 commits intobddicken:mainfrom
PEZ:programs-do-the-benching
Closed

Programs do the benching#365
PEZ wants to merge 62 commits intobddicken:mainfrom
PEZ:programs-do-the-benching

Conversation

@PEZ
Copy link
Collaborator

@PEZ PEZ commented Jan 17, 2025

I have:

  • Read the project README, including the benchmark descriptions
  • Read the PR template instructions before I deleted them
  • Understood that if I have changed something that could impact performance of one or more contributions, I should provide results benchmark runs, using the run.sh script, from before and after the change.

Description of changes

This is the start of what I said in #341 that I should try to implement in-process benchmarking for Clojure, Java, and C. Starting with Clojure, to get it as right as possible before cloning the approach to any other languages.

I think the changes are best described in the New runner section in the updated README.md, plus:

Addressing:

@PEZ PEZ added levenshtein Anything regarding the levenshtein benchmark/test correctness Things touching upon the issue of program correctness loops Anything regarding the loops benchmark/test fibonacci Anything regarding the fibonacci benchmark/test start-times Issues regarding start-times as part of the benchmarks hello-world Anything regarding the hello-world benchmark/test in-process-benching labels Jan 17, 2025
@PEZ PEZ requested a review from bddicken January 17, 2025 00:37
@PEZ
Copy link
Collaborator Author

PEZ commented Jan 18, 2025

Now there are implementations for C, Clojure and Java, and Babashka (which can use the Clojure benchmarking utility). Here's what a levenshtein run looks like:

example-results-csv

@int2str
Copy link

int2str commented Jan 19, 2025

I'll have a crack at the C++ version of the benchmark.

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 19, 2025

Awesome, @int2str! I'm curious if you'll be able to use benchmark.c for it. Don't hesitate to make changes to it that would enable sharing.

@int2str
Copy link

int2str commented Jan 19, 2025

I've drafted a C++ version -> int2str@c5f3f02

Haven't tried using the C version. I might try that as well.
Though it feels "icky" somehow :D lol

Also, if the return type for the benchmark ever is something more complex than an int, I'd prefer to have my template<> blanket to comfort me :D

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 19, 2025

if the return type for the benchmark ever is something more complex than an int

It already is for Levenshtein where the return type is an array.

The reason for sharing is that it is less code to maintain. But if it makes things awkward for the CPP benchmarks that is a reason to implementing something more CPP friendly. Also, providing a separate CPP version could be good for reference, I think.

@int2str
Copy link

int2str commented Jan 23, 2025

Updated my draft to print dots as requested.

Btw. Maybe the warm-up runs shouldn't be the same amount as the final run? As in, why not do a 1 or 2 second warm-up and then the 10s run. Seems a bit much to do 10s for both, no?

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 23, 2025

I honestly don't know how much warmup is needed. But for JIT compilers it is different than for non-JIT. I can do a bunch of tests on Java and Clojure with different warmups and see if I can find a better guess than “same as benchmark”.

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 23, 2025

Can you file a PR on my fork with your changes, @int2str?

PEZ added 22 commits January 23, 2025 21:26
@PEZ PEZ force-pushed the programs-do-the-benching branch from 69de15c to dccf3aa Compare January 23, 2025 20:27
@PEZ
Copy link
Collaborator Author

PEZ commented Jan 23, 2025

I'm closing this PR and will move the changes to a separate repository/project which will be focused on benchmarking with minimal impact from start/setup times: https://github.com/PEZ/languages-fun

Because the world simply don't have enough of microbenchmark projects! 😄

@int2str PR with your C++ benchmark runner welcome there!

@PEZ PEZ closed this Jan 23, 2025
@PEZ PEZ deleted the programs-do-the-benching branch January 23, 2025 22:34
@PEZ PEZ mentioned this pull request Jan 25, 2025
3 tasks
@PEZ
Copy link
Collaborator Author

PEZ commented Jan 25, 2025

Alright @int2str. @bddicken and I decided to go for this runner in this repo, so I archived that other repo and now hope you'll PR your C++ implementation here. I'm sorry for the back-and-forth.

@int2str
Copy link

int2str commented Jan 25, 2025 via email

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 25, 2025

Cool! I added a separate warmup-ms arg to the programs, instead of just using run-ms for it. The run.ms script defaults to 2000 for warm-up. We can tweak that later if we see that more is needed for some environment. I also changed the benchmark.{clj,java,c} utilities to not run at all if the run-ms is 0. And the run.sh script sends 1, and 0, for run-ms and warmup-ns respectively in the correctness test run. I kept it simple in run.{clj,java,c} and just don't look at the return value of the warmup run. E.g. Executing something like ./c/run 0 0 levenshtein-words.txt will crash or not terminate or something. I think that's fine, running it with 0 run-ms doesn't make sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

correctness Things touching upon the issue of program correctness fibonacci Anything regarding the fibonacci benchmark/test hello-world Anything regarding the hello-world benchmark/test levenshtein Anything regarding the levenshtein benchmark/test loops Anything regarding the loops benchmark/test start-times Issues regarding start-times as part of the benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants