Skip to content

feat(transfer): instrument encode_and_send_segment dispatch (INC_RECURSE I2)#4143

Merged
oferchen merged 1 commit into
masterfrom
feat/inc-recurse-segment-dispatch-2197
May 16, 2026
Merged

feat(transfer): instrument encode_and_send_segment dispatch (INC_RECURSE I2)#4143
oferchen merged 1 commit into
masterfrom
feat/inc-recurse-segment-dispatch-2197

Conversation

@oferchen
Copy link
Copy Markdown
Owner

Summary

No new CLI flag, no wire-format change, no change to the public encode_and_send_segment signature.

Test plan

  • cargo fmt --all
  • CI: fmt+clippy
  • CI: nextest (stable) - new tests segment_dispatch_call_counter_increments and segment_dispatch_totals_observable_without_dispatch in crates/transfer/src/generator/tests.rs
  • CI: Windows, macOS, Linux musl

Closes #2197

…RSE I2)

Adds INC_RECURSE diagnostic counter I2 (#2197): two process-global
AtomicU64 counters that track every encode_and_send_segment invocation
on the generator file-list path and the cumulative wall time spent
inside the helper across all generator transfers.

The counters fire from a single record_segment_dispatch helper bumped
from encode_and_send_segment itself, which wraps the existing body in
an Instant::now() pair. The zero-entry early-return path is still
counted so per-transfer dispatch rate stays comparable to segment
scheduler activity, but contributes a near-zero ns delta.

Totals are sampled in GeneratorContext::run via
segment_dispatch_totals() in the same finalize block used by PR #4103
(I1 first-byte latency), PR #4120 (I4 NDX partition_point), PR #4121
(I3 flush rate) and PR #4142 (I5 prepare_pending_acl), and emitted
via:

- debug_log!(Genr, 1, "generator encode_and_send_segment totals: \
  calls=N elapsed_ns=M")
- tracing::debug! event on rsync::generator::segment_dispatch when
  the optional tracing feature is enabled

Two unit tests in crates/transfer/src/generator/tests.rs cover the
new counters:

- segment_dispatch_call_counter_increments asserts the call counter
  and the cumulative elapsed_ns counter grow by at least N and
  sum-of-durations after N synthetic record_segment_dispatch
  invocations. The assertion uses >= because the counter is shared
  across the process and other tests may run concurrently.
- segment_dispatch_totals_observable_without_dispatch asserts the
  totals snapshot is a pure read - constructing a generator does not
  bump the counter on its own, so two adjacent reads with no
  intervening dispatch call must return identical values.

No new CLI flag, no wire-format change, no change to the public
encode_and_send_segment signature.

Closes #2197
@github-actions github-actions Bot added the enhancement New feature or request label May 16, 2026
@oferchen oferchen merged commit c4d619b into master May 16, 2026
39 checks passed
@oferchen oferchen deleted the feat/inc-recurse-segment-dispatch-2197 branch May 16, 2026 09:51
@oferchen oferchen mentioned this pull request May 16, 2026
oferchen added a commit that referenced this pull request May 18, 2026
…RSE I2) (#4143)

Adds INC_RECURSE diagnostic counter I2 (#2197): two process-global
AtomicU64 counters that track every encode_and_send_segment invocation
on the generator file-list path and the cumulative wall time spent
inside the helper across all generator transfers.

The counters fire from a single record_segment_dispatch helper bumped
from encode_and_send_segment itself, which wraps the existing body in
an Instant::now() pair. The zero-entry early-return path is still
counted so per-transfer dispatch rate stays comparable to segment
scheduler activity, but contributes a near-zero ns delta.

Totals are sampled in GeneratorContext::run via
segment_dispatch_totals() in the same finalize block used by PR #4103
(I1 first-byte latency), PR #4120 (I4 NDX partition_point), PR #4121
(I3 flush rate) and PR #4142 (I5 prepare_pending_acl), and emitted
via:

- debug_log!(Genr, 1, "generator encode_and_send_segment totals: \
  calls=N elapsed_ns=M")
- tracing::debug! event on rsync::generator::segment_dispatch when
  the optional tracing feature is enabled

Two unit tests in crates/transfer/src/generator/tests.rs cover the
new counters:

- segment_dispatch_call_counter_increments asserts the call counter
  and the cumulative elapsed_ns counter grow by at least N and
  sum-of-durations after N synthetic record_segment_dispatch
  invocations. The assertion uses >= because the counter is shared
  across the process and other tests may run concurrently.
- segment_dispatch_totals_observable_without_dispatch asserts the
  totals snapshot is a pure read - constructing a generator does not
  bump the counter on its own, so two adjacent reads with no
  intervening dispatch call must return identical values.

No new CLI flag, no wire-format change, no change to the public
encode_and_send_segment signature.

Closes #2197
oferchen added a commit that referenced this pull request May 18, 2026
…RSE I2) (#4143)

Adds INC_RECURSE diagnostic counter I2 (#2197): two process-global
AtomicU64 counters that track every encode_and_send_segment invocation
on the generator file-list path and the cumulative wall time spent
inside the helper across all generator transfers.

The counters fire from a single record_segment_dispatch helper bumped
from encode_and_send_segment itself, which wraps the existing body in
an Instant::now() pair. The zero-entry early-return path is still
counted so per-transfer dispatch rate stays comparable to segment
scheduler activity, but contributes a near-zero ns delta.

Totals are sampled in GeneratorContext::run via
segment_dispatch_totals() in the same finalize block used by PR #4103
(I1 first-byte latency), PR #4120 (I4 NDX partition_point), PR #4121
(I3 flush rate) and PR #4142 (I5 prepare_pending_acl), and emitted
via:

- debug_log!(Genr, 1, "generator encode_and_send_segment totals: \
  calls=N elapsed_ns=M")
- tracing::debug! event on rsync::generator::segment_dispatch when
  the optional tracing feature is enabled

Two unit tests in crates/transfer/src/generator/tests.rs cover the
new counters:

- segment_dispatch_call_counter_increments asserts the call counter
  and the cumulative elapsed_ns counter grow by at least N and
  sum-of-durations after N synthetic record_segment_dispatch
  invocations. The assertion uses >= because the counter is shared
  across the process and other tests may run concurrently.
- segment_dispatch_totals_observable_without_dispatch asserts the
  totals snapshot is a pure read - constructing a generator does not
  bump the counter on its own, so two adjacent reads with no
  intervening dispatch call must return identical values.

No new CLI flag, no wire-format change, no change to the public
encode_and_send_segment signature.

Closes #2197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant