Skip to content

Use perf ctlfd #320

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

Merged
merged 1 commit into from
Jul 1, 2025
Merged

Use perf ctlfd #320

merged 1 commit into from
Jul 1, 2025

Conversation

lnbrks
Copy link
Contributor

@lnbrks lnbrks commented Jan 16, 2025

Use perf controlfd to snapshot, cause snapshot-on-exit, and cleanly
shutdown perf, replacing SIGUSR2, SIGINT, and SIGTERM respectively.

Manual testing:

  • Run: breakpoints in a quick-exiting program
  • Run: snapshot-on-exit
  • Attach: breakpoints in long running program
  • Attach: snapshot-on-exit via Ctrl+C

@lnbrks lnbrks force-pushed the use-perf-controlfd branch 2 times, most recently from 3011cd4 to a66e21b Compare January 16, 2025 21:33
if should_take_snapshot
then (
match t.snapshot_behavior with
| Never -> failwith "unreachable"
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: lift this block into a let snapshot () = ..., then have the -> (true|false) branches above be -> (() | snapshot ()). That way we don't have to double-state the Never case.

else (
match when_to_snapshot with
| Magic_trace_or_the_application_terminates ->
if perf_supports_snapshot_on_exit then `at_exit `sigint else `at_exit `sigusr2
| Application_calls_a_function _ -> `function_call)
if perf_supports_snapshot_on_exit then At_exit Sigint else At_exit Sigusr2
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the ctrlfd here too?

This logic is also used for triggering on ^C; it'd be nice to get away from the buggy signal handling where we can.

@lnbrks lnbrks force-pushed the use-perf-controlfd branch from 3a9ffee to aa31f43 Compare June 27, 2025 00:19
@lnbrks lnbrks changed the title Snapshot using perf ctlfd Use perf ctlfd Jun 27, 2025
@lnbrks lnbrks marked this pull request as draft June 27, 2025 00:28
Use perf controlfd to snapshot, cause snapshot-on-exit, and cleanly
shutdown perf, replacing SIGUSR2, SIGINT, and SIGTERM respectively.

Signed-off-by: Ilana Brooks <[email protected]>
@lnbrks lnbrks force-pushed the use-perf-controlfd branch from aa31f43 to a95431c Compare June 27, 2025 16:25
@lnbrks lnbrks marked this pull request as ready for review June 27, 2025 16:25
Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@Xyene Xyene merged commit e882fb3 into janestreet:master Jul 1, 2025
2 checks passed
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