Skip to content

feat: support custom process name for extractor workers - #299

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
Johnson-zs:develop/snipe
Nov 24, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
Johnson-zs:develop/snipe

Conversation

@Johnson-zs

@Johnson-zs Johnson-zs commented Nov 24, 2026 •

Copy link
Copy Markdown
  1. Added --process-name command line argument to extractor binary to set
    custom process names (comm)
  2. Modified ControllerPipe::start() to accept extra arguments and
    forward them to the subprocess
  3. Created validation logic for process names (15-byte limit, printable
    ASCII only)
  4. Updated IndexProfile to include workerName field for content and
    OCR extractors
  5. Modified ProcessExtractor to pass the worker name from IndexProfile
    to the extractor subprocess
  6. Updated test stubs to match the new ControllerPipe::start() signature

Log: Extractor worker processes now show meaningful names in system
process listings

Influence:

  1. Test that content extractor subprocess shows "anything/text" as
    process name in ps/top
  2. Test that OCR extractor subprocess shows "anything/ocr" as process
    name in ps/top
  3. Verify that filename index (which has no extractor) works normally
  4. Test extractor startup with invalid process names (too long, non-
    ASCII, whitespace)
  5. Verify system process monitoring tools display the custom names
    correctly
  6. Test extractor functionality remains unaffected by the process name
    changes

feat: 为提取器工作进程支持自定义进程名称

  1. 添加了 --process-name 命令行参数到提取器二进制文件,用于设置自定义进
    程名称(comm)
  2. 修改 ControllerPipe::start() 以接收额外参数并将其转发给子进程
  3. 创建了进程名称验证逻辑(15字节限制、仅可打印ASCII字符)
  4. 更新 IndexProfile 为内容和OCR提取器包含 workerName 字段
  5. 修改 ProcessExtractor 将工作进程名称从 IndexProfile 传递给提取器子
    进程
  6. 更新测试桩以匹配新的 ControllerPipe::start() 签名

PMS: Task-395529
Log: 提取器工作进程现在在系统进程列表中显示有意义的名称

Influence:

  1. 测试内容提取器子进程在 ps/top 中显示 "anything/text" 作为进程名称
  2. 测试OCR提取器子进程在 ps/top 中显示 "anything/ocr" 作为进程名称
  3. 验证文件名索引(没有提取器)正常工作
  4. 测试使用无效进程名称(太长、非ASCII、空格)启动提取器
  5. 验证系统进程监控工具正确显示自定义名称
  6. 测试提取器功能不受进程名称更改影响

Summary by Sourcery

Expose meaningful, validated process names for extractor workers in system monitoring tools.

New Features:

  • Add configurable worker names for content and OCR extractor subprocesses, visible in system process listings.
  • Support passing validated custom process names from index profiles to extractor workers.

Enhancements:

  • Extend extractor process startup to accept additional command-line arguments while preserving profiles without extractors.

Tests:

  • Update extractor tests and stubs for the expanded process startup interface.

1. Added --process-name command line argument to extractor binary to set
custom process names (comm)
2. Modified ControllerPipe::start() to accept extra arguments and
forward them to the subprocess
3. Created validation logic for process names (15-byte limit, printable
ASCII only)
4. Updated IndexProfile to include workerName field for content and
OCR extractors
5. Modified ProcessExtractor to pass the worker name from IndexProfile
to the extractor subprocess
6. Updated test stubs to match the new ControllerPipe::start() signature

Log: Extractor worker processes now show meaningful names in system
process listings

Influence:
1. Test that content extractor subprocess shows "anything/text" as
process name in ps/top
2. Test that OCR extractor subprocess shows "anything/ocr" as process
name in ps/top
3. Verify that filename index (which has no extractor) works normally
4. Test extractor startup with invalid process names (too long, non-
ASCII, whitespace)
5. Verify system process monitoring tools display the custom names
correctly
6. Test extractor functionality remains unaffected by the process name
changes

feat: 为提取器工作进程支持自定义进程名称

1. 添加了 --process-name 命令行参数到提取器二进制文件,用于设置自定义进
程名称(comm)
2. 修改 ControllerPipe::start() 以接收额外参数并将其转发给子进程
3. 创建了进程名称验证逻辑(15字节限制、仅可打印ASCII字符)
4. 更新 IndexProfile 为内容和OCR提取器包含 workerName 字段
5. 修改 ProcessExtractor 将工作进程名称从 IndexProfile 传递给提取器子
进程
6. 更新测试桩以匹配新的 ControllerPipe::start() 签名

PMS: Task-395529
Log: 提取器工作进程现在在系统进程列表中显示有意义的名称

Influence:
1. 测试内容提取器子进程在 ps/top 中显示 "anything/text" 作为进程名称
2. 测试OCR提取器子进程在 ps/top 中显示 "anything/ocr" 作为进程名称
3. 验证文件名索引(没有提取器)正常工作
4. 测试使用无效进程名称(太长、非ASCII、空格)启动提取器
5. 验证系统进程监控工具正确显示自定义名称
6. 测试提取器功能不受进程名称更改影响
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

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

@sourcery-ai

sourcery-ai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add a worker name to each index profile and assign names to the content and OCR profiles while leaving the filename profile unnamed.

  • src/index/profile/indexprofile.cpp L380-383 (+3 small edits)
  • src/index/profile/indexprofile.h L110-112

Expose the profile's worker name so runtime code can pass it to its extractor.

  • src/index/profile/indexprofile.cpp L34-35
  • src/index/profile/indexprofile.h L147

API

Extend the public process-extractor constructor to accept an optional worker name.

  • src/index/extractor/processextractor.h L11, L20

Extend ControllerPipe's public start interface with optional extra subprocess arguments.

  • src/extractor/libextractor/controllerpipe.h L40-44

Add the extractor command-line option that lets callers request a process name.

  • src/extractor/extractor/main.cpp L89-96

Uses of the API

Construct the runtime's process extractor with the worker name stored in its profile.

  • src/index/core/indexruntime.cpp L14

Translate a configured worker name into the optional command-line argument and pass it when starting the extractor subprocess.

  • src/index/extractor/processextractor.cpp L41-71 (+5 small edits)

Implementation

Validate the requested name against Linux comm constraints and apply it to the extractor's main thread, warning and retaining the default on failure.

  • src/extractor/extractor/main.cpp L12-59, L99-100

Forward extra arguments supplied by callers into the subprocess command line.

  • src/extractor/libextractor/controllerpipe.cpp L40-41, L102

Tests

Update both process-extractor test stubs to match the expanded ControllerPipe::start signature.

  • autotests/index/test_processextractor.cpp L38
  • autotests/index/test_processextractor_extra.cpp L43

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 7 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/extractor/libextractor/controllerpipe.h" line_range="44" />
<code_context>
      */
-    bool start(const QString &extractorPath, const QString &pluginPath = QString());
+    bool start(const QString &extractorPath, const QString &pluginPath = QString(),
+               const QStringList &extraArguments = QStringList());

     /**
</code_context>
<issue_to_address>
**Existing clients fail to load**

When the shared library is upgraded while a previously built client remains deployed, the new declaration replaces the two-argument `ControllerPipe::start` symbol with a three-argument symbol; existing binaries still request the old symbol, so loading them against the updated shared library with the unchanged SONAME fails with an undefined-symbol error.

Preserve the old two-argument overload as a forwarding wrapper, or bump the library SOVERSION and coordinate client rebuilds.
</issue_to_address>

### Comment 2
<location path="src/index/extractor/processextractor.cpp" line_range="235" />
<code_context>
         }

-        if (!m_pipe->start(m_extractorPath)) {
+        if (!m_pipe->start(m_extractorPath, QString(), processNameArguments(m_processName))) {
             qCritical() << "ProcessExtractorProxy: failed to start extractor process";
             return false;
</code_context>
<issue_to_address>
**Older workers reject new option**

When the new index service launches an older extractor binary, such as during a partial upgrade or through `ANYTHING_EXTRACTOR_TOOL`, `ControllerPipe::start` passes `--process-name` to the configured executable, and an older extractor's `QCommandLineParser::process()` rejects the unknown option and exits before initialization; content and OCR extraction then fail to start.

Handle an unsupported `--process-name` option compatibly, or ensure the index service and extractor are upgraded and selected as a matched pair.
</issue_to_address>

### Comment 3
<location path="src/index/profile/indexprofile.h" line_range="147" />
<code_context>

     Type type() const;
     const QString &id() const;
+    const QString &workerName() const;
     QString indexDirectory() const;
     QString statusFilePath() const;
</code_context>
<issue_to_address>
**Accessor uses mixed-case name**

`IndexProfile::workerName()` uses camelCase rather than snake_case, so the new public method violates the repository's method-naming rule.

Rename the accessor to `worker_name()` and update its callers.

Also at `src/index/profile/indexprofile.cpp:31`.
</issue_to_address>

### Comment 4
<location path="src/index/profile/indexprofile.h" line_range="112" />
<code_context>
         int runtimeVersion { -1 };
+        // 该 profile 的 extractor 子进程在 ps/top 中显示的短名,写入
+        // /proc/<pid>/comm。comm 上限 15 字节;为空则沿用二进制默认名。
+        QString workerName;
     };

</code_context>
<issue_to_address>
**New variables use mixed-case names**

The added `workerName`, `extraArguments`, `processName`, and related variables use camelCase instead of snake_case, violating the repository's variable-naming rule.

Rename the added variables and parameters to snake_case, updating their uses.

Also at `src/extractor/libextractor/controllerpipe.cpp:41`, `src/extractor/extractor/main.cpp:23-90`, `src/index/extractor/processextractor.cpp:49-326`.
</issue_to_address>

### Comment 5
<location path="src/extractor/extractor/main.cpp" line_range="21" />
<code_context>
+// is capped at TASK_COMM_LEN - 1 = 15 bytes. Which name each worker gets is the
+// index profile's policy (IndexProfile::workerName), not this binary's; here we
+// only enforce what the kernel accepts so a bad value cannot garble comm.
+constexpr int kMaxCommLength = 15;
+
+bool isValidProcessName(const QByteArray &name)
</code_context>
<issue_to_address>
**Constants use mixed-case names**

Both new `kMaxCommLength` constants use mixed-case names instead of uppercase, violating the repository's constant-naming rule.

Rename both constants to `MAX_COMM_LENGTH`.

Also at `src/index/extractor/processextractor.cpp:47`.
</issue_to_address>

### Comment 6
<location path="src/index/extractor/processextractor.cpp" line_range="283" />
<code_context>

 private:
     const QString m_extractorPath;
+    const QString m_processName;
     EXTRACTOR_NAMESPACE::ControllerPipe *m_pipe { nullptr };
     ActiveExtraction *m_activeExtraction { nullptr };
</code_context>
<issue_to_address>
**Private member lacks required prefix**

The new private member `m_processName` uses an `m_` prefix rather than the required `_` prefix, violating the private-member naming rule.

Rename the member to `_process_name` and update its uses.
</issue_to_address>

### Comment 7
<location path="src/extractor/libextractor/controllerpipe.h" line_range="44" />
<code_context>
      */
-    bool start(const QString &extractorPath, const QString &pluginPath = QString());
+    bool start(const QString &extractorPath, const QString &pluginPath = QString(),
+               const QStringList &extraArguments = QStringList());

     /**
</code_context>
<issue_to_address>
**New argument collections use Qt lists**

The new process-argument interfaces use `QStringList` instead of the repository-prescribed `std::vector` and `std::string` collections, violating the collection-type rule.

Use the prescribed standard collection types in the new interfaces and convert to `QStringList` at the `QProcess` boundary.

Also at `src/extractor/libextractor/controllerpipe.cpp:41-102`, `src/index/extractor/processextractor.cpp:49-62`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

*/
bool start(const QString &extractorPath, const QString &pluginPath = QString());
bool start(const QString &extractorPath, const QString &pluginPath = QString(),
const QStringList &extraArguments = QStringList());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Existing clients fail to load

When the shared library is upgraded while a previously built client remains deployed, the new declaration replaces the two-argument ControllerPipe::start symbol with a three-argument symbol; existing binaries still request the old symbol, so loading them against the updated shared library with the unchanged SONAME fails with an undefined-symbol error.

Preserve the old two-argument overload as a forwarding wrapper, or bump the library SOVERSION and coordinate client rebuilds.

Prompt for AI agents
In `src/extractor/libextractor/controllerpipe.h` at line 44:

**Existing clients fail to load**

When the shared library is upgraded while a previously built client remains deployed, the new declaration replaces the two-argument `ControllerPipe::start` symbol with a three-argument symbol; existing binaries still request the old symbol, so loading them against the updated shared library with the unchanged SONAME fails with an undefined-symbol error.

Preserve the old two-argument overload as a forwarding wrapper, or bump the library SOVERSION and coordinate client rebuilds.

}

if (!m_pipe->start(m_extractorPath)) {
if (!m_pipe->start(m_extractorPath, QString(), processNameArguments(m_processName))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Older workers reject new option

When the new index service launches an older extractor binary, such as during a partial upgrade or through ANYTHING_EXTRACTOR_TOOL, ControllerPipe::start passes --process-name to the configured executable, and an older extractor's QCommandLineParser::process() rejects the unknown option and exits before initialization; content and OCR extraction then fail to start.

Handle an unsupported --process-name option compatibly, or ensure the index service and extractor are upgraded and selected as a matched pair.

Prompt for AI agents
In `src/index/extractor/processextractor.cpp` at line 235:

**Older workers reject new option**

When the new index service launches an older extractor binary, such as during a partial upgrade or through `ANYTHING_EXTRACTOR_TOOL`, `ControllerPipe::start` passes `--process-name` to the configured executable, and an older extractor's `QCommandLineParser::process()` rejects the unknown option and exits before initialization; content and OCR extraction then fail to start.

Handle an unsupported `--process-name` option compatibly, or ensure the index service and extractor are upgraded and selected as a matched pair.


Type type() const;
const QString &id() const;
const QString &workerName() const;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ Low · Accessor uses mixed-case name

IndexProfile::workerName() uses camelCase rather than snake_case, so the new public method violates the repository's method-naming rule.

Rename the accessor to worker_name() and update its callers.

Also at src/index/profile/indexprofile.cpp:31.

Prompt for AI agents
In `src/index/profile/indexprofile.h` at line 147:

**Accessor uses mixed-case name**

`IndexProfile::workerName()` uses camelCase rather than snake_case, so the new public method violates the repository's method-naming rule.

Rename the accessor to `worker_name()` and update its callers.

Also at `src/index/profile/indexprofile.cpp:31`.

From AGENTS.md L57:

- Functions: `snake_case` (C functions, C++ methods)

int runtimeVersion { -1 };
// 该 profile 的 extractor 子进程在 ps/top 中显示的短名,写入
// /proc/<pid>/comm。comm 上限 15 字节;为空则沿用二进制默认名。
QString workerName;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ Low · New variables use mixed-case names

The added workerName, extraArguments, processName, and related variables use camelCase instead of snake_case, violating the repository's variable-naming rule.

Rename the added variables and parameters to snake_case, updating their uses.

Also at src/extractor/libextractor/controllerpipe.cpp:41, src/extractor/extractor/main.cpp:23-90, src/index/extractor/processextractor.cpp:49-326.

Prompt for AI agents
In `src/index/profile/indexprofile.h` at line 112:

**New variables use mixed-case names**

The added `workerName`, `extraArguments`, `processName`, and related variables use camelCase instead of snake_case, violating the repository's variable-naming rule.

Rename the added variables and parameters to snake_case, updating their uses.

Also at `src/extractor/libextractor/controllerpipe.cpp:41`, `src/extractor/extractor/main.cpp:23-90`, `src/index/extractor/processextractor.cpp:49-326`.

From AGENTS.md L59:

- Variables: `snake_case` (e.g., `config_ptr`, `event_handler`)

// is capped at TASK_COMM_LEN - 1 = 15 bytes. Which name each worker gets is the
// index profile's policy (IndexProfile::workerName), not this binary's; here we
// only enforce what the kernel accepts so a bad value cannot garble comm.
constexpr int kMaxCommLength = 15;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ Low · Constants use mixed-case names

Both new kMaxCommLength constants use mixed-case names instead of uppercase, violating the repository's constant-naming rule.

Rename both constants to MAX_COMM_LENGTH.

Also at src/index/extractor/processextractor.cpp:47.

Prompt for AI agents
In `src/extractor/extractor/main.cpp` at line 21:

**Constants use mixed-case names**

Both new `kMaxCommLength` constants use mixed-case names instead of uppercase, violating the repository's constant-naming rule.

Rename both constants to `MAX_COMM_LENGTH`.

Also at `src/index/extractor/processextractor.cpp:47`.

From AGENTS.md L60:

- Constants: `UPPER_CASE` (e.g., `MAX_INPUT_MINOR`, `INFO_LEVELS`)


private:
const QString m_extractorPath;
const QString m_processName;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ Low · Private member lacks required prefix

The new private member m_processName uses an m_ prefix rather than the required _ prefix, violating the private-member naming rule.

Rename the member to _process_name and update its uses.

Prompt for AI agents
In `src/index/extractor/processextractor.cpp` at line 283:

**Private member lacks required prefix**

The new private member `m_processName` uses an `m_` prefix rather than the required `_` prefix, violating the private-member naming rule.

Rename the member to `_process_name` and update its uses.

From AGENTS.md L61:

- Private members: Prefix with `_` (e.g., `_private_ptr`)

*/
bool start(const QString &extractorPath, const QString &pluginPath = QString());
bool start(const QString &extractorPath, const QString &pluginPath = QString(),
const QStringList &extraArguments = QStringList());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ Low · New argument collections use Qt lists

The new process-argument interfaces use QStringList instead of the repository-prescribed std::vector and std::string collections, violating the collection-type rule.

Use the prescribed standard collection types in the new interfaces and convert to QStringList at the QProcess boundary.

Also at src/extractor/libextractor/controllerpipe.cpp:41-102, src/index/extractor/processextractor.cpp:49-62.

Prompt for AI agents
In `src/extractor/libextractor/controllerpipe.h` at line 44:

**New argument collections use Qt lists**

The new process-argument interfaces use `QStringList` instead of the repository-prescribed `std::vector` and `std::string` collections, violating the collection-type rule.

Use the prescribed standard collection types in the new interfaces and convert to `QStringList` at the `QProcess` boundary.

Also at `src/extractor/libextractor/controllerpipe.cpp:41-102`, `src/index/extractor/processextractor.cpp:49-62`.

From AGENTS.md L77, AGENTS.md L80:

### C++ Style (C++17/20)

@Johnson-zs

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit f41acec into linuxdeepin:develop/snipe Nov 24, 2026
16 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.

2 participants