Conversation
Signed-off-by: Dawid Nowak <nowakd@gmail.com>
Signed-off-by: Dawid Nowak <nowakd@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @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 Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_runtimestype fromNonZeroU32toNonZeroUsizefor better alignment with system architecture - Updated default
num_runtimesvalue 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); |
There was a problem hiding this comment.
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.
| 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))); |
There was a problem hiding this comment.
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.
| 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))); | |
| } |
No description provided.