Commit Graph

100 Commits (6a3af5c9267830444946ae7a5d0d5a2923bf555b)

Author SHA1 Message Date
Stephen Dolan 6a3af5c926 Add Gc.Memprof.allocation_source 2020-11-17 11:17:52 +00:00
Jacques-Henri Jourdan 6d3065be78 Memprof: get rid of the idx_ptr pointers.
Instead, we use a thread-local variable [callback_status] which
contains the index of the corresponding entry when a callback is
running. We can do this since there can only be one running callback
at the same time in a given thread.

This lifts the restriction forbidding the call of Thread.exit from a
memprof callback.
2020-10-19 17:11:11 +02:00
Jacques-Henri Jourdan f83d71830d Memprof: provide the guarantee that an allocation callback is always run in the same thread the allocation takes place.
This is done by using a local entry array for each thread, containing
tracked blocks whose allocation callback has not yet been called.

This allows some simplification in the code running callbacks for
young allocations. Indeed, since the entry array is local to one
thread, we know for sure that it cannot be modified during a callback,
and therefore we no longer need to remember the indices of the
corresponding new entries.
2020-10-19 17:08:17 +02:00
Jacques-Henri Jourdan d1800821df Gc.Memprof.stop does no longer try to run pending callbacks.
This is only effetive in native mode, since function calls in bytecode
mode will trigger polling and hence run pending callbacks.
2020-10-19 16:41:13 +02:00
Damien Doligez 0069123c61
clean up and fix GC message 0x1 (#9949) 2020-10-09 12:02:00 +02:00
Et7f3 c4851b0ff0
Consistently use @raise tags in Stdlib docs (#8644) 2020-06-30 14:06:45 +01:00
Leo White dfd0c0cc77 Report full major collections in Gc stats 2020-06-25 14:24:41 +01:00
Enguerrand Decorne b7f0494df5 Rewrite the instrumented runtime to store traces in the CTF format.
The instrumentation code in the instrumented runtime was replaced
with new APIs to gather runtime statistics and output them in a new format
(Common Trace Format).
This commit also exposes new functions in the Gc module to pause or resume
instrumentation during a program execution (Gc.eventlog_pause and
Gc.eventlog_resume).
2020-04-30 10:32:01 +02:00
Gabriel Scherer ff6b20098f Gc.Memprof.start: take a record instead of 5 optional parameters
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.
2020-04-01 16:37:28 +02:00
Jacques-Henri Jourdan e1a22e80fb Memprof API: cannot be start if already running, cannot be stopped if not already running. 2020-01-14 10:42:16 +01:00
Jacques-Henri Jourdan 0c8416478c Drop support for tags in memprof.
They are somewhat difficult to handle for native allocations, and it is not clear how useful they are. Moreover, they are easy to add back since [Gc.Memprof.allocation] is a private record.
2020-01-11 13:19:10 +01:00
Jacques-Henri Jourdan 7dbbfce890 New ephemeron-free API for Memprof.
The user can register several callbacks, which are called for various
events during the block's lifetime. We need to maintain a data
structure for tracked blocks in the runtime. When using threads,
callbacks can be called concurrently in a reentrant way, so the
functions manipulating this data structure need to be reentrant.
2019-12-21 10:21:48 +01:00
Gabriel Scherer 238e483eb8 better documentation for the best-fit allocation policy 2019-12-10 21:40:50 +01:00
Guillaume Munch-Maccagnoni 1220986b72 [minor] typo 2019-10-16 14:22:49 +02:00
Damien Doligez 01bdd5bbc4
best-fit allocator (#8809) 2019-10-15 13:52:16 +02:00
Jacques-Henri Jourdan 90073e96e5 Memprof tracking of interned data. 2019-08-27 19:14:56 +02:00
Jacques-Henri Jourdan 0ca84f52cd Refactor the postponed blocks machinery in memprof.c
This makes sure that:
- Callbacks are never called when another is running
- The postponed queue is purged when setting memprof parameters

We now use a FIFO implemented as a circular buffer for remembering of
postponed blocks.
2019-06-05 14:25:33 +02:00
Jacques-Henri Jourdan b838e48c39 Memprof: Instead of a Poisson process, use a binomial distribution.
The workaround used for ignoring samples in the minor heap in native
mode now makes allocation very slow (or non-terminating) when the
sampling rate is not small enough. This will be fixed when sampling in
the minor heap in native mode will be implemented.
2019-05-21 17:10:16 +02:00
Damien Doligez 1d7740f624 additional fixes for #8634 2019-05-21 12:44:10 +02:00
Damien Doligez 1aeb9b2301 typos in comments 2019-05-20 16:49:40 +02:00
Jacques-Henri Jourdan cea1ff7534 Memprof sampling for blocks in the minor heap, allocated by C code.
Allocations ignored by this version
- Marshalling
- In the minor heap by natively-compiled OCaml code

Allocations potentially sampled
- In the major heap
- In the minor heap by C code and OCaml code in bytecode mode
2019-05-20 13:04:28 +02:00
Jacques-Henri Jourdan 052a950dea Statistical memory profiling of blocks allocated in the major heap. 2019-05-09 16:40:45 +02:00
Stephen Dolan c24e5b5c8a Ensure that Gc.minor_words remains accurate after a GC (#8619)
If an allocation fails, the decrement of young_ptr should be undone
before the GC is entered. This happened correctly on bytecode but not
on native code.

This commit (squash of pull request #8619) fixes it for all the
platforms supported by ocamlopt.

amd64: add alternate entry points caml_call_gc{1,2,3} for code size
optimisation.

powerpc: introduce one GC call point per allocation size per function.
Each call point corrects the allocation pointer r31 before calling
caml_call_gc.

i386, arm, arm64, s390x: update the allocation pointer after the
conditional branch to the GC, not before.

arm64: simplify the code generator: Ialloc can assume that less than
0x1_0000 bytes are allocated, since the max allocation size for the
minor heap is less than that.

This is a partial cherry-pick of commit 8ceec on multicore.
2019-05-04 10:01:23 +02:00
Damien Doligez 9e5e37c975
deprecate the mutability of Gc.control record fields (#2145)
deprecate the mutability of Gc.control record fields
2018-11-13 13:43:34 +01:00
Damien Doligez 17b64ac2b2
Add caml_alloc_custom_mem (#1738)
* add caml_alloc_custom_mem and corresponding GC parameters
* fix a bug in tests/misc/ephetest2.ml
2018-11-06 13:42:48 +01:00
Etienne Millon 530c99838e Fix link markup in Gc.finalise_last documentation 2018-10-11 16:11:20 +02:00
Jérémie Dimino 9124ab82d1
Deprecate Pervasives (#1605)
- inline Pervasives in Stdlib and re-add Pervasives as a deprecated
module that aliases all elements of Stdlib except the stdlib modules.

- remove special case for Stdlib.Pervasives in printtyp.ml
2018-08-27 12:42:14 +01:00
Stephen Dolan f5412927ba Fix Gc.minor_{words,free} by removing [@@noalloc] 2017-03-09 14:51:09 +00:00
Daniel b9dd14cdaf fix several typos in comments 2017-02-13 17:09:50 +01:00
Damien Doligez cd303efd6a PR#7355: Gc.finalise and lazy values 2016-12-14 13:14:21 +00:00
Gabriel Scherer a1a0fe19fb missing @since tags in stdlib's Gc module 2016-12-14 13:14:21 +00:00
François Bobot bdc138cf82 Add finalise_last without special case during minor 2016-07-09 21:02:54 +02:00
Pierre Chambart 18c55e9242 Declare the Gc.minor_words external 2016-05-31 15:14:59 +02:00
Gabriel Scherer 783be07789 stdlib .mli: forgotten @since 4.03.0 2016-05-11 22:34:45 -04:00
Damien Doligez 520fb2df50 Merge tag 4.03.0 into trunk. 2016-04-28 16:13:21 +02:00
Alain Frisch 8557a86477 Also enable more warnings in stdlib/ and fix them. 2016-03-15 22:47:26 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Damien Doligez 0225ca01e3 GC latency improvements 2015-12-21 14:27:46 +01:00
Louis Gesbert 24e42d4d22 Add v=0x400 to OCAMLRUNPARAM to print more Gc stats on exit
In a format following that of Gc.print_stat. I chose to print only the "quick_stat"
values rather than call gc_ctrl.c::heap_stats because it's lighter, and the extra
information is typically not very useful at program exit.

Also adds documentation for the 0x400 flag (in man and Gc module)

This replaces the previous undocumented 0x400 that only displayed the
total (minwords + majwords - prowords) and with a different format,
since keeping both wouldn't provide more information.
2015-12-04 21:09:27 +09:00
Damien Doligez 860c670848 merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev 16205)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16214 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-07-17 14:31:05 +00:00
Damien Doligez 3d89f3ef7e PR#6664: Crash when finalising lazy values of the wrong type.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15876 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-04 19:58:49 +00:00
Mark Shinwell 830a4fba2a minor update of comment in gc.mli
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15212 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-09-11 11:17:36 +00:00
Jérémie Dimino d095ba7f89 PR#6540: update documentation of default values in gc.mli
(Patch by Daniel Richman)


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15185 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-09-03 13:35:48 +00:00
Damien Doligez cbfe627f92 merge changes from branch 4.02 from branching (rev 14852) to 4.02.0+rc1 (rev 15121)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15125 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-22 13:45:02 +00:00
Damien Doligez 9baf42b72d safe-string: documentation fixes and add a couple of functions in Pervasives and Digest
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14721 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-01 21:54:15 +00:00
Damien Doligez 9d86709547 fix major performance problem on large heaps by making the heap increment proportional to the heap size
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14442 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-02-20 13:04:01 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Alain Frisch 2845f7b7ea Typo.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12338 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-04-11 03:50:39 +00:00
Damien Doligez 7c7cad0ee2 documentation
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12011 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-01-10 20:08:38 +00:00
Damien Doligez cca0035fbb continuing to change the name to OCaml
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11922 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-12-21 15:37:54 +00:00