Repository navigation
feat: support custom process name for extractor workers - #299
Conversation
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. 测试提取器功能不受进程名称更改影响
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideData structuresAdd a worker name to each index profile and assign names to the content and OCR profiles while leaving the filename profile unnamed.
Expose the profile's worker name so runtime code can pass it to its extractor.
APIExtend the public process-extractor constructor to accept an optional worker name.
Extend ControllerPipe's public start interface with optional extra subprocess arguments.
Add the extractor command-line option that lets callers request a process name.
Uses of the APIConstruct the runtime's process extractor with the worker name stored in its profile.
Translate a configured worker name into the optional command-line argument and pass it when starting the extractor subprocess.
ImplementationValidate the requested name against Linux comm constraints and apply it to the extractor's main thread, warning and retaining the default on failure.
Forward extra arguments supplied by callers into the subprocess command line.
TestsUpdate both process-extractor test stubs to match the expanded ControllerPipe::start signature.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>| */ | ||
| bool start(const QString &extractorPath, const QString &pluginPath = QString()); | ||
| bool start(const QString &extractorPath, const QString &pluginPath = QString(), | ||
| const QStringList &extraArguments = QStringList()); |
There was a problem hiding this comment.
🟡 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))) { |
There was a problem hiding this comment.
🟡 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; |
There was a problem hiding this comment.
⚪ 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; |
There was a problem hiding this comment.
⚪ 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; |
There was a problem hiding this comment.
⚪ 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; |
There was a problem hiding this comment.
⚪ 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()); |
There was a problem hiding this comment.
⚪ 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)|
/forcemerge |
|
This pr force merged! (status: unstable) |
f41acec
into
linuxdeepin:develop/snipe
custom process names (comm)
forward them to the subprocess
ASCII only)
OCR extractors
to the extractor subprocess
Log: Extractor worker processes now show meaningful names in system
process listings
Influence:
process name in ps/top
name in ps/top
ASCII, whitespace)
correctly
changes
feat: 为提取器工作进程支持自定义进程名称
程名称(comm)
进程
PMS: Task-395529
Log: 提取器工作进程现在在系统进程列表中显示有意义的名称
Influence:
Summary by Sourcery
Expose meaningful, validated process names for extractor workers in system monitoring tools.
New Features:
Enhancements:
Tests: