Skip to content

feat: charge properly for fetching canister logs#9905

Closed
maksymar wants to merge 11 commits intomasterfrom
maksym/fetch-logs-bench
Closed

feat: charge properly for fetching canister logs#9905
maksymar wants to merge 11 commits intomasterfrom
maksym/fetch-logs-bench

Conversation

@maksymar
Copy link
Copy Markdown
Contributor

@maksymar maksymar commented Apr 16, 2026

closed in favour of this one #9911

Add Criterion benchmarks measuring the cost of fetch_canister_logs
query calls at varying buffer sizes (128 KiB, 1 MiB, 2 MiB) and
record sizes (0-byte worst case, 100-byte realistic).

Extract shared setup into setup_canister_with_full_log(), reused by
both existing resize benchmarks and the new fetch benchmarks.

The current fetch_canister_logs fees are placeholders (PR #7033).
These benchmarks will provide the measurements needed to calibrate
them before enabling the feature.
@github-actions github-actions bot added the feat label Apr 16, 2026
maksymar and others added 10 commits April 16, 2026 13:34
Update fetch_canister_logs fee constants from placeholder values to
benchmark-calibrated ones:
- base_fee: 1_000_000 -> 20_000_000 (fixed overhead per call)
- per_byte_fee: 800 -> 32 (variable cost per response byte)

Add two tests for inter-canister fetch_canister_logs update calls:
- Rejected with insufficient cycles
- Cycles are properly deducted with overpayment refunded
The previous benchmark used query_as() which bypasses the update call
path and executes faster. The fetch_canister_logs fee applies to
inter-canister update calls, so the benchmark must measure that path.

Changes:
- setup_fetch_bench() now creates a StateMachine with
  replicated_inter_canister_log_fetch enabled, a universal canister
  (caller), and a target canister with filled logs
- run_bench_fetch_canister_log() uses the caller to make an
  inter-canister update call to ic_00 fetch_canister_logs
- Add baseline benchmark (canister_status via same inter-canister
  path) to isolate fetch cost from call overhead
Add a baseline that calls update_settings with the same log_memory_limit
(no-op resize). This measures pure update_settings overhead so the actual
resize cost can be isolated by subtraction.
Previous values (20M base, 32/byte) were derived from query-path
measurements which underestimated the cost. New values are derived
from inter-canister update call benchmarks with baseline subtraction:

- base_fee: 20_000_000 -> 10_000_000 (fixed overhead ~3ms)
- per_byte_fee: 32 -> 80 (variable cost ~28 ns/byte for 100B records)

Includes 1.4x safety margin over devenv measurements.
Max upfront payment on 13-node subnet: ~2.3B cycles (was ~20.8B).
…arks

Increase warm-up from 1s to 3s/5s and set explicit measurement_time
(12s/35s) so criterion's target time matches actual runtime. This
eliminates spurious warnings, ensures sufficient warm-up samples, and
improves CI precision for the fetch benchmarks.
- base_fee: 10_000_000 -> 5_000_000
- per_byte_fee: 80 (unchanged)
@maksymar maksymar closed this Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant