Skip to content

refactor: resolve the DSM-11 canister log TODOs - #11210

Merged
mraszyk merged 2 commits into
masterfrom
mraszyk/resolve-dsm-11-todos
Aug 20, 2026
Merged

refactor: resolve the DSM-11 canister log TODOs#11210
mraszyk merged 2 commits into
masterfrom
mraszyk/resolve-dsm-11-todos

Conversation

@mraszyk

@mraszyk mraszyk commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Two follow-ups left behind by the canister log memory store work:

  • Move the hardcoded LOG_RESIZE_COST_PER_BYTE out of canister_manager.rs into SchedulerConfig as canister_log_resize_instructions_per_byte (default DEFAULT_CANISTER_LOG_RESIZE_INSTRUCTIONS_PER_BYTE = 32), threaded through CanisterMgrConfig. The TODO suggested CyclesAccountManagerConfig, but that config holds only Cycles denominated fees while this is an instruction cost per byte, so it belongs next to upload_wasm_chunk_instructions and the canister_snapshot_*_instructions knobs. The integration test no longer hardcodes the value either.

  • Drop the aggregate flavour of CanisterLog, which the migration to LogMemoryStore (completed in refactor: drop the legacy canister_log store from SystemState #10821) made dead: new_aggregate, default_aggregate, CanisterLog::append_delta_log, clear, retention (superseded by LogMemoryStore::retention, already used by the metric) and the Records helpers that only served them. Records::from collapses into Records::new(byte_capacity) as every remaining constructor starts out empty. CanisterLog is now purely the per-message delta buffer, as its doc comment now states.

    The aggregate append tests are dropped, as the surviving behaviour is covered by the LogMemoryStore::append_delta_log tests; the rest are rewritten against the delta constructors, with new coverage for capacity capping and take().

Two follow-ups left behind by the canister log memory store work:

- Move the hardcoded `LOG_RESIZE_COST_PER_BYTE` out of
  `canister_manager.rs` into `SchedulerConfig` as
  `canister_log_resize_instructions_per_byte` (default
  `DEFAULT_CANISTER_LOG_RESIZE_INSTRUCTIONS_PER_BYTE` = 32), threaded
  through `CanisterMgrConfig`. The TODO suggested
  `CyclesAccountManagerConfig`, but that config holds only `Cycles`
  denominated fees while this is an instruction cost per byte, so it
  belongs next to `upload_wasm_chunk_instructions` and the
  `canister_snapshot_*_instructions` knobs. The value is kept non-zero on
  system subnets as well, so charging is unchanged everywhere. The
  integration test no longer hardcodes the value either.

- Drop the aggregate flavour of `CanisterLog`, which the migration to
  `LogMemoryStore` (completed in #10821) made dead: `new_aggregate`,
  `default_aggregate`, `CanisterLog::append_delta_log`, `clear`,
  `retention` (superseded by `LogMemoryStore::retention`, already used by
  the metric) and the `Records` helpers that only served them.
  `Records::from` collapses into `Records::new(byte_capacity)` as every
  remaining constructor starts out empty. `CanisterLog` is now purely the
  per-message delta buffer, as its doc comment now states.

  The aggregate append tests are dropped, as the surviving behaviour is
  covered by the `LogMemoryStore::append_delta_log` tests; the rest are
  rewritten against the delta constructors, with new coverage for
  capacity capping and `take()`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… subnets

- Add `test_canister_log_add_record_evicts_multiple_oldest_records`, which
  covers the `Records::make_free_space_within_limit` loop evicting several
  records at once while leaving survivors: it fills a delta log with twenty
  100-byte records (no eviction yet), then adds a single large record sized
  so that exactly fourteen of them still fit next to it, and asserts the six
  oldest were evicted, the surviving indices are the contiguous newest tail,
  the large content was not truncated, and `next_idx` counts them all. The
  record sizes are derived from `RECORD_SIZE` and the test capacity, with
  compile-time asserts pinning down the setup so it cannot silently
  degenerate if `CanisterLogRecord` grows a field.

  The existing `test_canister_log_add_record_applies_memory_limit` only
  covers the degenerate case where every record fills the whole capacity, so
  exactly one predecessor is evicted per push. The multi-eviction case used
  to be covered indirectly by the aggregate `append_delta_log` tests dropped
  in c6a24fa; the `LogMemoryStore` tests that superseded them exercise
  the ring buffer, not this eviction loop.

- Set `canister_log_resize_instructions_per_byte` to zero on system subnets,
  in line with `upload_wasm_chunk_instructions` and the
  `canister_snapshot_*_instructions` knobs next to it. This drops the log
  resize charge on system subnets, which c6a24fa had deliberately kept
  non-zero there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment thread rs/execution_environment/src/canister_manager.rs
@mraszyk
mraszyk marked this pull request as ready for review August 19, 2026 13:43
@mraszyk
mraszyk requested a review from a team as a code owner August 19, 2026 13:43
@zeropath-ai

zeropath-ai Bot commented Aug 19, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 9f9fbd1.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/config/src/subnet_config.rs
    Add DEFAULT_CANISTER_LOG_RESIZE_INSTRUCTIONS_PER_BYTE and integrate canister_log_resize_instructions_per_byte into SchedulerConfig and related defaults
► rs/execution_environment/src/canister_manager.rs
    Use per-byte log resize instruction cost from config instead of hard-coded constant
► rs/execution_environment/src/canister_manager/tests.rs
    Update test to use DEFAULT_CANISTER_LOG_RESIZE_INSTRUCTIONS_PER_BYTE from config
► rs/execution_environment/src/canister_manager/types.rs
    Add canister_log_resize_instructions_per_byte field to CanisterMgrConfig
► rs/execution_environment/src/lib.rs
    Pass canister_log_resize_instructions_per_byte to setup/config wiring
► rs/execution_environment/tests/canister_logging.rs
    Import DEFAULT_CANISTER_LOG_RESIZE_INSTRUCTIONS_PER_BYTE and use in tests
► rs/types/types/src/canister_log.rs
    Refactor Records and CanisterLog to simplify initialization paths (smaller, more explicit constructors); remove aggregate-specific logic and related helpers
► rs/types/types/src/canister_log.rs(二次分岐)
    Adjust tests to align with new delta/log initialization interfaces and per-byte resize cost usage

Comment thread rs/config/src/subnet_config.rs
@mraszyk
mraszyk added this pull request to the merge queue Aug 20, 2026
Merged via the queue into master with commit dd1e67e Aug 20, 2026
44 checks passed
@mraszyk
mraszyk deleted the mraszyk/resolve-dsm-11-todos branch August 20, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants