feat: charge properly for fetching canister logs#9905
Closed
feat: charge properly for fetching canister logs#9905
Conversation
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.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closed in favour of this one #9911