Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent LDA worker logging can interleave timing records and alter another worker’s floating-point formatting, requiring local record formatting and serialized emission without modifying std::cout’s formatting state.
1 open issue
What changed in this PR
This PR replaces banned APIs in ML.NET’s first-party native code while leaving vendored code unchanged.
Changes:
- Replaces formatted-output calls with C++ streams and string construction.
- Replaces
memcpycalls withstd::copy_n, propagating buffer capacities for validation. - Uses
getenv_sfor Windows diagnostics and retains a presence-only Unix environment check.
| File | Description |
|---|---|
src/Native/SymSgdNative/SymSgdNative.h |
Validates model size before copying weights. |
src/Native/SymSgdNative/SymSgdNative.cpp |
Passes model size to reset calls. |
src/Native/OneDalNative/OneDalAlgorithms.cpp |
Replaces diagnostic output and environment lookup APIs. |
src/Native/LdaNative/timer.h |
Uses string messages and stream-based timing output. |
src/Native/LdaNative/model_block.h |
Propagates rehash and alias buffer capacities. |
src/Native/LdaNative/model_block.cpp |
Updates map construction with buffer size. |
src/Native/LdaNative/light_doc_sampler.cpp |
Supplies rehash buffer capacity. |
src/Native/LdaNative/lda_engine.cpp |
Converts diagnostics to streams and string messages. |
src/Native/LdaNative/hybrid_map.h |
Validates rehash capacity before copying. |
src/Native/LdaNative/hybrid_map.cpp |
Preserves buffer capacity across construction and copying. |
src/Native/LdaNative/hybrid_alias_map.h |
Adds alias memory capacity tracking. |
src/Native/LdaNative/hybrid_alias_map.cpp |
Propagates capacity to alias-table generation. |
src/Native/LdaNative/alias_multinomial_rng_int.hpp |
Validates alias workspace and destination before copying. |
Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7912 +/- ##
=======================================
Coverage 70.85% 70.86%
=======================================
Files 1420 1420
Lines 279991 279991
Branches 27594 27594
=======================================
+ Hits 198381 198408 +27
+ Misses 73462 73446 -16
+ Partials 8148 8137 -11
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
svick
marked this pull request as ready for review
November 13, 2026 10:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
memcpycalls withstd::copy_nand propagate destination capacities so copies are validated before executiongetenv_sfor the diagnostic environment flag on Windows (the old_dupenv_swas not banned, but it allocated unnecessarily)getenvpresence check on Unix, where no better portable replacement is available; the returned pointer is neither dereferenced nor retainedJustification
The replacements remove avoidable banned APIs while preserving existing output and training behavior. Explicit capacity propagation strengthens the copy replacements rather than merely changing the function name. The Unix environment lookup controls only optional diagnostic output and uses
getenvsolely to test whether the variable exists.Note
This PR was generated with GitHub Copilot.