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: supports auto as default value for some mito configs #4513

Closed
wants to merge 4 commits into from

Conversation

killme2008
Copy link
Contributor

@killme2008 killme2008 commented Aug 5, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

#4497

What's changed and what's your intention?

Main changes:

  • Adds a macro define_mem_size_enum to define an enum type, which supports auto, unlimited, and ReadableSize. When it's auto, its value is determined by system memory size, factor, and maximum size.
  • Use define_mem_size_enum to define global_buffer_size, page_cache_size etc.
  • Update sample configurations.
  • Fixed /config HTTP API returning the wrong value in standalone mode.
  • When the default value is auto, make /config to return the actual value.
  • information_schema is read-only currently, updated export_metrics.self_import.db to greptime_metrics.
  • Adds http configs to the datanode sample config file.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Copy link
Contributor

coderabbitai bot commented Aug 5, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added docs-not-required This change does not impact docs. docs-required This change requires docs update. and removed docs-not-required This change does not impact docs. labels Aug 5, 2024
@killme2008 killme2008 marked this pull request as ready for review August 5, 2024 23:35
@killme2008 killme2008 requested review from evenyag, v0y4g3r, waynexia and a team as code owners August 5, 2024 23:35
@killme2008 killme2008 requested review from zyy17, evenyag and zhongzc and removed request for a team, v0y4g3r, evenyag and waynexia August 5, 2024 23:35
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 91.73554% with 10 lines in your changes missing coverage. Please review.

Project coverage is 84.74%. Comparing base (d64cc79) to head (f55f1de).
Report is 54 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4513      +/-   ##
==========================================
- Coverage   85.00%   84.74%   -0.27%     
==========================================
  Files        1084     1085       +1     
  Lines      193935   193996      +61     
==========================================
- Hits       164859   164404     -455     
- Misses      29076    29592     +516     

Copy link
Contributor

@evenyag evenyag left a comment

Choose a reason for hiding this comment

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

The "auto" option may not be the best solution. We might need to find a way to support the example config more properly.

Comment on lines +181 to +182
#[allow(clippy::from_over_into)]
impl Into<FrontendOptions> for StandaloneOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not implement From<StandaloneOptions> for FrontendOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because StandaloneOptions is only defined in cmd, I don't want to make frontend depend on cmd.

Comment on lines +116 to +121
## The runtime options.
[runtime]
## The number of threads to execute the runtime for global read operations.
global_rt_size = 8
## The number of threads to execute the runtime for global write operations.
compact_rt_size = 4
Copy link
Contributor

@evenyag evenyag Aug 6, 2024

Choose a reason for hiding this comment

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

@zyy17 Maybe toml2docs can provide a special marker so that we can comment out some options. e.g.

Suggested change
## The runtime options.
[runtime]
## The number of threads to execute the runtime for global read operations.
global_rt_size = 8
## The number of threads to execute the runtime for global write operations.
compact_rt_size = 4
## toml2docs:example-start
## The runtime options.
## [runtime]
## ## The number of threads to execute the runtime for global read operations.
## global_rt_size = 8
## ## The number of threads to execute the runtime for global write operations.
## compact_rt_size = 4
## toml2docs:example-end

We can also choose a special marker like ###, ##!.

##! global_rt_size = 8
##! example_option = "test"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeap, it's one of the solution that I'm plan to do.

Comment on lines +52 to +54
define_mem_size_enum!(
/// Global write buffer size threshold to trigger flush.
GlobalWriteBufferSize, GLOBAL_WRITE_BUFFER_SIZE_FACTOR, ReadableSize::gb(1), Some(ReadableSize::gb(1)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to support unlimited size for all options? Also, if we decouple the example config from the default value, we can use the auto value by not specifying this option in the TOML. Then we can still use ReadableSize.

Also, there is an issue with the mem size enum: We can't precompute the size while the enum is Auto. We need to compute the size each time we call as_bytes().

We may also have some options that we want to disable by default and can't get the default value automatically.

Maybe a better way is to support our requirements in https://github.com/zyy17/toml2docs

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 thought we could remove the unlimited, what do you think? @zhongzc .

We can't precompute the size while the enum is Auto. We need to compute the size each time we call as_bytes().

Yes, but I think that is good. We don't call it many times.

Copy link
Contributor

@evenyag evenyag Aug 7, 2024

Choose a reason for hiding this comment

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

We need to define a new type for each size just because we need a different default value. At least we can define a function for each default value and provide a method for get_or_default().

enum AutoReadableSize {}

let size = AutoReadableSize::Auto;
let x = size.get_or_default(default_global_write_buffer_size);

unlimited is useful for threshold. Maybe we can define another type like AutoReadableSize.

Copy link
Collaborator

@zyy17 zyy17 left a comment

Choose a reason for hiding this comment

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

LGTM. Nice refactoring.

@@ -561,7 +568,7 @@ impl StartCommand {

let (tx, _rx) = broadcast::channel(1);

let servers = Services::new(fe_opts, Arc::new(frontend.clone()), plugins)
let servers = Services::new(opts, Arc::new(frontend.clone()), plugins)
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-blocking: We also can remove the clone of fe_opts in L543.

@zyy17
Copy link
Collaborator

zyy17 commented Aug 6, 2024

The "auto" option may not be the best solution. We might need to find a way to support the example config more properly.

Why is it not a good solution? IMO, taking auto as default is natural.

@evenyag
Copy link
Contributor

evenyag commented Aug 7, 2024

The "auto" option may not be the best solution. We might need to find a way to support the example config more properly.

Why is it not a good solution? IMO, taking auto as default is natural.

Mentioned in #4513 (comment)

We also have to define a new type for each size in this way, just because we need a different default value. @zyy17

@killme2008 killme2008 closed this Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-required This change requires docs update.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants