Skip to content

Conversation

@shanicky
Copy link
Contributor

@shanicky shanicky commented Dec 5, 2025

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

linear_curves

Summary
This PR introduces a new LinearCurve variant to the AdaptiveParallelismStrategy enum, enabling flexible piecewise-linear mapping from available parallelism to target parallelism ratio. It enhances the system's ability to finely control parallelism scaling behavior beyond existing fixed or ratio-based strategies.

Details

  • Adds LinearCurve and LinearCurvePoint structs representing piecewise-linear curves with validated points sorted by available parallelism.
  • Extends parsing logic to support complex string inputs like LINEAR_CURVE(0:0,10:0.5,20:0.8) with automatic padding at boundaries for robustness.
  • Implements interpolation to compute target parallelism ratios dynamically based on current available parallelism, clamping or interpolating as needed.
  • Updates compute_target_parallelism to handle the new strategy, impacting adaptive parallelism decisions across the system.
  • Introduces a new error variant to handle parsing and validation errors specific to linear curves.
  • Adds comprehensive unit tests covering parsing, interpolation, edge cases, and error conditions to ensure correctness and resilience.

By the way, this curve doesn't necessarily need to keep increasing; it can even be used to draw a sine curve.

linear_curves

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.

Documentation

  • My PR needs documentation updates.
Release note

Add a linear_curve to the adaptive parallelism strategy, allowing users to customize the scaling curve.

Introduce a new AdaptiveParallelismStrategy variant `LinearCurve` that allows
fine-grained control of target parallelism via piecewise linear interpolation.
This enables smooth, custom scaling of parallelism ratios based on available
parallelism, improving flexibility over existing fixed or bounded strategies.

- Add `LinearCurve` and `LinearCurvePoint` data structures with interpolation
- Implement parsing of `linear_curve(a:r,...)` syntax with validation and padding
- Support serialization/deserialization preserving existing string format style
- Calculate target parallelism by interpolating ratio and scaling current value
- Add comprehensive unit tests covering parsing, interpolation, errors, and ordering

Signed-off-by: Peng Chen <[email protected]>
Refactor interpolation and padding logic in the linear curve strategy for
better correctness and code clarity. Modernize Rust idioms to enhance
readability and maintainability. Add comprehensive unit and integration
tests to verify interpolation behavior and system parameter effects.

- Replace explicit range checks with idiomatic `.contains()` usage
- Use `if let ... && ...` pattern and `.unwrap_or_else()` for cleaner code
- Add detailed comments explaining interpolation and padding logic
- Ensure padding points at 0 and 1 cores are properly inserted via interpolation
- Add unit tests for interpolation helper and LinearCurve interpolation
- Enhance integration tests with standard config and total cores encapsulation
- Add new integration test covering linear curve adaptive strategy behavior

Signed-off-by: Peng Chen <[email protected]>
@github-actions github-actions bot added the type/feature Type: New feature. label Dec 5, 2025
Escape square brackets in the `LinearCurve` struct doc comment from `[0,1]`
to `\[0,1\]` to prevent Rustdoc from interpreting them as Markdown links.

- Fixes potential Rustdoc warnings about malformed link syntax
- Ensures correct rendering of the target ratio range in generated docs
- Improves documentation clarity without affecting code behavior

Signed-off-by: Peng Chen <[email protected]>
Enhance error reporting in the `parse_linear_curve` function by using the
`AsReport` trait to format parsing errors more clearly and consistently.

- Import `thiserror_ext::AsReport` to enable richer error descriptions
- Replace direct error display with `e.as_report()` in error formatting
- Improve clarity and detail of error messages when parsing fails
- Maintain backward compatibility with no behavioral changes or API impact

Signed-off-by: Peng Chen <[email protected]>
Improve error handling in `parse_linear_curve` by explicitly specifying the
error types in the `map_err` closures when parsing numeric values from strings.

- Annotate parse errors as `ParseIntError` and `ParseFloatError` explicitly
- Enhance code clarity and compiler type inference for error handling
- Maintain detailed error reporting via `as_report()` without changing logic
- Address potential compiler or linter warnings about ambiguous error types

Signed-off-by: Peng Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature Type: New feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants