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

Check for failures in parseFile(), perf events tweaks #84

Merged
merged 3 commits into from
Feb 6, 2023

Conversation

cj-tommi-rantala
Copy link
Contributor

Check for failures when opening/reading any of the CPU frequency related sysfs files, to avoid needless warning messages.

Plus couple tweaks to the perf events:

  • Fallback to PERF_COUNT_HW_CPU_CYCLES, for example my laptop with AMD Ryzen CPU doesn't have the reference cycles event.
  • Add HW perf events before SW events, this fixes the events in one embedded device with 4.14 kernel.

Copy link
Owner

@martinus martinus left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I've got one note, other than that all is good

src/include/nanobench.h Outdated Show resolved Hide resolved
Check for failures when opening/reading the CPU frequency related sysfs
files, to avoid needless warning messages.

Note that if `scaling_min_freq` and `scaling_max_freq` both fail, then
`minFreq` and `maxFreq` will be zeroes and no warning is generated.
Not all platforms support the reference cycles, so fallback to the cycle
counter, it's better than nothing.
The mixed order of HW and SW events causes EINVAL failures from some of
the perf_event_open() syscalls in one embedded device with 4.14 kernel.
Fixed by adding all the HW events first, then the SW events.
@martinus
Copy link
Owner

martinus commented Feb 6, 2023

Awesome, thanks!

@cj-tommi-rantala cj-tommi-rantala deleted the perf-events branch February 6, 2023 08:07
fanquake added a commit to bitcoin-core/gui that referenced this pull request Nov 16, 2023
fe434a4 bench: Update nanobench to 4.3.11 (TheCharlatan)

Pull request description:

  The newest version fixes the false positive `* Turbo is enabled, CPU frequency will fluctuate` warning on AMD CPUs. The file was directly taken from the release page: https://github.com/martinus/nanobench/releases/tag/v4.3.11.

  Other changes from the release notes:

  * Check for failures in parseFile(), perf events tweaks by tommi-cujo in martinus/nanobench#84
  * Workaround missing noexcept for std::string move assignment by tommi-cujo in martinus/nanobench#87
  * removed the link by martinus in martinus/nanobench#89
  * Lots of minor cleanups by martinus in martinus/nanobench#85
  * Add linter for version & clang-format. Updated version by martinus in martinus/nanobench#90

ACKs for top commit:
  fanquake:
    ACK fe434a4 - have not tested.

Tree-SHA512: a8f15e1db1d993673e4b295a3bab22e67ee3c9f3c0bcbef28974fe9ff37dbb741967a526088d5b148c8d25c9d57cd3b844238100c17b23038638787461805678
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 24, 2024
fe434a4 bench: Update nanobench to 4.3.11 (TheCharlatan)

Pull request description:

  The newest version fixes the false positive `* Turbo is enabled, CPU frequency will fluctuate` warning on AMD CPUs. The file was directly taken from the release page: https://github.com/martinus/nanobench/releases/tag/v4.3.11.

  Other changes from the release notes:

  * Check for failures in parseFile(), perf events tweaks by tommi-cujo in martinus/nanobench#84
  * Workaround missing noexcept for std::string move assignment by tommi-cujo in martinus/nanobench#87
  * removed the link by martinus in martinus/nanobench#89
  * Lots of minor cleanups by martinus in martinus/nanobench#85
  * Add linter for version & clang-format. Updated version by martinus in martinus/nanobench#90

ACKs for top commit:
  fanquake:
    ACK fe434a4 - have not tested.

Tree-SHA512: a8f15e1db1d993673e4b295a3bab22e67ee3c9f3c0bcbef28974fe9ff37dbb741967a526088d5b148c8d25c9d57cd3b844238100c17b23038638787461805678
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 24, 2024
fe434a4 bench: Update nanobench to 4.3.11 (TheCharlatan)

Pull request description:

  The newest version fixes the false positive `* Turbo is enabled, CPU frequency will fluctuate` warning on AMD CPUs. The file was directly taken from the release page: https://github.com/martinus/nanobench/releases/tag/v4.3.11.

  Other changes from the release notes:

  * Check for failures in parseFile(), perf events tweaks by tommi-cujo in martinus/nanobench#84
  * Workaround missing noexcept for std::string move assignment by tommi-cujo in martinus/nanobench#87
  * removed the link by martinus in martinus/nanobench#89
  * Lots of minor cleanups by martinus in martinus/nanobench#85
  * Add linter for version & clang-format. Updated version by martinus in martinus/nanobench#90

ACKs for top commit:
  fanquake:
    ACK fe434a4 - have not tested.

Tree-SHA512: a8f15e1db1d993673e4b295a3bab22e67ee3c9f3c0bcbef28974fe9ff37dbb741967a526088d5b148c8d25c9d57cd3b844238100c17b23038638787461805678
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 24, 2024
fe434a4 bench: Update nanobench to 4.3.11 (TheCharlatan)

Pull request description:

  The newest version fixes the false positive `* Turbo is enabled, CPU frequency will fluctuate` warning on AMD CPUs. The file was directly taken from the release page: https://github.com/martinus/nanobench/releases/tag/v4.3.11.

  Other changes from the release notes:

  * Check for failures in parseFile(), perf events tweaks by tommi-cujo in martinus/nanobench#84
  * Workaround missing noexcept for std::string move assignment by tommi-cujo in martinus/nanobench#87
  * removed the link by martinus in martinus/nanobench#89
  * Lots of minor cleanups by martinus in martinus/nanobench#85
  * Add linter for version & clang-format. Updated version by martinus in martinus/nanobench#90

ACKs for top commit:
  fanquake:
    ACK fe434a4 - have not tested.

Tree-SHA512: a8f15e1db1d993673e4b295a3bab22e67ee3c9f3c0bcbef28974fe9ff37dbb741967a526088d5b148c8d25c9d57cd3b844238100c17b23038638787461805678
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 25, 2024
fe434a4 bench: Update nanobench to 4.3.11 (TheCharlatan)

Pull request description:

  The newest version fixes the false positive `* Turbo is enabled, CPU frequency will fluctuate` warning on AMD CPUs. The file was directly taken from the release page: https://github.com/martinus/nanobench/releases/tag/v4.3.11.

  Other changes from the release notes:

  * Check for failures in parseFile(), perf events tweaks by tommi-cujo in martinus/nanobench#84
  * Workaround missing noexcept for std::string move assignment by tommi-cujo in martinus/nanobench#87
  * removed the link by martinus in martinus/nanobench#89
  * Lots of minor cleanups by martinus in martinus/nanobench#85
  * Add linter for version & clang-format. Updated version by martinus in martinus/nanobench#90

ACKs for top commit:
  fanquake:
    ACK fe434a4 - have not tested.

Tree-SHA512: a8f15e1db1d993673e4b295a3bab22e67ee3c9f3c0bcbef28974fe9ff37dbb741967a526088d5b148c8d25c9d57cd3b844238100c17b23038638787461805678
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