-
Notifications
You must be signed in to change notification settings - Fork 16
ze: make sampling interval configurable #525
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
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,49 @@ | ||
| bats_require_minimum_version 1.5.0 | ||
|
|
||
| @test "sampling_interval_help" { | ||
| run iprof --help | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [[ "$output" == *"-i, --sample-interval MS"* ]] | ||
| [[ "$output" == *"Default: 50"* ]] | ||
| [[ "$output" == *"frequency, energy, engine, fabric-port, and memory"* ]] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we do this kind of test any where else? I think it's bad idea to put the default on the help. If we change the default, we will need to change it here too. |
||
| } | ||
|
|
||
| @test "sampling_interval_is_passed_to_ze_sampler" { | ||
| for option in -i --sample-interval; do | ||
| trace="sampling_interval_trace_${option#-}" | ||
| rm -rf "$trace" | ||
|
|
||
| LTTNG_UST_ZE_LIBZE_LOADER=/dev/null \ | ||
| iprof --no-analysis --sample --backends ze "$option" 125 \ | ||
| --trace-output "$trace" -- \ | ||
| bash -c 'test "$LTTNG_UST_ZE_SAMPLING_ENERGY_PERIOD_MS" = 125' | ||
| done | ||
| } | ||
|
Comment on lines
+12
to
+22
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sur what this is doing, we can remove it I think |
||
|
|
||
| @test "sampling_interval_rejects_invalid_values" { | ||
| for interval in 0 -1 nope; do | ||
| run iprof --sample --sample-interval "$interval" -- true | ||
|
|
||
| [ "$status" -ne 0 ] | ||
| [[ "$output" == *"ERROR:"* ]] | ||
| done | ||
| } | ||
|
|
||
| @test "sampling_interval_requires_sampling" { | ||
| run iprof --sample-interval 125 -- true | ||
|
|
||
| [ "$status" -ne 0 ] | ||
| [[ "$output" == *"--sample-interval requires --sample"* ]] | ||
| } | ||
|
|
||
| @test "sampling_interval_requires_ze_backend" { | ||
| run iprof --sample --sample-interval 125 --backends cxi -- true | ||
|
|
||
| [ "$status" -ne 0 ] | ||
| [[ "$output" == *"--sample-interval requires the ze backend"* ]] | ||
| } | ||
|
|
||
| @test "sampling_heartbeat" { | ||
| rm -rf heartbeat_trace | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -928,6 +928,7 @@ def all_env_tracers(usr_binary) | |
| # is to call zesInit and set ZES_ENABLE_SYSMAN to 0 | ||
| h['ZES_ENABLE_SYSMAN'] = 0 | ||
| h['LTTNG_UST_ZE_SAMPLING_ENERGY'] = 1 | ||
| h['LTTNG_UST_ZE_SAMPLING_ENERGY_PERIOD_MS'] = OPTIONS[:'sample-interval'] if OPTIONS.include?(:'sample-interval') | ||
| h['THAPI_SAMPLING_LIBRARIES'] << File.join(PKGLIBDIR, 'ze', 'libZESampling.so') | ||
| end | ||
| end | ||
|
|
@@ -1067,6 +1068,14 @@ if $thapi_launch || __FILE__ == $PROGRAM_NAME | |
| 'Use -1 for no limit.', default: 80) | ||
|
|
||
| parser.on('-s', '--sample', 'Enable counters sampling.') | ||
| parser.on('-i', '--sample-interval MS', OptionParser::DecimalInteger, | ||
| 'Set the Level Zero telemetry sampling interval in milliseconds.', | ||
| 'Controls frequency, energy, engine, fabric-port, and memory samples.', | ||
| 'Default: 50 ms.') do |interval| | ||
| raise(OptionParser::ParseError, 'sample interval must be greater than zero') unless interval.positive? | ||
|
|
||
| interval | ||
| end | ||
|
|
||
| parser.on('--metadata', 'Display trace metadata.') | ||
| parser.on('-v', '--version', 'Print the Version String.') do | ||
|
|
@@ -1098,6 +1107,13 @@ if $thapi_launch || __FILE__ == $PROGRAM_NAME | |
| options = {} | ||
| begin | ||
| parser.parse!(into: options) | ||
| options[:'backend-names'] = options[:backends].map { |name_level| name_level.split(':').first } | ||
| if options.include?(:'sample-interval') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We sampling other thing like CXI should be do like
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should do multiple mappings in the format of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. We do that for the Oh I guess we can do that for Sorry , I make you do big change :D But it seem far better API wize (and |
||
| raise OptionParser::ParseError, '--sample-interval requires --sample' unless options[:sample] | ||
| unless options[:'backend-names'].include?('ze') | ||
| raise OptionParser::ParseError, '--sample-interval requires the ze backend' | ||
| end | ||
| end | ||
| rescue OptionParser::InvalidOption => e | ||
| puts("ERROR: #{e}. Maybe missing --?") | ||
| print_help_and_exit(parser) | ||
|
|
@@ -1106,7 +1122,6 @@ if $thapi_launch || __FILE__ == $PROGRAM_NAME | |
| print_help_and_exit(parser) | ||
| end | ||
|
|
||
| options[:'backend-names'] = options[:backends].map { |name_level| name_level.split(':').first } | ||
| OPTIONS = options.freeze | ||
|
|
||
| if (launcher = %w[mpirun mpiexec].find { |b| ARGV.include?(b) }) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
run !(https://bats-core.readthedocs.io/en/stable/writing-tests.html#run-test-other-commands)
Lol I choose the wrong tests to do that. In the test where we do
state neq 0I mean :)