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

Benchmarks in CI. #1498

Merged
merged 12 commits into from
Mar 14, 2024
Merged

Benchmarks in CI. #1498

merged 12 commits into from
Mar 14, 2024

Conversation

shimkiv
Copy link
Member

@shimkiv shimkiv commented Mar 12, 2024

Closes #1473
Closes #1487
Closes #1489
Closes o1-labs/benchmark-infra#1

@mitschabaude
Copy link
Collaborator

Hey @shimkiv one ask - can we separate the core benchmarking library from the tooling to upload benchmark data?
I.e. have two library files

  • benchmark.ts similar to original
  • benchmarking-infra.ts (or whatever you want to call it), which depends on influx db client etc

Similarly, it would be nice if the benchmark definitions like EcdsaBenchmark would be in a different file from the code that runs them and stores results.

Goal: I want to keep the ability to easily run these benchmarks locally and print out their results, by writing a small script that calls Benchmark.run(), which does not depend on and interacts with any of our infra

@shimkiv
Copy link
Member Author

shimkiv commented Mar 13, 2024

Hey @shimkiv one ask - can we separate the core benchmarking library from the tooling to upload benchmark data? I.e. have two library files
Goal: I want to keep the ability to easily run these benchmarks locally and print out their results, by writing a small script that calls Benchmark.run(), which does not depend on and interacts with any of our infra

Hey @mitschabaude, if you will run benchmarks locally as it was intended at first like ./run benchmarks/ecdsa.ts --bundle then it won't talk to any of infra since it won't be configured properly.
All the difference really in results logging, everything else is the same.

@mitschabaude
Copy link
Collaborator

it won't talk to any of infra since it won't be configured properly.

Ok thanks I see it now in the code that nothing happens if you don't configure influx db.

Still, I'd like to keep the infra code separate from the core benchmark code. This is cleaner from a code organization perspective. The core benchmark lib is not supposed to:

  • require '@influxdata/influxdb-client' as an npm dependency
  • try to read process.env
  • require running in Node.js

It should be a pure JS lib really with no external dependencies (right now it depends on jsstat but that is a pure math library itself)

@mitschabaude
Copy link
Collaborator

mitschabaude commented Mar 13, 2024

@shimkiv you could pass in the additional environment data like the CPU to Benchmark.run(), so that the benchmarking lib doesn't have to collect that data internally:

import os from "node:os";
// import benchmarks

let environment = {
  hardware: `${os.cpus()[0].model}, ${os.cpus().length} cores, ...`
  // ...
 };
 
let results = [
  ...await EcdsaBenchmark.run(environment),
  ...await SomeOtherBenchmark.run(environment),
];
 
// results include measurements + environment data

@shimkiv
Copy link
Member Author

shimkiv commented Mar 13, 2024

@shimkiv you could pass in the additional environment data like the CPU to Benchmark.run(), so that the benchmarking lib doesn't have to collect that data internally:

This is cool feature but since we run all of them on the same env. it looks like we transfer the same data back and forth without any meaning. In its current state. But might be helpful after refactoring you suggest. Thanks.

@mitschabaude
Copy link
Collaborator

@shimkiv you could pass in the additional environment data like the CPU to Benchmark.run(), so that the benchmarking lib doesn't have to collect that data internally:

This is cool feature but since we run all of them on the same env. it looks like we transfer the same data back and forth without any meaning. In its current state. But might be helpful after refactoring you suggest. Thanks.

I agree, it's just passing data through. The alternative is to add the environment data to the benchmark results after collecting them.

In any case, the data needs to come from outside somehow if we go with the requirement that the benchmarking lib doesn't collect that data itself

@shimkiv
Copy link
Member Author

shimkiv commented Mar 13, 2024

@mitschabaude can you please take another look on latest refactoring in attempt to reflect what was requested (from my understanding).
We can also implement the file-system historical data preservation for local runs, but probably it should be done later in another PR.

@shimkiv shimkiv changed the title (WIP) Benchmarks in CI. Benchmarks in CI. Mar 13, 2024
@shimkiv shimkiv marked this pull request as ready for review March 13, 2024 17:04
Copy link
Contributor

@ymekuria ymekuria left a comment

Choose a reason for hiding this comment

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

Nice work @shimkiv! I will leave it up to @mitschabaude to decide if theses changes addressed his comments.

Copy link
Collaborator

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

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

some comments left, looks great overall!

package.json Outdated Show resolved Hide resolved
benchmark/utils/influxdb-utils.ts Outdated Show resolved Hide resolved
benchmark/samples/ecdsa.ts Outdated Show resolved Hide resolved
benchmark/base-benchmark.ts Outdated Show resolved Hide resolved
benchmark/base-benchmark.ts Outdated Show resolved Hide resolved
benchmark/base-benchmark.ts Outdated Show resolved Hide resolved
@shimkiv shimkiv requested a review from mitschabaude March 14, 2024 13:39
Copy link
Collaborator

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

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

ship it 🚢

@shimkiv shimkiv merged commit 76a2fe8 into main Mar 14, 2024
17 checks passed
@shimkiv shimkiv deleted the feat/ci-benchmarking branch March 14, 2024 14:27
@shimkiv shimkiv mentioned this pull request Mar 14, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants