Juggernaut.Peer.Footprint (Juggernaut v0.4.0)

Copy Markdown View Source

Which of the project's functions a job executed (design notes §7.3): the footprint a cached kill rests on.

Recorded with call-count tracing in a trace session of its own (docs/dependencies/trace-call-count.md), so it never touches the default session a test may use, and no process needs trace flags. The first measured job of a worker loads every module of the project's applications whose source is under the worker's directory (the sandbox), and turns call counting on for each, once; every measured job then sets the counters to zero, runs, and reads the functions whose count rose.

A function whose counting is off when read (its module was loaded again during the job) makes the footprint :incomplete: the controller then records no cache entry, never one resting on part of what ran.

This module runs inside workers and is never mutated.

Summary

Functions

Turns call counting on for modules (those with a source under the current directory) once per VM, and returns the armed state: the session and every function counted.

Arms call counting for the project's applications (Juggernaut.Peer.Boot.state/0) and returns :ok; a no-op once armed. The worker calls it before a measured job.

Ends counting and forgets the armed state (for tests).

Runs fun and returns {its result, the footprint} when measure?, else {its result, nil}. The footprint is a list of {source, module, fun, arity} (sources relative to the current directory) or :incomplete. apps are the project's applications.

The loaded modules of apps whose source is under the current directory.

Types

function_ref()

@type function_ref() :: {String.t(), module(), atom(), arity()}

Functions

arm(modules)

@spec arm([module()]) :: %{
  session: term(),
  functions: [{module(), atom(), arity(), String.t()}]
}

Turns call counting on for modules (those with a source under the current directory) once per VM, and returns the armed state: the session and every function counted.

arm_apps()

@spec arm_apps() :: :ok

Arms call counting for the project's applications (Juggernaut.Peer.Boot.state/0) and returns :ok; a no-op once armed. The worker calls it before a measured job.

disarm()

@spec disarm() :: :ok

Ends counting and forgets the armed state (for tests).

measure(bool, apps, fun)

@spec measure(boolean(), [atom()], (-> result)) ::
  {result, [function_ref()] | :incomplete | nil}
when result: term()

Runs fun and returns {its result, the footprint} when measure?, else {its result, nil}. The footprint is a list of {source, module, fun, arity} (sources relative to the current directory) or :incomplete. apps are the project's applications.

modules_of(apps)

@spec modules_of([atom()]) :: [module()]

The loaded modules of apps whose source is under the current directory.