aboutsummaryrefslogtreecommitdiffstats
path: root/eval/src/apps
diff options
context:
space:
mode:
Diffstat (limited to 'eval/src/apps')
-rw-r--r--eval/src/apps/analyze_onnx_model/CMakeLists.txt4
-rw-r--r--eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp51
-rw-r--r--eval/src/apps/eval_expr/CMakeLists.txt2
-rw-r--r--eval/src/apps/eval_expr/eval_expr.cpp2
-rw-r--r--eval/src/apps/make_tensor_binary_format_test_spec/CMakeLists.txt2
-rw-r--r--eval/src/apps/make_tensor_binary_format_test_spec/make_tensor_binary_format_test_spec.cpp2
-rw-r--r--eval/src/apps/tensor_conformance/CMakeLists.txt2
-rw-r--r--eval/src/apps/tensor_conformance/generate.cpp2
-rw-r--r--eval/src/apps/tensor_conformance/generate.h2
-rw-r--r--eval/src/apps/tensor_conformance/tensor_conformance.cpp2
10 files changed, 54 insertions, 17 deletions
diff --git a/eval/src/apps/analyze_onnx_model/CMakeLists.txt b/eval/src/apps/analyze_onnx_model/CMakeLists.txt
index dc89213f9eb..6ab7a17e109 100644
--- a/eval/src/apps/analyze_onnx_model/CMakeLists.txt
+++ b/eval/src/apps/analyze_onnx_model/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_executable(eval_analyze_onnx_model_app
SOURCES
analyze_onnx_model.cpp
@@ -6,4 +6,6 @@ vespa_add_executable(eval_analyze_onnx_model_app
INSTALL bin
DEPENDS
vespaeval
+ EXTERNAL_DEPENDS
+ dl
)
diff --git a/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp b/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp
index 31cb1d6b385..051c5027999 100644
--- a/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp
+++ b/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/eval/onnx/onnx_wrapper.h>
#include <vespa/eval/eval/tensor_spec.h>
@@ -10,6 +10,10 @@
#include <vespa/vespalib/util/guard.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <charconv>
+#ifdef __linux__
+#include <malloc.h>
+#include <dlfcn.h>
+#endif
using vespalib::make_string_short::fmt;
@@ -54,10 +58,13 @@ void extract(const vespalib::string &str, const vespalib::string &prefix, vespal
}
}
struct MemoryUsage {
- size_t size;
- size_t rss;
+ size_t vm_size;
+ size_t rss_size;
+ size_t malloc_peak;
+ size_t malloc_current;
};
+#ifdef __linux__
static const vespalib::string UNKNOWN = "unknown";
size_t convert(const vespalib::string & s) {
@@ -85,12 +92,38 @@ MemoryUsage extract_memory_usage() {
extract(line, "VmRSS:", vm_rss);
}
}
- return {convert(vm_size), convert(vm_rss)};
+ MemoryUsage usage = {};
+ usage.vm_size = convert(vm_size);
+ usage.rss_size = convert(vm_rss);
+
+#if __GLIBC_PREREQ(2, 33)
+ struct mallinfo2 info = mallinfo2();
+ usage.malloc_peak = size_t(info.usmblks);
+ usage.malloc_current = size_t(info.arena + info.hblkhd);
+#else
+ struct mallinfo info = mallinfo();
+
+ if (dlsym(RTLD_NEXT, "is_vespamalloc") != nullptr) {
+ // Vespamalloc reports arena in 1M blocks as an 'int' is too small.
+ usage.malloc_peak = size_t(info.usmblks) * 1_Mi;
+ usage.malloc_current = size_t(info.arena + info.hblkhd) * 1_Mi;
+ } else {
+ usage.malloc_peak = size_t(info.usmblks);
+ usage.malloc_current = size_t(info.arena + info.hblkhd);
+ }
+#endif
+ return usage;
+}
+#else
+MemoryUsage extract_memory_usage() {
+ return { 0, 0, 0, 0 };
}
+#endif
void report_memory_usage(const vespalib::string &desc) {
- MemoryUsage vm = extract_memory_usage();
- fprintf(stderr, "vm_size: %zu kB, vm_rss: %zu kB (%s)\n", vm.size/1024, vm.rss/1024, desc.c_str());
+ MemoryUsage m = extract_memory_usage();
+ fprintf(stderr, "vm_size: %zu kB, vm_rss: %zu kB, malloc_peak: %zu kb, malloc_curr: %zu (%s)\n",
+ m.vm_size/1_Ki, m.rss_size/1_Ki, m.malloc_peak/1_Ki, m.malloc_current/1_Ki, desc.c_str());
}
struct Options {
@@ -286,8 +319,10 @@ int probe_types() {
types.setString(output.name, output_type.to_spec());
}
MemoryUsage vm_after = extract_memory_usage();
- root.setLong("vm_size", vm_after.size - vm_before.size);
- root.setLong("vm_rss", vm_after.rss - vm_before.rss);
+ root.setLong("vm_size", vm_after.vm_size - vm_before.vm_size);
+ root.setLong("vm_rss", vm_after.rss_size - vm_before.rss_size);
+ root.setLong("malloc_peak", vm_after.malloc_peak - vm_before.malloc_peak);
+ root.setLong("malloc_current", vm_after.malloc_current - vm_before.malloc_current);
write_compact(result, std_out);
return 0;
}
diff --git a/eval/src/apps/eval_expr/CMakeLists.txt b/eval/src/apps/eval_expr/CMakeLists.txt
index c3c992ab864..082be27eaa7 100644
--- a/eval/src/apps/eval_expr/CMakeLists.txt
+++ b/eval/src/apps/eval_expr/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_executable(eval_eval_expr_app
SOURCES
eval_expr.cpp
diff --git a/eval/src/apps/eval_expr/eval_expr.cpp b/eval/src/apps/eval_expr/eval_expr.cpp
index 2c73b158ba9..23af5a926c4 100644
--- a/eval/src/apps/eval_expr/eval_expr.cpp
+++ b/eval/src/apps/eval_expr/eval_expr.cpp
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/util/require.h>
#include <vespa/eval/eval/function.h>
diff --git a/eval/src/apps/make_tensor_binary_format_test_spec/CMakeLists.txt b/eval/src/apps/make_tensor_binary_format_test_spec/CMakeLists.txt
index c39b21901a2..9fa7b851d84 100644
--- a/eval/src/apps/make_tensor_binary_format_test_spec/CMakeLists.txt
+++ b/eval/src/apps/make_tensor_binary_format_test_spec/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_executable(eval_make_tensor_binary_format_test_spec_app
SOURCES
make_tensor_binary_format_test_spec.cpp
diff --git a/eval/src/apps/make_tensor_binary_format_test_spec/make_tensor_binary_format_test_spec.cpp b/eval/src/apps/make_tensor_binary_format_test_spec/make_tensor_binary_format_test_spec.cpp
index 97daa3cea5d..d3ce9e7cc03 100644
--- a/eval/src/apps/make_tensor_binary_format_test_spec/make_tensor_binary_format_test_spec.cpp
+++ b/eval/src/apps/make_tensor_binary_format_test_spec/make_tensor_binary_format_test_spec.cpp
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/data/slime/slime.h>
#include <vespa/vespalib/objects/nbostream.h>
diff --git a/eval/src/apps/tensor_conformance/CMakeLists.txt b/eval/src/apps/tensor_conformance/CMakeLists.txt
index 84b3a2660fd..73cefc66460 100644
--- a/eval/src/apps/tensor_conformance/CMakeLists.txt
+++ b/eval/src/apps/tensor_conformance/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_executable(vespa-tensor-conformance
SOURCES
generate.cpp
diff --git a/eval/src/apps/tensor_conformance/generate.cpp b/eval/src/apps/tensor_conformance/generate.cpp
index 625915168b8..0ebfb772451 100644
--- a/eval/src/apps/tensor_conformance/generate.cpp
+++ b/eval/src/apps/tensor_conformance/generate.cpp
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "generate.h"
#include <vespa/eval/eval/test/gen_spec.h>
diff --git a/eval/src/apps/tensor_conformance/generate.h b/eval/src/apps/tensor_conformance/generate.h
index 7e4a2e07176..b0f20ac4471 100644
--- a/eval/src/apps/tensor_conformance/generate.h
+++ b/eval/src/apps/tensor_conformance/generate.h
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
diff --git a/eval/src/apps/tensor_conformance/tensor_conformance.cpp b/eval/src/apps/tensor_conformance/tensor_conformance.cpp
index 80714ebb491..3e2d1e844b6 100644
--- a/eval/src/apps/tensor_conformance/tensor_conformance.cpp
+++ b/eval/src/apps/tensor_conformance/tensor_conformance.cpp
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/data/output_writer.h>
#include <vespa/vespalib/data/slime/json_format.h>