Skip to content

Conversation

@fly602
Copy link
Contributor

@fly602 fly602 commented Jan 15, 2026

Add OOMScoreAdjust and Nice settings to improve system daemon stability

  1. Set OOMScoreAdjust=-500 to reduce likelihood of OOM killer termination
  2. Set Nice=-5 to give the process higher CPU scheduling priority
  3. These changes help ensure critical system services remain available
  4. Prevents system instability due to resource contention

Log: Improved system daemon stability with better resource prioritization

Influence:

  1. Test system behavior under high memory pressure
  2. Verify daemon remains running during system stress
  3. Check CPU scheduling priority with nice command
  4. Monitor OOM score adjustments during low memory conditions
  5. Test overall system stability with multiple resource-intensive applications

fix: 增强系统守护进程资源管理

添加 OOMScoreAdjust 和 Nice 设置以提升系统守护进程稳定性

  1. 设置 OOMScoreAdjust=-500 降低被 OOM 杀手终止的概率
  2. 设置 Nice=-5 给予进程更高的 CPU 调度优先级
  3. 这些更改有助于确保关键系统服务保持可用
  4. 防止因资源竞争导致的系统不稳定

Log: 通过更好的资源优先级设置提升系统守护进程稳定性

Influence:

  1. 在高内存压力下测试系统行为
  2. 验证守护进程在系统压力下保持运行
  3. 使用 nice 命令检查 CPU 调度优先级
  4. 监控低内存条件下的 OOM 分数调整
  5. 测试多资源密集型应用下的整体系统稳定性

Summary by Sourcery

Tune dde-system-daemon systemd service resource settings to improve stability under memory and CPU pressure.

Enhancements:

  • Adjust dde-system-daemon systemd unit to lower its OOM killer likelihood via OOMScoreAdjust.
  • Raise dde-system-daemon CPU scheduling priority in the systemd unit using a negative nice value.

Add OOMScoreAdjust and Nice settings to improve system daemon stability
1. Set OOMScoreAdjust=-500 to reduce likelihood of OOM killer
termination
2. Set Nice=-5 to give the process higher CPU scheduling priority
3. These changes help ensure critical system services remain available
4. Prevents system instability due to resource contention

Log: Improved system daemon stability with better resource
prioritization

Influence:
1. Test system behavior under high memory pressure
2. Verify daemon remains running during system stress
3. Check CPU scheduling priority with nice command
4. Monitor OOM score adjustments during low memory conditions
5. Test overall system stability with multiple resource-intensive
applications

fix: 增强系统守护进程资源管理

添加 OOMScoreAdjust 和 Nice 设置以提升系统守护进程稳定性
1. 设置 OOMScoreAdjust=-500 降低被 OOM 杀手终止的概率
2. 设置 Nice=-5 给予进程更高的 CPU 调度优先级
3. 这些更改有助于确保关键系统服务保持可用
4. 防止因资源竞争导致的系统不稳定

Log: 通过更好的资源优先级设置提升系统守护进程稳定性

Influence:
1. 在高内存压力下测试系统行为
2. 验证守护进程在系统压力下保持运行
3. 使用 nice 命令检查 CPU 调度优先级
4. 监控低内存条件下的 OOM 分数调整
5. 测试多资源密集型应用下的整体系统稳定性
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 15, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Configures the dde-system-daemon systemd unit with explicit OOMScoreAdjust and CPU scheduling (Nice) settings to improve its survivability under memory pressure and CPU contention.

File-Level Changes

Change Details Files
Tune systemd service to be more resilient under memory and CPU pressure by adjusting OOM score and niceness.
  • Add OOMScoreAdjust=-500 to the service so the daemon is less likely to be selected by the OOM killer under low-memory conditions
  • Add Nice=-5 to increase the daemon’s CPU scheduling priority relative to default processes
  • Ensure the new resource-tuning directives are applied within the appropriate systemd service section so systemd recognizes them
misc/systemd/services/system/dde-system-daemon.service

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider whether the chosen OOMScoreAdjust=-500 and Nice=-5 values should be configurable rather than hardcoded, so deployments with different performance/latency requirements can tune daemon priority appropriately.
  • Please double-check that the new OOMScoreAdjust and Nice settings are consistent with other critical systemd units on the system to avoid unexpected priority inversions between this daemon and related services.
  • If this unit can also run in non-desktop or resource-constrained environments, you may want to guard these settings with appropriate Condition= or environment-specific overrides to prevent starving other important workloads.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider whether the chosen OOMScoreAdjust=-500 and Nice=-5 values should be configurable rather than hardcoded, so deployments with different performance/latency requirements can tune daemon priority appropriately.
- Please double-check that the new OOMScoreAdjust and Nice settings are consistent with other critical systemd units on the system to avoid unexpected priority inversions between this daemon and related services.
- If this unit can also run in non-desktop or resource-constrained environments, you may want to guard these settings with appropriate Condition= or environment-specific overrides to prevent starving other important workloads.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

deepin pr auto review

这段代码修改是在 systemd 服务单元文件(dde-system-daemon.service)中添加了两个资源控制参数:OOMScoreAdjustNice

以下是对该修改的详细审查意见,包括语法逻辑、代码质量、性能和安全性方面:

1. 语法逻辑

  • 正确性:语法完全符合 systemd 单元文件规范。
    • OOMScoreAdjust=-500:设置内存溢出(OOM) killer 的评分。有效范围是 -1000 到 1000。
    • Nice=-5:设置进程的调度优先级。有效范围(在非实时调度下)通常是 -20 到 19。
  • 逻辑合理性
    • Nice=-5:将进程优先级提高(数值越小优先级越高)。这意味着该守护进程比普通进程(Nice=0)获得更多 CPU 时间。这对于需要快速响应系统事件的后台服务通常是合理的。
    • OOMScoreAdjust=-500:降低该进程被 OOM Killer 杀死的概率。数值越小,越不容易被杀。这对于系统核心守护进程非常重要,防止系统在内存压力大时误杀关键服务。

2. 代码质量

  • 格式规范:格式良好,对齐方式与上下文一致。
  • 注释:建议添加注释说明添加这两个参数的原因。例如,是为了防止内存不足时服务崩溃,还是为了提高服务响应速度。这有助于后续维护者理解意图。

3. 代码性能

  • 正面影响
    • Nice=-5:提高了该服务的 CPU 调度优先级,理论上可以加快服务的响应速度和处理能力。
  • 潜在风险
    • 如果该服务包含 CPU 密集型任务,提高优先级可能会导致系统其他进程(尤其是未设置优先级的用户应用)获取 CPU 时间变少,从而影响整体系统的流畅度。需要确认该服务确实需要较高的 CPU 优先级,且不会长时间占用 CPU。

4. 代码安全

  • 安全性
    • OOMScoreAdjust 设置为负值通常需要管理员权限(systemd 服务文件通常以 root 运行,所以这没问题)。这增加了服务的稳定性,防止恶意或意外的内存压力导致服务崩溃。
    • 资源滥用风险:将优先级调高(Nice=-5)且降低被杀概率(OOMScoreAdjust=-500),如果该服务存在内存泄漏或死循环的 Bug,可能会比普通进程更难被杀死,且占用更多 CPU 资源,甚至可能导致系统假死。因此,确保该服务本身的代码质量非常关键。

5. 改进建议

  1. 添加注释:在参数上方添加简短注释,解释调整优先级和 OOM 分数的业务或技术原因。
    # 提高优先级以保证系统事件响应速度,并降低被OOM killer杀死的概率以增强服务稳定性
    OOMScoreAdjust=-500
    Nice=-5
  2. 数值评估
    • Nice=-5 是一个比较温和的提升。如果测试中发现对前台应用有明显影响,可以考虑调整为 -1-2
    • OOMScoreAdjust=-500 已经提供了相当强的保护。通常系统关键服务(如 systemd-journald)可能会设置得更低(如 -900),但 -500 对于桌面环境守护进程来说是一个平衡的选择。
  3. 资源限制(可选):既然提高了优先级,为了防止该进程失控,建议配合使用 CPUQuotaMemoryLimit(如果 systemd 版本支持且业务允许),作为硬性限制兜底,防止高优先级进程耗尽系统资源。

总结

该修改在语法和逻辑上是正确的,旨在提高系统守护进程的稳定性和响应速度。主要风险在于如果该服务本身存在性能问题或 Bug,可能会对系统整体造成较大影响。建议添加注释说明意图,并在实际测试中观察其对系统流畅度的影响。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, robertkill

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fly602 fly602 merged commit 37f19a7 into linuxdeepin:master Jan 15, 2026
15 of 17 checks passed
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.

3 participants