Skip to content

perf: ускорить получение информации о процессоре в Linux - #13

Merged
Stivo182 merged 2 commits into
mainfrom
perf/linux-cpu-info
Aug 7, 2026
Merged

Stivo182 merged 2 commits into
mainfrom
perf/linux-cpu-info

Conversation

@Stivo182

@Stivo182 Stivo182 commented Aug 7, 2026 •

Copy link
Copy Markdown
Owner

Что изменено

  • /proc/cpuinfo читается напрямую как файл без запуска внешней команды cat.
  • Получение данных из cpuinfo и lscpu вынесено в отдельные источники.

Зачем

Прямое чтение /proc/cpuinfo исключает запуск отдельного процесса cat и связанные с ним накладные расходы.

Summary by CodeRabbit

  • New Features

    • Improved Linux processor detection using standardized system information sources.
    • Added support for identifying processor models, architecture, logical and physical core counts, processor identifiers, and maximum frequency.
    • Added fallback handling when the primary source provides incomplete or unavailable information.
  • Bug Fixes

    • Improved consistency and reliability of Linux processor information parsing.
    • Preserved Windows detection behavior while strengthening cross-platform compatibility.
  • Tests

    • Added coverage for Linux detection, fallback scenarios, source errors, and parsed processor details.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Stivo182, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bcf4a841-f48d-49ac-9ed6-309be0c4d84a

📥 Commits

Reviewing files that changed from the base of the PR and between 1d51d6c and 746b5c9.

📒 Files selected for processing (1)
  • src/internal/Классы/ИсточникИнформацииОПроцессореCpuInfo.os
📝 Walkthrough

Walkthrough

Linux processor detection now uses dedicated /proc/cpuinfo and lscpu sources with shared parsers. The detector caches platform information and tests cover source ordering, fallback behavior, and error propagation.

Changes

Linux processor detection

Layer / File(s) Summary
Processor sources and parsers
src/internal/Классы/ИсточникИнформацииОПроцессоре*.os, src/internal/Классы/ПарсерДанныхПроцессора*.os, tests/Тесты_ПарсерДанныхПроцессора*.os
Added sources for /proc/cpuinfo and lscpu. Added parsers for processor facts, architecture, counts, identifiers, and frequency values.
Linux detector wiring
src/internal/Классы/ДетекторПроцессораLinux.os, src/internal/Модули/ПарсерИнформацииОПроцессореLinux.os
The detector caches the platform, initializes both sources, and passes source output to the shared parsers.
Detection validation and test compatibility
tests/Тесты_Детекторы.os, tests/helpers/Классы/МокИсточникИнформацииОПроцессоре.os, tests/Тесты_FallbackДетектораПроцессораWindows.os, src/internal/Классы/ДетекторПроцессораWindows.os
Added Linux detector tests for success, fallback, call order, and errors. Updated Windows fallback tests to use the generic source mock and added the symbol-check directive.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Detector as ДетекторПроцессораLinux
  participant CpuInfo as ИсточникИнформацииОПроцессореCpuInfo
  participant Lscpu as ИсточникИнформацииОПроцессореLscpu
  participant Parser as ПарсерИнформацииОПроцессореLinux
  Detector->>CpuInfo: Получить()
  CpuInfo-->>Detector: /proc/cpuinfo
  Detector->>Lscpu: Получить()
  Lscpu-->>Detector: lscpu output
  Detector->>Parser: Распарсить(cpuinfo, lscpu)
  Parser-->>Detector: processor facts
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: speeding up CPU information retrieval on Linux.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/linux-cpu-info

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/internal/Классы/ИсточникИнформацииОПроцессореCpuInfo.os`:
- Around line 9-11: Обеспечьте гарантированное закрытие объекта ЧтениеТекста при
ошибке в методе чтения процессорной информации: оберните вызов Прочитать в
Попытка/Исключение и вызовите Закрыть перед повторным выбросом исключения, либо
используйте Контекст для автоматического освобождения ресурса.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f65018c7-ed26-49d4-9d78-5846b402bb97

📥 Commits

Reviewing files that changed from the base of the PR and between 02745c1 and 1d51d6c.

📒 Files selected for processing (12)
  • src/internal/Классы/ДетекторПроцессораLinux.os
  • src/internal/Классы/ДетекторПроцессораWindows.os
  • src/internal/Классы/ИсточникИнформацииОПроцессореCpuInfo.os
  • src/internal/Классы/ИсточникИнформацииОПроцессореLscpu.os
  • src/internal/Классы/ПарсерДанныхПроцессораCpuInfo.os
  • src/internal/Классы/ПарсерДанныхПроцессораLscpu.os
  • src/internal/Модули/ПарсерИнформацииОПроцессореLinux.os
  • tests/helpers/Классы/МокИсточникИнформацииОПроцессоре.os
  • tests/Тесты_FallbackДетектораПроцессораWindows.os
  • tests/Тесты_Детекторы.os
  • tests/Тесты_ПарсерДанныхПроцессораCpuInfo.os
  • tests/Тесты_ПарсерДанныхПроцессораLscpu.os

@Stivo182
Stivo182 merged commit 895aaf6 into main Aug 7, 2026
21 checks passed
@Stivo182
Stivo182 deleted the perf/linux-cpu-info branch August 7, 2026 08:37
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