package memprof-limits

  1. Overview
  2. Docs
Memory limits, allocation limits, and thread cancellation

Install

Dune Dependency

Authors

Maintainers

Sources

memprof-limits-v0.2.1.tar.gz
md5=15026b85944ee405fe6784cc9f1575bb
sha512=6ae138bc582911ab221f8c8a4a461b58bfcb837933b989ea9f10ef8cdd54a445c300f41fa4a0ec70746a27c24ccae5598666c98195a8400bc7c5c37e9327480b

Description

Memprof-limits provides per-thread global memory limits, per-thread allocation limits, and cancellation of threads, with ways to ensure resource-safety after interruption.

Global memory limits let you bound the memory consumption of a task, in terms of the major heap size.

Allocation limits let you bound the execution time of a task measured in number of allocations. Allocation limits do not count deallocations, and are therefore a measure of the work done, which can be more suitable (reliable, portable, deterministic) than wall-clock time.

Token limits lets you cancel a (CPU-bound) task preemptively and at a distance.

Tasks are interrupted by raising an asynchronous exception. Memprof-limits provides resource-management features and guidance for reasoning about the consistency of state in the presence of such interrupts.

The implementation uses OCaml's Statmemprof engine with a low sampling rate that does not affect performance. A reimplementation of the Memprof interface compatible with Memprof-limits running at the same time is provided for profiling needs.

Published: 21 Mar 2024

README

Memprof-limits — Memory limits, allocation limits, and thread cancellation for OCaml

Memprof-limits is an implementation of (per-thread) global memory limits, (per-thread) allocation limits, and cancellation of CPU-bound threads, for OCaml. Memprof-limits interrupts a computation by raising an exception asynchronously and offers features to recover from them such as interrupt-safe resources.

The implementation uses OCaml's Memprof engine with a low sampling rate that does not affect performance.

An explanation of what must be done to ensure one recovers from a memprof-limits interrupt is provided. It summarises the experience acquired in OCaml in the Coq proof assistant, as well as in other situations in many other programming languages. To my knowledge, this has never been told in textbooks, so I thought it might be of general interest to the community.

Note: Memprof-limits does not support OCaml 5 yet.

  • Home page: https://gitlab.com/gadmm/memprof-limits/

  • Documentation: https://guillaume.munch.name/software/ocaml/memprof-limits/

  • Changes: https://gitlab.com/gadmm/memprof-limits/-/blob/master/CHANGES.md

Memprof-limits is distributed under the LGPL license version 3 with linking exception, see LICENSE.

Installation

Memprof-limits can be installed with Opam: opam install memprof-limits. It requires OCaml 4.12 or newer.

Compilation from sources is done with make. Compilation of documentation is with make doc, which requires odoc and inkscape.

Documentation

Dependencies (2)

  1. dune >= "1.2"
  2. ocaml >= "4.12.0" & < "5.0"

Dev Dependencies

None

Used by

None

Conflicts

None