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

Support showing the global bus events metrics #93

Open
ryoqun opened this issue Mar 5, 2024 · 5 comments
Open

Support showing the global bus events metrics #93

ryoqun opened this issue Mar 5, 2024 · 5 comments

Comments

@ryoqun
Copy link

ryoqun commented Mar 5, 2024

hi, thanks for maintaining this crate. i found this useful. :)

Callgrind supports collecting global bus events. This is useful for measuring how much atomic instructions are issued for given algorithm:

       --collect-bus=<no|yes> [default: no]
           This specifies whether the number of global bus events executed should be collected. The event type "Ge" is used for these events.

However, iai-callgrind doesn't support this? Ideally, I'd like to see this output when it's given with opt-in cli flag like --collect-bus:

test_lib_bench_readme_example_fibonacci::bench_fibonacci_group::bench_fibonacci short:10
  Instructions:                1733|N/A             (*********)
  L1 Hits:                     2359|N/A             (*********)
  L2 Hits:                        0|N/A             (*********)
  RAM Hits:                       2|N/A             (*********)
  Total read+write:            2361|N/A             (*********)
  Estimated Cycles:            2429|N/A             (*********)
  Global Bus Events:            223|N/A             (*********)  # <- NEW 

@ryoqun ryoqun changed the title Support the global bus events metrics Support showing the global bus events metrics Mar 5, 2024
@gamma0987
Copy link

Thanks for your interest in iai-callgrind.

There are different possibilities in place to achieve collecting global bus events (and the other optional callgrind events):

You can switch on --collect-bus using the LibraryBenchmarkConfig (library benchmarks) or BinaryBenchmarkConfig (binary benchmarks). For example:

main!(
    config = LibraryBenchmarkConfig::default()
        .raw_callgrind_args(["--collect-bus=yes"]);
...
);

The global bus events are printed in the Ge column in the output. Or, using the cli with environment variables

IAI_CALLGRIND_ARGS="--collect-bus=yes" cargo bench

with arguments

cargo bench -- --callgrind-args="--collect-bus=yes"

@ryoqun
Copy link
Author

ryoqun commented Mar 17, 2024

thanks for the reply!

There are different possibilities in place to achieve collecting global bus events (and the other optional callgrind events):

You can switch on --collect-bus using the LibraryBenchmarkConfig (library benchmarks) or BinaryBenchmarkConfig (binary benchmarks). For example:

main!(
    config = LibraryBenchmarkConfig::default()
        .raw_callgrind_args(["--collect-bus=yes"]);
...
);

Well, this worked nice!

The global bus events are printed in the Ge column in the output.

yeah, i saw like this:

  Instructions:                 729|729             (No change)
  L1 Hits:                     1093|1096            (-0.27372%) [-1.00274x]
  L2 Hits:                        0|0               (No change)
  RAM Hits:                      61|58              (+5.17241%) [+1.05172x]
  Total read+write:            1154|1154            (No change)
  Estimated Cycles:            3228|3126            (+3.26296%) [+1.03263x]
  Ge:                             8|N/A             (*********)

Or, using the cli with environment variables

IAI_CALLGRIND_ARGS="--collect-bus=yes" cargo bench

however, this didn't work for some reason.

with arguments

cargo bench -- --callgrind-args="--collect-bus=yes"

and this didn't too.

@gamma0987
Copy link

Oops. Sorry, the environment variable changed to IAI_CALLGRIND_CALLGRIND_ARGS="--collect-bus=yes" cargo bench.

For cargo bench -- --callgrind-args="--collect-bus=yes" to work you may need to specify the benchmark with --bench BENCHMARK, for example cargo bench --bench my_iai_benchmark -- --callgrind-args="--collect-bus=yes" or add the following to your Cargo.toml

[lib]
bench = false

and if you have binaries

[[bin]]
name = "my-binary"
path = "src/bin/my-binary.rs"
bench = false

@gamma0987
Copy link

You can always use cargo bench --bench my_iai_benchmark -- --help to list the recognized environment variables and command line arguments.

@gamma0987
Copy link

Is it working now?

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

No branches or pull requests

2 participants