Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

make the ws buffer size configurable #10013

Merged
12 commits merged into from
Oct 14, 2021
Merged

make the ws buffer size configurable #10013

12 commits merged into from
Oct 14, 2021

Conversation

kianenigma
Copy link
Contributor

@kianenigma kianenigma commented Oct 12, 2021

I know this is not populare, but hear me out:

I am running into similar issues as in paritytech/polkadot#2039 in staking miners, and I don't see any other clear way to fix this.

In the issue, it was mentioned that this happened due to the speed of the consumer and producer not matching. Given the 10mb default, I am pretty sure it my case it is happening because a single storage item is somewhere above 10mb.

If at least one of @tomusdrw or @bkchr give a thumb up, will remove draft and document the code a bit better. I can also group all RPC-server related params into one struct to make it cleaner.

Polkadot companion: paritytech/polkadot#4078

@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Oct 12, 2021
@kianenigma kianenigma requested a review from bkchr October 12, 2021 18:33
Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm (modulo missing docs, and refinement), we are far beyond the "don't add any RPC-related CLI options" point anyway, and config files are nowhere around the corner, so I'm okay with adding it, especially that it addresses a particular pain point you are having.

Comment on lines 130 to 132
/// Set the the maximum RPC output buffer size. Default is 10MiB.
#[structopt(long = "rpc-max-in-buffer-capacity")]
pub ws_max_in_buffer_capacity: Option<usize>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a use case for in buffer? We already have max_rpc_payload which limits that, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not in my case, but I thought it would be cleaner to make both configurable.

client/cli/src/commands/run_cmd.rs Outdated Show resolved Hide resolved
#[structopt(long = "rpc-max-in-buffer-capacity")]
pub ws_max_in_buffer_capacity: Option<usize>,

/// Set the the maximum RPC output buffer size. Default is 10MiB.
Copy link
Contributor

Choose a reason for hiding this comment

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

How does it relate to max payload setting? Wouldn't restricting it here further restrict the output max payload?

Suggested change
/// Set the the maximum RPC output buffer size. Default is 10MiB.
/// Set the the maximum RPC output buffer size in MiB. Default is 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The buffer seems to be the pre-cursor to the max-payload, at least for the output buffer. I presume you want to have your buffer size be x and your max payload size 80% of x in most cases. But now, we allow max payload to be high like 100 MiB (don't ask why, assume some teams that don't care about DOS need it :p), but with a buffer of 10 MiB your max payload is useless.

Copy link
Contributor

Choose a reason for hiding this comment

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

but with a buffer of 10 MiB your max payload is useless.

Right, perhaps best to detect such misconfiguration and quit with an error then? I think it might be confusing to see large requests fail because they are limited by some other factor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do this if you agree with setting the default buffer size to 16 MiB, with the default max payload remaining 15 MiB. Then I can add a warning if the max out buffer is ever less than max payload.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied. I think it is pretty safe, WDYT?

kianenigma and others added 2 commits October 13, 2021 10:29
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
client/cli/src/commands/run_cmd.rs Outdated Show resolved Hide resolved
kianenigma and others added 2 commits October 13, 2021 12:12
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
@kianenigma kianenigma marked this pull request as ready for review October 13, 2021 12:19
@github-actions github-actions bot added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Oct 13, 2021
@kianenigma kianenigma added B5-clientnoteworthy C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. labels Oct 13, 2021
@kianenigma kianenigma mentioned this pull request Oct 14, 2021
Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Few grumbles, but lgtm otherwise!

client/cli/src/commands/run_cmd.rs Outdated Show resolved Hide resolved
client/rpc-servers/src/lib.rs Outdated Show resolved Hide resolved
client/rpc-servers/src/lib.rs Show resolved Hide resolved
client/cli/src/commands/run_cmd.rs Outdated Show resolved Hide resolved
kianenigma and others added 2 commits October 14, 2021 12:48
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
@kianenigma
Copy link
Contributor Author

bot merge

@ghost
Copy link

ghost commented Oct 14, 2021

Waiting for commit status.

@ghost ghost merged commit 00629de into master Oct 14, 2021
@ghost ghost deleted the kiz-configurable-ws-buffer-size branch October 14, 2021 11:44
NikVolf pushed a commit to gear-tech/substrate that referenced this pull request Oct 22, 2021
* make the ws buffer size configurable

* Update client/cli/src/commands/run_cmd.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/cli/src/commands/run_cmd.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/cli/src/commands/run_cmd.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Final touches

* Apply suggestions from code review

* fix bench

* remove in buffer

* Apply suggestions from code review

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
AlastairHolmes added a commit to chainflip-io/substrate that referenced this pull request Dec 8, 2021
* make the ws buffer size configurable

* Update client/cli/src/commands/run_cmd.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/cli/src/commands/run_cmd.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/cli/src/commands/run_cmd.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Final touches

* Apply suggestions from code review

* fix bench

* remove in buffer

* Apply suggestions from code review

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants