Yex.MemDebug (y_ex v0.10.6)

View Source

Native (Rust NIF) memory debugging counters for y_ex.

Counters track hot paths in the NIF layer: doc creation, subdoc map integration, YDoc reads, update encoding, subscriptions, etc.

Build y_ex from source when using this module:

RUSTLER_PRECOMPILATION_YEX_BUILD=true mix deps.compile y_ex --force

Or set the same env var when starting the application.

Summary

Functions

Enable or disable native counter recording.

Encode full document update and return {:ok, byte_size, binary}.

Inspect yrs store size metrics for a document.

Append an NDJSON line with native snapshot to path. Optional extra map is merged into the JSON payload.

Reset all native counters to zero.

Return current native counter snapshot.

Return snapshot fields as a plain map (snake_case keys).

Types

doc_info()

@type doc_info() :: %{
  guid: String.t(),
  client_id: non_neg_integer(),
  skip_gc: boolean(),
  auto_load: boolean(),
  state_vector_bytes: non_neg_integer(),
  update_encode_bytes: non_neg_integer(),
  has_worker_pid: boolean()
}

snapshot()

@type snapshot() :: %{
  enabled: boolean(),
  doc_new: non_neg_integer(),
  doc_with_options: non_neg_integer(),
  map_set_doc: non_neg_integer(),
  map_set_null: non_neg_integer(),
  map_set_other: non_neg_integer(),
  yout_ydoc_wrap: non_neg_integer(),
  monitor_update_v1: non_neg_integer(),
  monitor_update_v2: non_neg_integer(),
  monitor_subdocs: non_neg_integer(),
  sub_unsubscribe: non_neg_integer(),
  encode_state_as_update: non_neg_integer(),
  apply_update: non_neg_integer(),
  transaction_begin: non_neg_integer(),
  transaction_commit: non_neg_integer(),
  net_subdoc_integrations: integer()
}

Functions

enable(enabled)

@spec enable(boolean()) :: :ok

Enable or disable native counter recording.

encode_update_size(doc)

@spec encode_update_size(Yex.Doc.t()) :: {:ok, non_neg_integer(), binary()}

Encode full document update and return {:ok, byte_size, binary}.

inspect_doc(doc)

@spec inspect_doc(Yex.Doc.t()) :: doc_info()

Inspect yrs store size metrics for a document.

log(path, phase, extra \\ %{})

@spec log(String.t(), String.t(), map()) :: :ok

Append an NDJSON line with native snapshot to path. Optional extra map is merged into the JSON payload.

reset()

@spec reset() :: :ok

Reset all native counters to zero.

snapshot()

@spec snapshot() :: snapshot()

Return current native counter snapshot.

snapshot_map()

@spec snapshot_map() :: map()

Return snapshot fields as a plain map (snake_case keys).