Skip to content

Rprs 0 mem debug#1

Open
michachen wants to merge 4 commits into
publishfrom
RPRS-0-mem-debug
Open

Rprs 0 mem debug#1
michachen wants to merge 4 commits into
publishfrom
RPRS-0-mem-debug

Conversation

@michachen

Copy link
Copy Markdown

local temp solution until 1.2.9 is released

@codeguard-pr-analyzer

Copy link
Copy Markdown

🤖 CodeGuard PR Analysis

✨ Summary

This pull request modifies the build process to bundle CatBoost C API headers and pre-compiled libraries directly into the project, rather than downloading them dynamically. It also introduces a load_buffer_zero_copy method in src/model.rs to address an ARM64 memory leak by using zero-copy model loading. This is noted as a temporary solution.

🎯 Jira Ticket Alignment: ℹ️ Not Found

⚠️ Risk Level: 🟡 Medium

The PR introduces bundled native binaries, replacing dynamic fetching. This shift from dynamic linking to bundled binaries carries a medium risk of platform-specific compatibility issues if not rigorously tested across all target environments. It also acts as a temporary workaround for an ARM64 memory leak, which suggests a degree of instability in the solution.

🧪 Test Coverage

⚠️ No tests added for new load_buffer_zero_copy functionality or for the build process changes, which now rely on bundled binaries.

📊 Root Cause Analysis

The changes are a temporary solution to mitigate a known memory leak issue in CatBoost's internal memory pools on ARM64 (aarch64) when models are loaded from a buffer using the copying mechanism. Bundling the binaries bypasses external dependencies and potentially ensures a specific, stable version for the workaround.

🔗 Dependency Chain
  • Modified: build.rs, src/model.rs
  • Impacts: The build process, model loading mechanism, and overall memory footprint/stability, especially on ARM64 platforms.
  • Dependencies: Removed dynamic download dependencies (ureq and io used for downloads in build.rs). Now implicitly depends on the correctly bundled CatBoost C API libraries (c_api.h, libcatboostmodel.so/.dylib/.dll).
📝 Detailed Changes

New Features:

  • src/model.rs: Added Model::load_buffer_zero_copy for memory-efficient, zero-copy model loading.

Modified:

  • build.rs: Refactored to use local, bundled c_api.h and platform-specific libcatboostmodel files instead of downloading them from GitHub releases. Removed io import.
  • src/model.rs: Added _buffer_owner: Option<Arc<Vec<u8>>> to Model struct to manage the lifetime of zero-copy loaded buffers. Added a warning to the existing load_buffer method about ARM64 memory leaks.

Added:

  • c_api.h: Bundled CatBoost C API header file.
  • libcatboostmodel-x86_64.so: Bundled CatBoost shared library for Linux x86_64.
  • libcatboostmodel.dylib: Bundled CatBoost dynamic library for macOS.
  • libcatboostmodel.so: Bundled CatBoost shared library for Linux aarch64.

Powered by Gemini 2.5 Flash | Last updated: 15/02/2026 08:49:06 UTC

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