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

fix(sims): OOM at sim-multi-seed-long run #21503

Merged
merged 2 commits into from
Sep 3, 2024
Merged

fix(sims): OOM at sim-multi-seed-long run #21503

merged 2 commits into from
Sep 3, 2024

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Sep 2, 2024

Resolves #21415

With this PR, the GOMEMLIMIT is set for the test-sim-multi-seed-long CI run. The variable sets a soft memory limit for the Go runtime. With the additional buffer the GC prevents the OOM.

Also the app.Close() method is called within the test forks to release resources as soon as possible.

Summary by CodeRabbit

  • New Features

    • Introduced a new method for proper application closure in the simulation framework, enhancing resource management.
    • Expanded help text for database backend configuration to clarify acceptable values.
  • Improvements

    • Increased timeout for specific tests to ensure successful completion without timing out.
    • Added an environment variable to improve memory management during test execution.
  • Bug Fixes

    • Enhanced error handling during cleanup to prevent potential memory leaks.

Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Walkthrough

Walkthrough

The changes made to the codebase involve enhancements to memory management and timeout settings in simulation tests, the introduction of a resource management method in the simulation application interface, and improvements to user guidance regarding database backend options. These modifications aim to stabilize long-running simulations and ensure proper resource handling during execution.

Changes

Files Change Summary
.github/workflows/sims-nightly.yml Added GOMEMLIMIT environment variable set to 14GiB in the test-sim-multi-seed-long job.
scripts/build/simulations.mk Increased timeout for go test command from 1 hour to 2 hours in test-sim-multi-seed-long.
testutils/sims/runner.go Added Close() method to SimulationApp interface; modified NewSimulationAppInstance to create a "data" directory.
x/simulation/client/cli/flags.go Expanded help text for DBBackend flag to specify acceptable values: "goleveldb" and "memdb."

Assessment against linked issues

Objective Addressed Explanation
Fix long simulations (#21415)

Tip

We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.


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 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 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.

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.

@@ -173,6 +175,8 @@ func NewSimulationAppInstance[T SimulationApp](
) TestInstance[T] {
t.Helper()
workDir := t.TempDir()
require.NoError(t, os.Mkdir(filepath.Join(workDir, "data"), 0o755))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ensures that the data dir exists for unordered TX

@@ -185,7 +189,7 @@ func NewSimulationAppInstance[T SimulationApp](
db, err := dbm.NewDB("Simulation", dbm.BackendType(tCfg.DBBackend), dbDir)
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, db.Close())
_ = db.Close() // ensure db is closed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The DB is closed by the app on on the happy path now so that errors can be ignored

@alpe alpe changed the title [Do not merge] Test long sims run error fix(sims): OOM at sim-multi-seed-long run Sep 3, 2024
@alpe alpe marked this pull request as ready for review September 3, 2024 12:47
@alpe alpe requested a review from a team as a code owner September 3, 2024 12:47
Copy link
Contributor

github-actions bot commented Sep 3, 2024

@alpe your pull request is missing a changelog!

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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e3d8378 and 2c93a70.

Files selected for processing (4)
  • .github/workflows/sims-nightly.yml (1 hunks)
  • scripts/build/simulations.mk (1 hunks)
  • testutils/sims/runner.go (7 hunks)
  • x/simulation/client/cli/flags.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • x/simulation/client/cli/flags.go
Additional context used
Path-based instructions (1)
testutils/sims/runner.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (8)
.github/workflows/sims-nightly.yml (1)

27-28: LGTM!

Setting the GOMEMLIMIT environment variable to 14GiB is a good practice to prevent OOM errors during long-running simulations. The comment provides a clear explanation of the purpose of the memory limit, and the value seems reasonable, considering that 2 GiB is reserved as a buffer for GC.

scripts/build/simulations.mk (1)

47-47: Timeout increase is reasonable.

Increasing the timeout from 1 hour to 2 hours for the TestFullAppSimulation test in the test-sim-multi-seed-long target is a reasonable change. It provides more time for the long-running simulation to complete successfully without timing out.

testutils/sims/runner.go (6)

6-6: LGTM!

The code change is approved.


54-54: LGTM!

The code change is approved.


128-128: LGTM!

The code change is approved.


138-138: LGTM!

The code change is approved.


144-144: LGTM!

The code change is approved.


179-179: LGTM!

The code change is approved.

Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

Amazing, thank you!!

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Sep 3, 2024
@julienrbrt julienrbrt added this pull request to the merge queue Sep 3, 2024
Merged via the queue into main with commit 62bf23a Sep 3, 2024
76 checks passed
@julienrbrt julienrbrt deleted the alex/21415_fix branch September 3, 2024 13:48
mergify bot pushed a commit that referenced this pull request Sep 3, 2024
(cherry picked from commit 62bf23a)

# Conflicts:
#	testutils/sims/runner.go
julienrbrt added a commit that referenced this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:CLI C:Simulations Type: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix long simulations
3 participants