Skip to content

Conversation

@mryzhov
Copy link
Contributor

@mryzhov mryzhov commented Oct 16, 2025

Details:

  • item1
  • ...

Tickets:

  • ticket-id

@mryzhov mryzhov requested a review from Copilot October 16, 2025 08:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a memory profiler to track memory usage during transformation passes. It implements functionality to monitor and report memory consumption at the process level, providing insights into which passes consume the most memory.

  • Adds memory information tracking with RSS and virtual memory monitoring
  • Implements profiling infrastructure to measure memory usage before and after each pass
  • Adds summary reporting to identify passes with highest memory consumption

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/core/src/pass/manager.cpp Implements memory profiling logic, adds getProcessMemoryInfo function and memory tracking in pass execution
src/core/include/openvino/pass/manager.hpp Declares MemoryInfo struct and getProcessMemoryInfo function for memory profiling interface

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

while (std::getline(status, line)) {
if (line.rfind("VmRSS:", 0) == 0) {
std::sscanf(line.c_str(), "VmRSS: %zu", &info.vm_rss_bytes);
info.vm_rss_bytes /= 1024; // KB → Mbytes
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'Mbytes' to 'MB' for standard unit abbreviation.

Suggested change
info.vm_rss_bytes /= 1024; // KB → Mbytes
info.vm_rss_bytes /= 1024; // KB → MB

Copilot uses AI. Check for mistakes.

Comment on lines +44 to +47
info.vm_rss_bytes /= 1024; // KB → Mbytes
} else if (line.rfind("VmSize:", 0) == 0) {
std::sscanf(line.c_str(), "VmSize: %zu", &info.vm_size_bytes);
info.vm_size_bytes /= 1024;
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

The division by 1024 converts from KB to bytes, but the comment says 'KB → Mbytes'. The variable name suggests bytes, so the conversion should be *= 1024 to convert KB to bytes, or rename the variable to indicate MB units.

Suggested change
info.vm_rss_bytes /= 1024; // KB → Mbytes
} else if (line.rfind("VmSize:", 0) == 0) {
std::sscanf(line.c_str(), "VmSize: %zu", &info.vm_size_bytes);
info.vm_size_bytes /= 1024;
info.vm_rss_bytes *= 1024; // KB → bytes
} else if (line.rfind("VmSize:", 0) == 0) {
std::sscanf(line.c_str(), "VmSize: %zu", &info.vm_size_bytes);
info.vm_size_bytes *= 1024; // KB → bytes

Copilot uses AI. Check for mistakes.

Comment on lines +44 to +47
info.vm_rss_bytes /= 1024; // KB → Mbytes
} else if (line.rfind("VmSize:", 0) == 0) {
std::sscanf(line.c_str(), "VmSize: %zu", &info.vm_size_bytes);
info.vm_size_bytes /= 1024;
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

Same issue as with vm_rss_bytes - the division converts KB to a smaller unit but the variable name suggests bytes. Either multiply by 1024 to get bytes or rename to indicate the actual unit.

Suggested change
info.vm_rss_bytes /= 1024; // KB → Mbytes
} else if (line.rfind("VmSize:", 0) == 0) {
std::sscanf(line.c_str(), "VmSize: %zu", &info.vm_size_bytes);
info.vm_size_bytes /= 1024;
info.vm_rss_bytes *= 1024; // KB → bytes
} else if (line.rfind("VmSize:", 0) == 0) {
std::sscanf(line.c_str(), "VmSize: %zu", &info.vm_size_bytes);
info.vm_size_bytes *= 1024;

Copilot uses AI. Check for mistakes.

MemoryInfo mem_info_after = getProcessMemoryInfo();
std::cout << "After: RSS = " << mem_info_after.vm_rss_bytes << ", VM = " << mem_info_after.vm_size_bytes << std::endl;
std::cout << "Diff: RSS = " << mem_info_after.vm_rss_bytes - mem_info_before.vm_rss_bytes << ", VM = " << mem_info_after.vm_size_bytes - mem_info_before.vm_size_bytes << std::endl;
if(mem_info_after.vm_rss_bytes > max_vm_consumer.vm_rss) {
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

Both conditions check the same value (vm_rss_bytes). The first condition should check vm_size_bytes for VM memory tracking, and the second should check vm_rss_bytes for RSS tracking.

Suggested change
if(mem_info_after.vm_rss_bytes > max_vm_consumer.vm_rss) {
if(mem_info_after.vm_size_bytes > max_vm_consumer.vm) {

Copilot uses AI. Check for mistakes.

max_vm_consumer.vm = mem_info_after.vm_size_bytes;
max_vm_consumer.pass_name = pass_name;
}
if(mem_info_after.vm_rss_bytes > max_rss_consumer.vm_rss) {
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

Both conditions check the same value (vm_rss_bytes). The first condition should check vm_size_bytes for VM memory tracking, and the second should check vm_rss_bytes for RSS tracking.

Copilot uses AI. Check for mistakes.

}


static stopwatch m_pass_time;
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

Static member variables should be declared in the private section of the class, not in the middle of the public section. Move this declaration to the private section with other member variables.

Copilot uses AI. Check for mistakes.

@github-actions github-actions bot added category: Core OpenVINO Core (aka ngraph) category: transformations OpenVINO Runtime library - Transformations category: CPP API OpenVINO CPP API bindings labels Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: Core OpenVINO Core (aka ngraph) category: CPP API OpenVINO CPP API bindings category: transformations OpenVINO Runtime library - Transformations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant