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

smaller job defaults requirements #4785

Merged
merged 3 commits into from
Dec 18, 2024

Conversation

wdbaruni
Copy link
Member

@wdbaruni wdbaruni commented Dec 18, 2024

Smaller job resource requirements so that jobs can run on smaller EC2 instances by default.

This PR also introduce the following changes:

  • Increase allocated capacity from 70% to 80%
  • Unify the library used for printing human readable bytes

Summary by CodeRabbit

  • New Features

    • Enhanced memory and disk capacity outputs with improved human-readable formatting.
    • Updated default configuration settings for resource allocation in Bacalhau nodes.
    • Introduced new API endpoints for orchestrator nodes and version retrieval.
  • Bug Fixes

    • Adjusted memory allocation settings for batch, daemon, and service jobs to optimize resource management.
    • Improved error handling and response schemas for various API endpoints.

Copy link

linear bot commented Dec 18, 2024

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces several changes to the Bacalhau system, including updates to the formatting of memory and disk capacity outputs in the CLI node columns by switching from the datasize package to the humanize package. Additionally, the default configuration settings for resource allocation have been modified, increasing the allocated capacity for CPU, Memory, and Disk from 70% to 80%, while reducing memory allocation for various job types from 1Gb to 512Mb. Furthermore, extensive updates to the Swagger API documentation and specifications have been made, including the addition of new endpoints and refined response schemas.

Changes

File Change Summary
cmd/cli/node/columns.go Replaced datasize.ByteSize(...).HR() with humanize.Bytes(...) for formatting memory and disk capacity outputs.
pkg/config/defaults.go Updated default resource allocation:
- Increased allocated capacity from 70% to 80% for CPU, Memory, and Disk
- Reduced memory allocation for batch, daemon, and service jobs from 1Gb to 512Mb
pkg/swagger/docs.go Updated Swagger documentation with new API endpoints, modified existing endpoints, and refined response schemas. Added new method init() and updated SwaggerInfo and docTemplate.
pkg/swagger/swagger.json Added new endpoints and updated existing endpoint definitions and response schemas, including error handling improvements.
webui/lib/api/schema/swagger.json Extensive modifications to API schema definitions and endpoint specifications, including new endpoints and updated response schemas.

Possibly related PRs

Suggested reviewers

  • jamlo

Poem

🐰 Bytes dance in humanize's light,
Resources tweaked with rabbit's might,
Configs shift, percentages rise,
Memory trimmed to compact size,
A CLI transformation takes flight! 🚀


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 11d9d2c and 91c40cb.

📒 Files selected for processing (3)
  • pkg/swagger/docs.go (0 hunks)
  • pkg/swagger/swagger.json (0 hunks)
  • webui/lib/api/schema/swagger.json (0 hunks)
💤 Files with no reviewable changes (3)
  • pkg/swagger/docs.go
  • pkg/swagger/swagger.json
  • webui/lib/api/schema/swagger.json

🪧 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.
    • 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 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 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 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. (Beta)
  • @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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 76836dd and 11d9d2c.

📒 Files selected for processing (2)
  • cmd/cli/node/columns.go (2 hunks)
  • pkg/config/defaults.go (5 hunks)
🔇 Additional comments (3)
cmd/cli/node/columns.go (2)

7-7: LGTM: Good choice of package for human-readable formatting

The go-humanize package is a well-maintained library that provides consistent human-readable number formatting.


103-105: LGTM: Consistent formatting implementation

The implementation consistently uses humanize.Bytes() for both memory and disk capacity formatting, which aligns with the PR objective of unifying the library used for printing human-readable byte values.

Also applies to: 111-113

pkg/config/defaults.go (1)

54-56: LGTM: Reasonable increase in resource allocation

Increasing allocated capacity from 70% to 80% for CPU, Memory, and Disk is a good balance between:

  • Better resource utilization
  • Maintaining sufficient headroom for system processes

@@ -63,7 +63,7 @@ var Default = types.Bacalhau{
Task: types.BatchTaskDefaultConfig{
Resources: types.ResourcesConfig{
CPU: "500m",
Memory: "1Gb",
Memory: "512Mb",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Memory configuration appears to be reduced from previous defaults

Based on the search results, I can make the following observations:

  • The production configuration (pkg/config_legacy/configenv/production.go) previously used 1Gb memory
  • Test configurations (pkg/test/compute/resourcelimits_test.go and pkg/config/types/bacalhau_test.go) use 1Gb memory
  • The new default of 512Mb is a significant reduction from the previous 1Gb setting

Since this is a significant reduction in memory allocation and there's evidence of higher memory usage in production and test configurations, this warrants attention.

  • pkg/config_legacy/configenv/production.go: Previously used 1Gb
  • pkg/config/defaults.go: New default of 512Mb
  • pkg/test/compute/resourcelimits_test.go: Tests expecting 1Gb
🔗 Analysis chain

Verify if 512Mb is sufficient for typical workloads

While reducing memory requirements to 512Mb aligns with the goal of running on smaller EC2 instances, we should verify this doesn't impact typical workloads.

Consider implementing memory auto-scaling or providing documentation for users to override these defaults when needed for memory-intensive workloads.

Also applies to: 75-75, 84-84, 93-93


Let me try a different approach to gather information about memory usage patterns in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for memory-related issues or discussions in recent PRs and issues
gh search issues "memory OOM out of memory" --repo bacalhau-project/bacalhau --state all --limit 10

# Look for memory configuration mentions in tests
rg -l "Memory.*[0-9]+[MGT]b" "test" || true

Length of output: 2860


Script:

#!/bin/bash
# Search for memory configurations in the entire codebase
rg -A 2 -B 2 'Memory.*[0-9]+[MGT]b' || true

# Look for memory-related configurations and defaults
fd -e yaml -e yml | xargs rg 'memory|Memory' || true

# Look for memory-related test configurations
ast-grep --pattern 'Memory: "$_"'

Length of output: 4163

@wdbaruni wdbaruni merged commit 0607cf3 into main Dec 18, 2024
14 checks passed
@wdbaruni wdbaruni deleted the eng-192-compute-node-fails-to-start-on-small-nodes branch December 18, 2024 13:13
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.

1 participant