Skip to content

Snapshot using 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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lnbrks
Copy link

@lnbrks lnbrks commented Jan 16, 2025

No description provided.

@lnbrks lnbrks force-pushed the use-perf-controlfd branch from 06c7943 to 3011cd4 Compare January 16, 2025 21:17
Signed-off-by: Ilana Brooks <[email protected]>
@lnbrks lnbrks force-pushed the use-perf-controlfd branch from 3011cd4 to a66e21b Compare January 16, 2025 21:33
@@ -0,0 +1,80 @@
open Core
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
open Core
open! Core


let close_perf_side_fds t =
Core_unix.close ~restart:true t.ctl_rx;
t.ctl_rx <- Core_unix.File_descr.of_int (-1);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: let's make these options.

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.

(String.equal
ack_msg
(Bytes.unsafe_to_string ~no_mutation_while_string_reachable:t.ack_buf))
then failwith "Receive malformed ack from perf";
Copy link
Member

Choose a reason for hiding this comment

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

This will be very hard to debug if it ever raises. Let's turn this into a raise_s and include the ack we did get.

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.

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