Skip to content

Comments

Changing default startup settings #164

Open
dawid-nowak wants to merge 2 commits intomainfrom
dawid.nowak/changin_default_runtime_settings
Open

Changing default startup settings #164
dawid-nowak wants to merge 2 commits intomainfrom
dawid.nowak/changin_default_runtime_settings

Conversation

@dawid-nowak
Copy link
Member

No description provided.

Signed-off-by: Dawid Nowak <nowakd@gmail.com>
Signed-off-by: Dawid Nowak <nowakd@gmail.com>
Copilot AI review requested due to automatic review settings February 19, 2026 09:32
@kmesh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from dawid-nowak. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dawid-nowak, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the runtime configuration by standardizing the num_runtimes type to NonZeroUsize and setting its default to the system's CPU count, improving consistency and resource utilization. It also enhances the HTTP/2 server setup with explicit configuration for better performance and control, and addresses a minor type-related bug in the rate limiter's interval calculation.

Highlights

  • Runtime Configuration Refactor: The num_runtimes field in the runtime configuration has been changed from NonZeroU32 to NonZeroUsize and its default value now aligns with the number of available CPUs.
  • HTTP/2 Server Settings: Explicit HTTP/2 configuration, including timer, max frame size, max concurrent streams, and keep-alive interval, has been added to the HyperServerBuilder.
  • Rate Limiter Adjustment: A type casting issue in the rate limiter's fill_interval calculation was corrected to properly use the num_runtimes value.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • orion-configuration/src/config/runtime.rs
    • Updated the num_runtimes field type from NonZeroU32 to NonZeroUsize.
    • Changed the default value for num_runtimes to non_zero_num_cpus().
    • Modified the environment variable parsing for num_runtimes to expect NonZeroUsize.
  • orion-configuration/src/options.rs
    • Updated the num_runtimes option type in the Options struct from Option<NonZeroU32> to Option<NonZeroUsize>.
  • orion-lib/src/listeners/filterchain.rs
    • Imported TokioTimer for use with Hyper server.
    • Added explicit HTTP/2 configuration to HyperServerBuilder, including timer, max_frame_size, max_concurrent_streams, and keep_alive_interval.
  • orion-lib/src/listeners/rate_limiter/mod.rs
    • Adjusted the adjusted_fill_interval calculation to correctly cast runtime_config().num_runtimes.get() to u32.
Activity
  • No activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the default number of runtimes to match the number of available CPUs, which is a sensible default. The necessary type changes from NonZeroU32 to NonZeroUsize for num_runtimes are propagated consistently. My review includes two main points: first, some new HTTP/2 settings are hardcoded and should be made configurable for better maintainability. Second, there's a potentially unsafe type cast from usize to u32 that could be made safer to prevent silent data truncation.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the default startup settings for the Orion gateway, specifically modifying the num_runtimes configuration to use NonZeroUsize instead of NonZeroU32 and changing its default from 1 to the number of available CPUs. Additionally, it adds HTTP/2 protocol configuration settings to the server connection handler.

Changes:

  • Changed num_runtimes type from NonZeroU32 to NonZeroUsize for better alignment with system architecture
  • Updated default num_runtimes value from 1 to the number of detected CPUs for better resource utilization
  • Added HTTP/2 protocol configuration (timer, max_frame_size, max_concurrent_streams, keep_alive_interval) to connection handling

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
orion-configuration/src/options.rs Updated CLI option type for num_runtimes from NonZeroU32 to NonZeroUsize
orion-configuration/src/config/runtime.rs Changed num_runtimes field type, default function, parsing, and default value to use NonZeroUsize and non_zero_num_cpus()
orion-lib/src/listeners/rate_limiter/mod.rs Updated type conversion for num_runtimes from .into() to .get() as u32 to accommodate new NonZeroUsize type
orion-lib/src/listeners/filterchain.rs Added TokioTimer import and configured HTTP/2 protocol settings for server connections

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

let tokens_per_fill = token_bucket.tokens_per_fill;
let fill_interval = token_bucket.fill_interval;
let adjusted_fill_interval = fill_interval.checked_mul(runtime_config().num_runtimes.into());
let adjusted_fill_interval = fill_interval.checked_mul(runtime_config().num_runtimes.get() as u32);
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The conversion from NonZeroUsize to u32 using get() as u32 can be lossy on 64-bit systems where usize can exceed u32::MAX. This could cause silent truncation of the num_runtimes value when it's larger than 2^32-1. Consider using a safer conversion method like u32::try_from(runtime_config().num_runtimes.get()) with proper error handling, or ensuring that num_runtimes is validated to be within the u32 range at configuration time.

Copilot uses AI. Check for mistakes.
Comment on lines +227 to +232
hyper_server
.http2()
.timer(TokioTimer::new())
.max_frame_size(Some(1024 * 1024))
.max_concurrent_streams(1024)
.keep_alive_interval(Some(std::time::Duration::from_secs(2)));
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

These hardcoded HTTP/2 configuration settings (max_frame_size, max_concurrent_streams, keep_alive_interval) are being applied unconditionally to all server builders, regardless of whether the connection will use HTTP/1 or HTTP/2. This is problematic for two reasons: (1) HTTP/2-specific settings shouldn't be configured when the selected_codec is HTTP/1, and (2) as the TODO comment on line 234 indicates, these should be configurable via listener settings rather than hardcoded. Consider refactoring this to only apply HTTP/2 settings when needed and to make these values configurable through a listener-level Http2ProtocolOptions structure similar to what's available for clusters.

Suggested change
hyper_server
.http2()
.timer(TokioTimer::new())
.max_frame_size(Some(1024 * 1024))
.max_concurrent_streams(1024)
.keep_alive_interval(Some(std::time::Duration::from_secs(2)));
if !matches!(selected_codec, CodecType::Http1) {
hyper_server
.http2()
.timer(TokioTimer::new())
.max_frame_size(Some(1024 * 1024))
.max_concurrent_streams(1024)
.keep_alive_interval(Some(std::time::Duration::from_secs(2)));
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants