Skip to content

Conversation

lindig
Copy link
Contributor

@lindig lindig commented May 16, 2016

This change adds optional coverage profiling using bisect_ppx. The code changes don't affect the normal (non-profiling) case. To set up the build environment for a profiling build, do:

make coverage
make

The first step rewrites the _tags file to enable code instrumentation. It can be reverted with

make uncover

See the COVERAGE.md for general information about coverage profiling. Supporting code lives in profiling/ -- it doesn't have an effect when not profiling as it only sets up an environment variable. The build requires bisect_ppx to be available. This has been added to the SPEC file and oasis as well (although this is not used).

An important code change is a handler for the SIGTERM signal to make sure the profiling code writes it data to a file before the daemon terminates.

lindig added 10 commits May 11, 2016 10:46
Bisect dumps it report by registering a function through at_exit. This
wasn't called by xenopsd. We added a handler to catch the SIGTERM signal
used by the systemd service framework to stop the service. This leads to
the profiling data being dumped.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Since opam is not used to pull in all dependencies I'm not sure this
opam file is working as intended. I've just added the biscec_ppx
dependency.

See the README for how to control where log data is written.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
We don't want all log data to end up in / where others might log, too.
This code finds a temp dir and directs bisect_ppx to log there. The
BISECT_FILE env variable can still override this.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
We need this code for the other binaries in this repo, too. Hence, it
better lives in its own module

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
To set up a build for coverage profiling, use "make coverage" followed
by "make". This should it make possible to interate this code into
the main line. Supporting code lives in profiling/. All other changes to
the code are concerned with better signal handling and should likewise
go into the main line.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
….ml)

This was missed in the previous commit.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Signed-off-by: Christian Lindig <christian.lindig@citrix.com>

(* Start the program with the libvirt backend *)
let _ =
Coverage.init "xenopsd-libvirt";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indentation does not seem right here.

@euanh
Copy link
Collaborator

euanh commented May 17, 2016

Since you are touching all the oasis auto-generated files, this would be a good opportunity to switch to oasis setup -setup-update dynamic and remove most of the auto-generated stuff.

xenstore.unix,
xenstore_transport,
xenstore_transport.unix,
oclock
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm glad you have split these out onto separate lines! Much better for resolving merges. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to move to oasis setup -setup-update dynamic in a separate step. It is not in all projects straight forward but I have tested that the proposed method works in that context, too. It's done here: https://github.com/lindig/luna-rossa.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's fine. Let's make sure we come back to it before we wrap this work up.

lindig added 2 commits May 17, 2016 10:02
Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
This was an oversight in the last commit.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
@simonjbeaumont
Copy link
Collaborator

@lindig if you think you've addressed all the review comments so far then please remove the "needs updating" label and ping @euanh

@lindig
Copy link
Contributor Author

lindig commented May 17, 2016

Can we get this merged? Since this is a testbed for more repos I'd like to see this exercised in a test.

_tags Outdated
# compile and link with package bisect_ppx
<**/*.ml{,i,y}>: pkg_bisect_ppx
<**/*.native>: pkg_bisect_ppx
# END_COVERAGE
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is what I'm most nervous about with this method.

@simonjbeaumont
Copy link
Collaborator

If @euanh is happy then I'm happy.

@simonjbeaumont
Copy link
Collaborator

49f1024 This makes me nervous at how easy it is to check this file in accidentally

@lindig
Copy link
Contributor Author

lindig commented May 19, 2016

I agree. That's why it would be better in the long run to build regular and instrumented binaries in the same build. As we discussed, I'd suggest we look into the way ocamlbuild infers compilation for a top-level xenopsd-xc.coverage binary that gets build along with xenopsd-xc.native.

@jonludlam
Copy link
Collaborator

There are still a couple of indentation slips that @euanh noticed that still need fixing. Other than that, I agree that switching modes is dangerous, but this approach is at least nicer than some we've had in the past. If we can get ocamlbuild to do a parallel coverage-enabled build all in one go, that's definitely the way we should be going, but that might take a bit more time than we have right now to sort out.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
@jonludlam jonludlam merged commit f40550e into xapi-project:master May 19, 2016
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.

4 participants