Skip to content

speed up cli startup #542

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

speed up cli startup #542

wants to merge 5 commits into from

Conversation

aantn
Copy link
Contributor

@aantn aantn commented Jun 19, 2025

No description provided.

@aantn aantn requested a review from moshemorad June 19, 2025 11:57
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

Walkthrough

The change removes an extraneous blank line in holmes/__init__.py. The HTTP GET request timeout in fetch_holmes_info was reduced from 2 seconds to 0.3 seconds and the function was decorated with @cache for memoization. The Config class gained a log_useful_info method, and its loading methods were refactored to log loaded model keys after instantiation.

Changes

File(s) Change Summary
holmes/init.py Removed extraneous blank line after __version__ assignment.
holmes/clients/robusta_client.py Reduced HTTP GET timeout in fetch_holmes_info from 2s to 0.3s; added @cache decorator; commented out logging in exception handler.
holmes/config.py Added log_useful_info method to Config; refactored load_from_file and load_from_env to instantiate then log loaded model keys before returning.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Config
    participant Logger

    User->>Config: load_from_file()/load_from_env()
    Config->>Config: Instantiate Config object (result)
    Config->>Config: result.log_useful_info()
    Config->>Logger: Log loaded model keys
    Config-->>User: Return Config instance
Loading
sequenceDiagram
    participant Caller
    participant robusta_client

    Caller->>robusta_client: fetch_holmes_info()
    Note right of robusta_client: First call performs HTTP GET (0.3s timeout) and caches result
    Caller->>robusta_client: fetch_holmes_info()
    Note right of robusta_client: Subsequent calls return cached value
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
holmes/config.py (1)

143-145: Good addition for configuration visibility.

The log_useful_info method provides useful debugging information about loaded models and version status immediately after configuration loading.

Minor style improvement needed.

Add proper spacing between methods according to PEP 8 conventions.

         }
+
     def log_useful_info(self):
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9216a7b and 6922274.

📒 Files selected for processing (3)
  • holmes/__init__.py (2 hunks)
  • holmes/clients/robusta_client.py (1 hunks)
  • holmes/config.py (3 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
holmes/clients/robusta_client.py

[refactor] 12-12: Too few public methods (0/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
🔇 Additional comments (7)
holmes/clients/robusta_client.py (3)

4-4: Good addition for performance optimization.

Adding the @cache decorator import supports the memoization strategy for CLI startup optimization.


9-9: Verify timeout reduction doesn't cause excessive failures.

The timeout was reduced from 2 seconds to 0.3 seconds, which is quite aggressive. While this improves CLI startup speed, it may cause more failures on slower networks.

Consider monitoring failure rates after this change, especially in environments with higher network latency. You might want to make this configurable or find a balance between speed and reliability.


17-17: Excellent use of caching for CLI performance.

The @cache decorator prevents redundant network calls during CLI execution, which aligns perfectly with the PR objective to speed up CLI startup.

holmes/__init__.py (2)

5-5: Good addition for performance optimization.

Adding the @cache decorator import enables memoization of expensive operations.


15-15: Perfect candidate for caching.

The @cache decorator on get_version() is an excellent optimization. This function performs expensive subprocess calls and file I/O that don't need to be repeated during a single CLI execution.

holmes/config.py (2)

174-182: Well-structured config loading with logging.

The refactored approach properly instantiates the config object first, then calls log_useful_info() before returning. This ensures immediate visibility of loaded configuration details.


212-214: Consistent logging implementation.

Good consistency with the load_from_file method by calling log_useful_info() after config instantiation.

mainred
mainred previously approved these changes Jun 25, 2025
@aantn
Copy link
Contributor Author

aantn commented Jun 25, 2025

@mainred do you mind re-approving? (nothing substantial changed, but I had to resolve a merge conflict so the review is stale)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
holmes/clients/robusta_client.py (1)

16-16: LGTM: Caching prevents duplicate expensive network calls.

The caching decorator addresses the issue where model_post_init is called twice in certain flows, preventing duplicate expensive network calls. This change was previously discussed and confirmed safe for both CLI and server usage.

🧹 Nitpick comments (1)
holmes/clients/robusta_client.py (1)

24-24: Consider the trade-off between performance and observability.

Commenting out the logging statement improves performance but reduces observability when API calls fail. This aligns with the CLI startup speed objective, but consider whether this information might be valuable for debugging connectivity issues.

If debugging information is needed, consider using a debug-level log instead of removing it entirely:

-        # logging.info("Failed to fetch holmes info")
+        logging.debug("Failed to fetch holmes info")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dcefe2 and 1852b54.

📒 Files selected for processing (1)
  • holmes/clients/robusta_client.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
holmes/clients/robusta_client.py

[refactor] 11-11: Too few public methods (0/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: llm_evals
🔇 Additional comments (2)
holmes/clients/robusta_client.py (2)

3-3: LGTM: Import addition supports caching functionality.

The import is necessary for the @cache decorator and is correctly placed.


8-8: Verify the timeout reduction is sufficient for typical conditions.

The timeout was reduced from 2 seconds to 0.3 seconds, which is quite aggressive. While this supports the CLI startup speed improvement goal, ensure this timeout is sufficient for typical network conditions and API response times to avoid unnecessary failures.

Consider monitoring for timeout-related failures after deployment, especially in environments with higher network latency.

@aantn aantn enabled auto-merge (squash) June 26, 2025 17:56
Copy link
Contributor

Results of HolmesGPT evals

Test suite Test case Status
ask_holmes 01_how_many_pods ⚠️
ask_holmes 02_what_is_wrong_with_pod
ask_holmes 03_what_is_the_command_to_port_forward
ask_holmes 04_related_k8s_events
ask_holmes 05_image_version
ask_holmes 06_explain_issue
ask_holmes 07_high_latency
ask_holmes 08_sock_shop_frontend ⚠️
ask_holmes 09_crashpod
ask_holmes 10_image_pull_backoff
ask_holmes 11_init_containers
ask_holmes 12_job_crashing
ask_holmes 13_pending_node_selector
ask_holmes 14_pending_resources
ask_holmes 15_failed_readiness_probe
ask_holmes 16_failed_no_toolset_found
ask_holmes 17_oom_kill
ask_holmes 18_crash_looping_v2
ask_holmes 19_detect_missing_app_details
ask_holmes 20_long_log_file_search
ask_holmes 21_job_fail_curl_no_svc_account ⚠️
ask_holmes 22_high_latency_dbi_down ⚠️
ask_holmes 23_app_error_in_current_logs
ask_holmes 24_misconfigured_pvc
ask_holmes 25_misconfigured_ingress_class ⚠️
ask_holmes 26_multi_container_logs
ask_holmes 27_permissions_error_no_helm_tools
ask_holmes 28_permissions_error_helm_tools_enabled
ask_holmes 29_events_from_alert_manager
ask_holmes 30_basic_promql_graph_cluster_memory
ask_holmes 31_basic_promql_graph_pod_memory
ask_holmes 32_basic_promql_graph_pod_cpu
ask_holmes 33_http_latency_graph
ask_holmes 34_memory_graph
ask_holmes 35_tempo
ask_holmes 36_argocd_find_resource
ask_holmes 37_argocd_wrong_namespace ⚠️
ask_holmes 38_rabbitmq_split_head
ask_holmes 39_failed_toolset
ask_holmes 40_disabled_toolset
ask_holmes 41_setup_argo
ask_holmes 42_dns_issues_result_all_tools ⚠️
ask_holmes 42_dns_issues_result_new_tools ⚠️
ask_holmes 42_dns_issues_result_old_tools ⚠️
ask_holmes 42_dns_issues_steps_new_all_tools ⚠️
ask_holmes 42_dns_issues_steps_new_tools ⚠️
ask_holmes 42_dns_issues_steps_old_tools ⚠️
ask_holmes 43_current_datetime_from_prompt
ask_holmes 43_slack_deployment_logs
ask_holmes 44_slack_statefulset_logs
ask_holmes 45_fetch_deployment_logs_simple
ask_holmes 46_job_crashing_no_longer_exists ⚠️
ask_holmes 47_truncated_logs_context_window ⚠️
ask_holmes 48_logs_since_thursday ⚠️
ask_holmes 49_logs_since_last_week
ask_holmes 50_logs_since_specific_date ⚠️
ask_holmes 51_logs_summarize_errors
ask_holmes 52_logs_login_issues ⚠️
ask_holmes 53_logs_find_term
investigate 01_oom_kill
investigate 02_crashloop_backoff
investigate 03_cpu_throttling
investigate 04_image_pull_backoff
investigate 05_crashpod
investigate 06_job_failure
investigate 07_job_syntax_error
investigate 08_memory_pressure
investigate 09_high_latency
investigate 10_KubeDeploymentReplicasMismatch
investigate 11_KubePodCrashLooping
investigate 12_KubePodNotReady
investigate 13_Watchdog
investigate 14_tempo
investigate 15_dns_resolution ⚠️

Legend

  • ✅ the test was successful
  • ⚠️ the test failed but is known to be flakky or known to fail
  • ❌ the test failed and should be fixed before merging the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants