Fathom.Facts (fathom v0.1.0)

Copy Markdown View Source

The in-memory fact buffer that the compiler tracer writes into.

Tracers run concurrently inside the compiler's own processes, so this is a public ETS table rather than a process. Sending a message per traced event would serialise the whole compilation behind one mailbox.

Facts are stored as {partition_key, fact} in a :duplicate_bag. The partition key is the module being compiled, which spreads writes across buckets instead of hammering a single key; nothing reads facts back by key, Fathom.Store folds over the whole table at dump time.

Summary

Functions

Number of facts currently buffered.

Drops the table.

Creates the fact table, replacing any table left over from a previous run.

Records a fact under the given partition key. Called from compiler processes.

Folds fun over every fact. Order is unspecified.

Whether the table exists, i.e. whether a build is in progress.

Returns every fact as a list. Prefer reduce/2 on large codebases.

Functions

count()

Number of facts currently buffered.

destroy()

Drops the table.

init()

Creates the fact table, replacing any table left over from a previous run.

put(partition, fact)

Records a fact under the given partition key. Called from compiler processes.

Returns :ok rather than the true from :ets.insert/2, because the compiler requires every tracer callback to return :ok and the tracer clauses tail-call straight into this.

reduce(acc, fun)

Folds fun over every fact. Order is unspecified.

started?()

Whether the table exists, i.e. whether a build is in progress.

to_list()

Returns every fact as a list. Prefer reduce/2 on large codebases.