Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable vnode count with env var #18161

Closed
wants to merge 6 commits into from
Closed

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Aug 21, 2024

Signed-off-by: Bugen Zhao [email protected]I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

See background in #15900.

Allow configuring vnode count by setting env var RW_VNODE_COUNT.

Ideally it should be specified as an immutable system parameter. However, such approach will involve a considerable amount of code changes. So for the initial PR, I simply switch to use the environment variable. This enables support for more parallelism in RW with minimal changes.

As the cost, specifying different RW_VNODE_COUNT values for different worker nodes or different runs will lead to unexpected behavior, which can be dangerous.

There are also other limitations on the valid range of vnode counts:

  • Vnode ID is physically represented by a 16-bit integer, which limits the max vnode count to 65536.
  • Row ID generator only reserves 10 bits for vnode, which further limits the max vnode count to 1024. However, this appears to be fixable.

In future PRs, we may make it...

  • immutable, thus more robust
  • backwards compatible
  • even configurable for different streaming jobs

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
@BugenZhao BugenZhao marked this pull request as ready for review August 21, 2024 07:10
@shanicky shanicky requested a review from yezizp2012 August 21, 2024 07:14
Signed-off-by: Bugen Zhao <[email protected]>
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @BugenZhao and the rest of your teammates on Graphite Graphite

@@ -31,44 +34,82 @@ pub struct VirtualNode(VirtualNodeInner);

/// The internal representation of a virtual node id.
type VirtualNodeInner = u16;
static_assertions::const_assert!(VirtualNodeInner::BITS >= VirtualNode::BITS as u32);
// static_assertions::const_assert!(VirtualNodeInner::BITS >= VirtualNode::BITS as u32);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// static_assertions::const_assert!(VirtualNodeInner::BITS >= VirtualNode::BITS as u32);

pub fn count() -> usize {
// Cache the value to avoid repeated env lookups and parsing.
static COUNT: LazyLock<usize> = LazyLock::new(|| {
if let Ok(count) = std::env::var("RW_VNODE_COUNT") {
Copy link
Member

@fuyufjh fuyufjh Aug 22, 2024

Choose a reason for hiding this comment

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

What if the RW_VNODE_COUNT is different after restart?

Considering the vnode is persisted in storage, this will certainly cause some problems, I think. If so, I would question whether it's a good idea to pass it via env var, perhaps making it a MV argument would be better? Or at least it should be a system parameter, and should always use the first-time initialized value, like state_store_url

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right.

I had some discussion about these approaches in the original issue. Basically this PR is a quick hack if we want to unblock some users to utilize more resources for their clusters. However, if we find this niche and not that urgent, I agree that we may not merge this PR but directly implement the polished ideas, like per-job configuration or global immutable system parameter.

@BugenZhao
Copy link
Member Author

Superseded by the works of fragment-local vnode count.

@BugenZhao BugenZhao closed this Sep 11, 2024
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