Skip to content

feat(cli): wire --max-alloc=N memory cap to buffer pool#3749

Merged
oferchen merged 2 commits into
masterfrom
feat/max-alloc-cli-flag
May 6, 2026
Merged

feat(cli): wire --max-alloc=N memory cap to buffer pool#3749
oferchen merged 2 commits into
masterfrom
feat/max-alloc-cli-flag

Conversation

@oferchen
Copy link
Copy Markdown
Owner

@oferchen oferchen commented May 5, 2026

Summary

  • Add parse_max_alloc_argument that validates K/M/G/T/P/E suffixes, rejects zero, and clamps at u64::MAX/4 for arithmetic safety.
  • Plumb the parsed cap into a new memory_cap field on GlobalBufferPoolConfig so init_global_buffer_pool calls BufferPool::with_memory_cap, activating backpressure on the outstanding buffer total.
  • Apply the cap at the start of run_client_internal and the server stdio entry point so both client and server enforce their own budgets, matching upstream options.c:1943-1950.
  • Forward --max-alloc=N to remote sender and daemon-server invocations and recognise it as a long server flag, matching upstream options.c:2845-2846 server_options().
  • Add --max-alloc to SUPPORTED_OPTIONS_LIST plus a help-text line documenting the suffix semantics.

Test plan

  • cargo nextest run -p cli --all-features -E 'test(parse_max_alloc)' (CI)
  • cargo nextest run -p cli --all-features -E 'test(server::tests)' (CI)
  • cargo nextest run -p engine --all-features -E 'test(buffer_pool::global)' (CI)
  • cargo nextest run -p core --all-features -E 'test(remote::invocation)' (CI)
  • Full CI matrix (fmt+clippy, nextest stable, Windows, macOS, Linux musl)

Adds enforcement for the previously parsed-but-ignored --max-alloc flag.
A new parse_max_alloc_argument validates the size suffix, rejects zero,
and clamps at u64::MAX/4 for arithmetic safety. The resolved cap is
propagated through ClientConfig into a new memory_cap field on
GlobalBufferPoolConfig, which init_global_buffer_pool feeds into
BufferPool::with_memory_cap so backpressure kicks in once outstanding
buffer memory hits the limit.

The flag is forwarded to remote sender and daemon-server invocations to
match upstream rsync's options.c:2845-2846 server_options() emission,
and the server-side parser applies the cap locally just like the
client.
@github-actions github-actions Bot added the enhancement New feature or request label May 5, 2026
@oferchen oferchen merged commit c52486a into master May 6, 2026
39 checks passed
@oferchen oferchen deleted the feat/max-alloc-cli-flag branch May 6, 2026 18:56
oferchen added a commit that referenced this pull request May 18, 2026
* feat(cli): wire --max-alloc=N memory cap to buffer pool

Adds enforcement for the previously parsed-but-ignored --max-alloc flag.
A new parse_max_alloc_argument validates the size suffix, rejects zero,
and clamps at u64::MAX/4 for arithmetic safety. The resolved cap is
propagated through ClientConfig into a new memory_cap field on
GlobalBufferPoolConfig, which init_global_buffer_pool feeds into
BufferPool::with_memory_cap so backpressure kicks in once outstanding
buffer memory hits the limit.

The flag is forwarded to remote sender and daemon-server invocations to
match upstream rsync's options.c:2845-2846 server_options() emission,
and the server-side parser applies the cap locally just like the
client.

* fix(cli): inline format args and replace useless vec! with array
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