Skip to content

[feat] Make ds_max_workers configurable in YuanrongStorageClient - #157

Open
Chase-Rong wants to merge 1 commit into
Ascend:mainfrom
Chase-Rong:feat/configurable-ds-max-workers
Open

[feat] Make ds_max_workers configurable in YuanrongStorageClient#157
Chase-Rong wants to merge 1 commit into
Ascend:mainfrom
Chase-Rong:feat/configurable-ds-max-workers

Conversation

@Chase-Rong

@Chase-Rong Chase-Rong commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes the parallel-serialization worker count of Yuanrong's general KV client (GeneralKVClientAdapter.DS_MAX_WORKERS) configurable via the Yuanrong backend config instead of a hardcoded class constant.

backend:
  Yuanrong:
    ds_max_workers: 1   # worker threads for parallel serialization; 1 = serial packing
  • Default stays 1 (serial packing, introduced in [perf] Pack serially in YuanrongStorageClient (DS_MAX_WORKERS 16 -> 1) #153), so existing behavior is unchanged when the option is not set.
  • Invalid values (non-int or < 1) raise ValueError at client init.
  • Config flows through the existing path: backend.Yuanrong section → YuanrongStorageManager → YuanrongStorageClient → strategy init(config); no intermediate layers are touched.

Test

  • Verified locally: default fallback, config override, invalid-value rejection, and that mset_zero_copy forwards the configured value as num_workers to batch_encode_into.
  • pytest tests/test_yuanrong_client_zero_copy.py tests/test_serial_utils_batch_on_cpu.py tests/test_serial_utils_on_cpu.py tests/test_storage_client_factory.py: 115 passed.

@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

Chase-Rong, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 196f904a77

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


PUT_KEYS_LIMIT: int = 10_000
GET_CLEAR_KEYS_LIMIT: int = 10_000
# Default worker count for parallel serialization; override via config 'ds_max_workers'.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove the redundant one-line comment

This comment merely restates that DS_MAX_WORKERS is a configurable default, rather than explaining why the constant exists, and it occupies only one line. Delete it instead of retaining narration that violates the repository requirement that comments be why-focused and 2–4 lines long.

AGENTS.md reference: AGENTS.md:L22-L26

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

raise ValueError("Missing or invalid 'worker_port' in config")

ds_max_workers = config.get("ds_max_workers", self.DS_MAX_WORKERS)
if not isinstance(ds_max_workers, int) or ds_max_workers < 1:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject booleans as worker counts

When a YAML/config override supplies ds_max_workers: true, Python treats True as an int, so this validation accepts it even though the option is documented as a positive integer. batch_encode_into then evaluates True <= 1 and silently uses serial packing instead of reporting the invalid configuration; explicitly exclude bool or require type(ds_max_workers) is int.

AGENTS.md reference: AGENTS.md:L17-L18

Useful? React with 👍 / 👎.

enable_yr_npu_transport: false
# Number of worker threads used to serialize objects in parallel before storing
# them via the general KV client. 1 disables parallelism (serial packing).
ds_max_workers: 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also reflect in performance test config

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also reflect in performance test config

done

DS_MAX_WORKERS (worker threads for parallel serialization in
GeneralKVClientAdapter.mset_zero_copy) was a hardcoded class constant.
Read it from the Yuanrong backend config instead, keeping 1 (serial
packing) as the default, and validate that it is a positive integer.

Signed-off-by: lolo-pop <lolopop.rong@gmail.com>
@Chase-Rong
Chase-Rong force-pushed the feat/configurable-ds-max-workers branch from 196f904 to 72807a6 Compare August 21, 2026 09:57
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

Chase-Rong, thanks for your pull request. All authors of the commits have signed the CLA. 👍

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.

3 participants