Skip to content

Support cleanup previous dumps in dumper#19013

Open
fzyzcjy wants to merge 4 commits intosgl-project:mainfrom
fzyzcjy:ac8398/0
Open

Support cleanup previous dumps in dumper#19013
fzyzcjy wants to merge 4 commits intosgl-project:mainfrom
fzyzcjy:ac8398/0

Conversation

@fzyzcjy
Copy link
Collaborator

@fzyzcjy fzyzcjy commented Feb 19, 2026

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

When SGLANG_DUMPER_CLEANUP=1, all existing sglang_dump_* directories
under the base dir are removed before the first dump write to disk.
Rank 0 performs the cleanup with a distributed barrier for sync.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @fzyzcjy, 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 enhances the SGLang dumper utility by adding a new feature to automatically clean up old dump directories. This prevents the accumulation of debugging data over time, improving disk space management for users who frequently use the dumper. The cleanup is triggered before the first dump operation when explicitly enabled via an environment variable.

Highlights

  • New Cleanup Feature: Introduced an automatic cleanup mechanism for previous SGLang dump directories, preventing accumulation of debugging data.
  • Environment Variable Control: Added the SGLANG_DUMPER_CLEANUP_PREVIOUS environment variable to enable or disable the cleanup behavior.
  • Dumper Integration: Integrated the cleanup logic into the _Dumper class, ensuring old dumps are removed before the first write operation when the feature is enabled.
  • Unit Tests: Included new unit tests to verify the correct functionality of the dump cleanup feature, covering both enabled and disabled scenarios.

🧠 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
  • python/sglang/srt/debug_utils/dumper.py
    • Documented the new SGLANG_DUMPER_CLEANUP_PREVIOUS environment variable in the class docstring.
    • Added a cleanup_previous boolean parameter to the _Dumper constructor and initialized a corresponding _pending_cleanup internal state.
    • Modified the from_env class method to read the SGLANG_DUMPER_CLEANUP_PREVIOUS environment variable and pass it to the constructor.
    • Implemented a conditional check within _dump_single to perform cleanup if _pending_cleanup is true before writing the first dump.
    • Introduced a new private helper function _cleanup_old_dumps to remove directories matching 'sglang_dump_*' patterns, with distributed barrier synchronization.
  • test/registered/debug_utils/test_dumper.py
    • Added a new test class TestCleanup to house tests for the dumper's cleanup functionality.
    • Included test_cleanup_removes_old_dumps to verify that old dump directories are correctly removed when cleanup is enabled.
    • Added test_no_cleanup_by_default to confirm that existing dump directories are not removed when the cleanup feature is not explicitly enabled.
Activity
  • No human 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 introduces a helpful feature to the dumper utility for automatically cleaning up previous dump files. The implementation is clear and includes corresponding tests. My review includes a fix for a bug in the new test case and a minor style suggestion to improve code consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

high

There's a typo in the keyword argument. The _Dumper constructor expects cleanup_previous, but needs_cleanup is provided. This will cause a TypeError when running the test.

Suggested change
dumper = _make_test_dumper(tmp_path, needs_cleanup=True)
dumper = _make_test_dumper(tmp_path, cleanup_previous=True)



def _cleanup_old_dumps(base_dir: Path) -> None:
import shutil
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

According to the PEP 8 style guide, imports should be placed at the top of the file. Please move import shutil to the module-level imports for better code organization and readability.

References
  1. PEP 8 advises that imports should be at the top of the file, just after any module comments and docstrings, and before module globals and constants. This is for clarity and to make it easy to see what modules a file uses. (link)

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

Comments