Skip to content

Comments

chore(gov): clean slice w2p1 governor (P1 surface)#62

Open
heidi-dang wants to merge 6 commits intomainfrom
pr/clean-feat-w2p1-governor
Open

chore(gov): clean slice w2p1 governor (P1 surface)#62
heidi-dang wants to merge 6 commits intomainfrom
pr/clean-feat-w2p1-governor

Conversation

@heidi-dang
Copy link
Owner

This PR applies a small, cleaned cherry-pick of the initial process resource governor (P1 surface) and resolves conflicts introduced by recent refactors. Changes: - cherry-pick of initial governor code (gov_rule.h, process_governor.*) - Adjust tests to match current P1 API - Add/keep procfs_starttime helper for proc-cap robustness Verification: local Release build + ctest all passed except CI to run remote checks.\n\nNo behavioral changes to ProcCap or JobRunner beyond the existing merged helper and spawn PGID observation. (Small test-only adjustments to keep compatibility.)

- Add GOV_APPLY schema with strict linear JSON parser (<=512B payload)
- Add ACK/NACK codes for validation errors
- Implement RuleSet POD structures (cpu/mem/pids/rlim/oom_score_adj)
- Add bounded ingress queue (256 capacity) with backpressure
- Implement ProcessGovernor with apply loop
- Implement affinity (sched_setaffinity), nice (setpriority),
  rlimits (prlimit RLIMIT_NOFILE/RLIMIT_CORE), oom_score_adj
- Add 20 unit tests for parser (passes 20/20)
… adjust tests to P1 API; add procfs starttime helper
@gemini-code-assist
Copy link

Summary of Changes

Hello @heidi-dang, 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 integrates a cleaned-up cherry-pick of the initial process resource governor (P1 surface) and resolves recent refactor conflicts. The changes primarily focus on refining existing test cases to align with the current P1 API and ensuring robustness in process capability handling, without introducing any new behavioral changes to ProcCap or JobRunner.

Highlights

  • Governor API Testing: A new test case was introduced to validate backward compatibility for V1 governor apply payloads, ensuring that requests without an explicit version are correctly interpreted.
  • ProcFS Parsing Refinement: An existing test for parsing process start times from /proc/stat lines was updated, adjusting the test data to reflect potential changes in the expected format or parsing logic.
  • Code Cleanup: A minor code style improvement was made in src/job/job.cpp by removing an unnecessary blank line.
Changelog
  • src/job/job.cpp
    • Removed an extraneous blank line.
  • tests/test_gov_rule.cpp
    • Added a test for parse_gov_apply to ensure backward compatibility with V1 payloads.
  • tests/test_job.cpp
    • Modified the test string for parse_start_time_from_stat_line to match updated expectations.
Activity
  • No specific activity or comments have been recorded for 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

@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 is a cleanup of a cherry-pick for the process resource governor. The changes are minor, including fixing a test data string for parsing /proc/pid/stat, removing a blank line, and adding a new test for backward compatibility. The changes look good overall. I've suggested an improvement to the new test to make it more robust and avoid redundancy with an existing test.

Comment on lines +155 to +159
TEST_F(GovApplyParserTest, ParseV1BackwardCompat) {
auto result = parse_gov_apply(R"({"pid":1234,"cpu":{"affinity":"0-3"}})");
EXPECT_TRUE(result.success);
// P1 API: payloads without explicit version are treated as V1; no version field present.
}

Choose a reason for hiding this comment

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

medium

This test appears to be redundant with ParsePidWithCpuAffinity as it uses the same input payload. While the test name and comment are useful for documenting the backward compatibility behavior, the test itself only asserts result.success.

To make this test more robust and not just a subset of an existing test, consider adding assertions to verify the parsed values, similar to what is done in ParsePidWithCpuAffinity.

TEST_F(GovApplyParserTest, ParseV1BackwardCompat) {
  auto result = parse_gov_apply(R"({"pid":1234,"cpu":{"affinity":"0-3"}})");
  EXPECT_TRUE(result.success);
  EXPECT_EQ(result.msg.pid, 1234);
  ASSERT_TRUE(result.msg.cpu.has_value());
  ASSERT_TRUE(result.msg.cpu->affinity.has_value());
  EXPECT_EQ(*result.msg.cpu->affinity, "0-3");
  // P1 API: payloads without explicit version are treated as V1; no version field present.
}

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