From 6452d146af38f5ba7f6b4c0523dd6dacce1abba1 Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 24 Dec 2025 19:03:18 +0800 Subject: [PATCH] enhance: move jemalloc_stats from pkg to internal/util/segcore (#46560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #46133 Move jemalloc_stats.go and its test file from pkg/util/hardware to internal/util/segcore. This is a more appropriate location because: - jemalloc_stats depends on milvus_core C++ library via cgo - The pkg directory should remain independent of internal C++ dependencies - segcore is the natural home for core memory allocator utilities ## Summary by CodeRabbit * **Refactor** * Improved internal code organization by reorganizing memory statistics collection infrastructure for better maintainability and modularity. No impact on end-user functionality or behavior. ✏️ Tip: You can customize this high-level summary in your review settings. Signed-off-by: Congqi Xia --- internal/querynodev2/metrics_info.go | 3 ++- {pkg/util/hardware => internal/util/segcore}/jemalloc_stats.go | 2 +- .../hardware => internal/util/segcore}/jemalloc_stats_test.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) rename {pkg/util/hardware => internal/util/segcore}/jemalloc_stats.go (99%) rename {pkg/util/hardware => internal/util/segcore}/jemalloc_stats_test.go (99%) diff --git a/internal/querynodev2/metrics_info.go b/internal/querynodev2/metrics_info.go index fc4991a852..c7fc4749ba 100644 --- a/internal/querynodev2/metrics_info.go +++ b/internal/querynodev2/metrics_info.go @@ -30,6 +30,7 @@ import ( "github.com/milvus-io/milvus/internal/querynodev2/collector" "github.com/milvus-io/milvus/internal/querynodev2/delegator" "github.com/milvus-io/milvus/internal/querynodev2/segments" + "github.com/milvus-io/milvus/internal/util/segcore" "github.com/milvus-io/milvus/pkg/v2/log" "github.com/milvus-io/milvus/pkg/v2/metrics" "github.com/milvus-io/milvus/pkg/v2/streaming/util/types" @@ -269,7 +270,7 @@ func getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest, } // Get jemalloc memory statistics - jemallocStats := hardware.GetJemallocStats() + jemallocStats := segcore.GetJemallocStats() hardwareInfos := metricsinfo.HardwareMetrics{ IP: node.session.Address, diff --git a/pkg/util/hardware/jemalloc_stats.go b/internal/util/segcore/jemalloc_stats.go similarity index 99% rename from pkg/util/hardware/jemalloc_stats.go rename to internal/util/segcore/jemalloc_stats.go index 5b5ae6dc46..e25233b15a 100644 --- a/pkg/util/hardware/jemalloc_stats.go +++ b/internal/util/segcore/jemalloc_stats.go @@ -11,7 +11,7 @@ //go:build linux || darwin -package hardware +package segcore /* #cgo pkg-config: milvus_core diff --git a/pkg/util/hardware/jemalloc_stats_test.go b/internal/util/segcore/jemalloc_stats_test.go similarity index 99% rename from pkg/util/hardware/jemalloc_stats_test.go rename to internal/util/segcore/jemalloc_stats_test.go index d61fcd7013..630ecb0f5e 100644 --- a/pkg/util/hardware/jemalloc_stats_test.go +++ b/internal/util/segcore/jemalloc_stats_test.go @@ -9,7 +9,7 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License. -package hardware +package segcore import ( "testing"