Skip to content

Add a memtrace-enabled ocamlopt#245

Merged
mshinwell merged 7 commits intoflambda2.0-stablefrom
flambda2-ocamlopt-memtrace
Aug 21, 2020
Merged

Add a memtrace-enabled ocamlopt#245
mshinwell merged 7 commits intoflambda2.0-stablefrom
flambda2-ocamlopt-memtrace

Conversation

@Gbury
Copy link
Copy Markdown

@Gbury Gbury commented Aug 20, 2020

Probably best reviewed commit by commit.

stedolan and others added 7 commits August 20, 2020 16:15
Expose the main entrypoint in compilerlibs

(cherry picked from commit 088fa01)
The Gc.Memprof module provides a low-level API, that will hopefully be
paired with user libraries that provide high-level instrumentation
choices.

A natural question is: how are the higher-level API going to expose
their choice of instrumentation to their users? With the current
Memprof.start API (before this patch), they would have to either
provide their own `start` function wrapping Memprof.start, or provide
a tuple of callbacks for to their users to pass to Memprof.start
themselves.

    val start : params -> unit
    (* or *)
    val callback : params ->
      ((allocation -> foo option) * (allocation -> bar option) * ... )

With an explicit record, it is easier for libraries to expose an
instrumentation choice (possibility parametrized over
user-provided settings):

    val tracker : params -> (foo, bar) Gc.Memprof.tracker

In addition, providing a record instead of optional parameters makes
it much easier to provide "default settings" (helper functions) that
instantiates the types `'minor` and `'ḿajor`, see for example
`simple_tracker` in this patch (which stores the same information for
the minor and major heap, and does not observe promotion), or to later
define checking predicates that can verify that a given choice of
callbacks is sensible (for example: providing a major-dealloc callback
but no promotion callback (dropping all tracked value on promotion) is
probably not a good idea).

Bootstrap: to avoid requiring an awkward bootstrap, this commit keeps
the (now unused) function caml_memprof_start_byt unchanged -- it is
used in the bootstrap binaries, so removing it would break the
build. The intention is to remove it in the following commit.
@Gbury Gbury changed the title Add a memtrace-enable ocamlopt Add a memtrace-enabled ocamlopt Aug 20, 2020
@Gbury
Copy link
Copy Markdown
Author

Gbury commented Aug 20, 2020

Note that the memtrace-enabled ocamlopt is only built (and installed) with the Makefile build.

@mshinwell
Copy link
Copy Markdown

I think this looks ok, we'll soon find out if it's not...

@mshinwell mshinwell merged commit 18adea5 into flambda2.0-stable Aug 21, 2020
lthls pushed a commit that referenced this pull request Sep 29, 2020
* Merge pull request ocaml#9688 from stedolan/main-compiler-libs
* Gc.Memprof.start: take a record instead of 5 optional parameters
* Try and vendor memtrace
* Move memtrace to otherlibs
* Add changes to configure
* Add a memtrace-enabled ocamlopt as ocamlopt-memtrace
* Fix dune build following driver split

Co-authored-by: Stephen Dolan <sdolan@janestreet.com>
Co-authored-by: Gabriel Scherer <gabriel.scherer@gmail.com>
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