ic icon indicating copy to clipboard operation
ic copied to clipboard

feat: [CON-1567,CON-1568,CON-1570] add some load metrics to `CanisterMetrics` in the replicated states + tools which use them

Open kpop-dfinity opened this issue 1 month ago • 0 comments

These tools/metrics could be later used to determine how to split a subnet, if necessary.

Metrics tracked per canister

Added the following metrics to the CanisterMetrics in the Replicated State:

  1. Number of ingress messages executed (8 bytes)
  2. Number of xnet requests/responses executed (8 bytes)
  3. Number of intranet requests/responses executed (8 bytes)
  4. Number of http outcalls executed (8 bytes)
  5. Total number of instructions executed (8 bytes)

Note: In total they increase the size of the replicated state by 40 bytes per canister.

Further steps

In a subsequent PR, we will also keep track of which canisters each canister exchanges messages with.

ic-state-tool

Added a new command which takes as an argument a path to a state checkpoint and outputs the above metrics to a specified file, in a CSV format.

INFO: Running command line: bazel-bin/rs/state_tool/state-tool canister_metrics --help
Extracts canister metrics from the replicated state and prints them in CSV format to the specified file

Usage: state-tool canister_metrics --checkpoint <PATH> --output <OUTPUT> --subnet-type <SUBNET_TYPE>

Options:
      --checkpoint <PATH>          Path to a checkpoint
      --output <OUTPUT>            Output path
      --subnet-type <SUBNET_TYPE>  Type of the subnet
  -h, --help                       Print help

ic-subnet-splitting-tool

Added a new command which takes the extracted metrics as an argument and estimates what the load would look like after splitting the subnet.

INFO: Running command line: bazel-bin/rs/recovery/subnet_splitting/subnet-splitting-tool estimate --help
Estimate the states' sizes and loads after splitting the subnet

Usage: subnet-splitting-tool estimate [OPTIONS] --canister-id-ranges-to-move <CANISTER_ID_RANGES_TO_MOVE>... --state-manifest-path <STATE_MANIFEST_PATH> --load-samples-path <LOAD_SAMPLES_PATH>

Options:
      --canister-id-ranges-to-move <CANISTER_ID_RANGES_TO_MOVE>...
          The canister ID ranges to be moved to the destination subnet
      --state-manifest-path <STATE_MANIFEST_PATH>
          Path to a state manifest computed from the state on the source subnet. Needed to compute the sizes of canisters
      --load-samples-path <LOAD_SAMPLES_PATH>
          Path to a CSV file containing a sample of load metrics on the source subnet
      --load-samples-reference-path <LOAD_SAMPLES_REFERENCE_PATH>
          Optional path to a CSV file containing a sample of load metrics on the source subnet. If present, we will look at the difference between metrics at [`EstimateArgs::load_samples_path`] and [`EstimateArgs::load_samples_reference_path`]
  -h, --help
          Print help

Tests

Added an integration test between IC <> State Tool <> Subnet Splitting Tool

kpop-dfinity avatar Dec 16 '25 09:12 kpop-dfinity