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

Adapt perf package to our needs #1

Merged
merged 6 commits into from
Aug 22, 2019
Merged

Conversation

adriansr
Copy link
Contributor

This adds a few features and fixes on top of the base perf package currently on review.

Added

  • OpenWithFlags() to pass custom flags to perf_event_open(2), necessary for managing our own event groups.
  • HasRecord() to peek a ring buffer without blocking. Necessary to read multiple rings in parallel from a single goroutine.

Changes

  • Add build tags

Fixes

  • Fix bad handling of ring buffer memory.
  • Add error checking to prevent crashes due to corrupted samples.

The original source doesn't need a LICENSE in the perf package as its
part of a bigger repository. This just copies this license to the root
of the forked repo.
Use the fix I submitted to acln0/perf instead of the one suggested on
the review.
This prevents a common cause of crashes due to live ring-buffer memory
being returned by readRawRecordNonblock, which could be overwritten at
any time.

Also adds some error checks to  the ring-buffer reading.
- OpenWithFlags() constructor, similar to Open() but allows to pass
  flags to perf_event_open(2).
- HasRecord() to be able to read a sample without blocking.
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