Movatterモバイル変換


[0]ホーム

URL:


packagemirage-profile-unix

  1. Overview
  2. Docs

You can search for identifiers within the package.

in-package search v0.2.0

Collect runtime profiling information in CTF format

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-profile-v0.9.1.tbz
sha256=2bb6cf03c73c6f45dedc34365c9131b8bdda62390b04d26eb76793a6422a0352
sha512=23cc4a2a62f5cc05b48d626bd6c8171a442fd46490da6810b1c507fcd7661c7fcd901d8328cddf687af4144136bf0d34b63f8484e32550077ab63d23e6eaea2b

Description

This library can be used to trace execution of OCaml/Lwt programs (such asMirage unikernels) at the level of Lwt threads. The traces can be viewed usingJavaScript or GTK viewers provided by [mirage-trace-viewer][] or processed bytools supporting the [Common Trace Format (CTF)][ctf].

This backend adds a Unix collector.

Published:09 Jul 2019

README

mirage-profile -- collect runtime profiling information in CTF format

This library can be used to trace execution of OCaml/Lwt programs (such as Mirage unikernels) at the level of Lwt threads. The traces can be viewed using JavaScript or GTK viewers provided bymirage-trace-viewer or processed by tools supporting theCommon Trace Format (CTF). Some example traces can be found in the blog postVisualising an Asynchronous Monad.

Libraries can use the functions mirage-profile provides to annotate the traces with extra information. When compiled against a normal version of Lwt, mirage-profile's functions are null-ops (or call the underlying untraced operation, as appropriate) and OCaml's cross-module inlining will optimise these calls away, meaning there should be no overhead in the non-profiling case.

Use with Mirage

See http://openmirage.org/wiki/profiling for instructions.

Recording traces manually

To record traces you need to pin a version of Lwt with tracing support (this provides thelwt.tracing findlib module):

$ opam pin add lwt.3.0 'https://github.com/mirage/lwt.git#tracing'

This will cause mirage-profile and any programs using it to be recompiled with tracing enabled.

To trace aUnix process, useMProf_unix.mmap_buffer to write to an mmapped file:

let () =  let buffer = MProf_unix.mmap_buffer ~size:1000000 "trace.ctf" in  let trace_config = MProf.Trace.Control.make buffer MProf_unix.timestamper in  MProf.Trace.Control.start trace_config

You'll also need to link with themirage-profile andmirage-profile-unix libraries. e.g. with thisdune file:

(executable  (name test)  (libraries mirage-profile mirage-profile-unix))

To begin tracing aXen unikernel, create a buffer and callMProf.Trace.Control.start:

let trace_pages = MProf_xen.make_shared_buffer ~size:1000000let () =   let buffer = trace_pages |> Io_page.to_cstruct |> Cstruct.to_bigarray in  let trace_config = MProf.Trace.Control.make buffer MProf_xen.timestamper in  MProf.Trace.Control.start trace_config

To share the buffer with dom0, do this somewhere in your initialisation code:

MProf_xen.share_with (module Gnt.Gntshr) (module OS.Xs) ~domid:0 trace_pages

You'll also need to link with themirage-profile andmirage-profile-xen libraries.

Viewing traces

To view the trace you should, ideally, callMProf.Trace.Control.stop before reading the buffer to avoid race conditions, but in practice reading the trace at any time usually works.

If your program crashes, you can still read the trace buffer. On Xen, you can ensure that the buffer doesn't disappear by adding these lines to your guest's config file:

on_crash = 'preserve'on_poweroff = 'preserve'

mirage-trace-viewer contains tools for saving and viewing traces, as well as ametadata description of the format, which allows the traces to be read using e.g.babeltrace.

Recording extra trace data

Programs and libraries are encouraged to record extra useful information using theMProf module. As using these functions generally has no overhead when a regular Lwt is used, there should be no need to use conditional compilation for this. See theMProf.Trace andMProf.Counter modules for documentation about what can be recorded.

Dependencies (5)

  1. ocplib-endian
  2. mtime>= "1.0.0"
  3. mirage-profile>= "0.8.0"
  4. dune>= "1.0"
  5. ocaml>= "4.06.0"

Dev Dependencies

None

Used by

None

Conflicts

None


[8]ページ先頭

©2009-2025 Movatter.jp