Rename memory usage and memory allocated (#1426)
This commit is contained in:
parent
93e6d058d2
commit
48631d1e37
@ -65,7 +65,7 @@ class MetricsService {
|
||||
return MetricsResponse{.vertex_count = info.vertex_count,
|
||||
.edge_count = info.edge_count,
|
||||
.average_degree = info.average_degree,
|
||||
.memory_usage = info.memory_usage,
|
||||
.memory_usage = info.memory_res,
|
||||
.disk_usage = info.disk_usage,
|
||||
.event_counters = GetEventCounters(),
|
||||
.event_gauges = GetEventGauges(),
|
||||
|
@ -42,7 +42,7 @@ void LicenseInfoSender::SendData() {
|
||||
license_info_.WithLock([&data, this](const auto &license_info) mutable {
|
||||
if (license_info && !license_info->organization_name.empty()) {
|
||||
const auto memory_info = utils::GetMemoryInfo();
|
||||
const auto memory_usage = utils::GetMemoryUsage();
|
||||
const auto memory_res = utils::GetMemoryRES();
|
||||
data = {{"run_id", uuid_},
|
||||
{"machine_id", machine_id_},
|
||||
{"type", "license-check"},
|
||||
@ -52,7 +52,7 @@ void LicenseInfoSender::SendData() {
|
||||
{"valid", license_info->is_valid},
|
||||
{"physical_memory_size", memory_info.memory},
|
||||
{"swap_memory_size", memory_info.swap},
|
||||
{"memory_used", memory_usage},
|
||||
{"memory_usage", memory_res},
|
||||
{"runtime_memory_limit", memory_limit_},
|
||||
{"license_memory_limit", license_info->license.memory_limit},
|
||||
{"timestamp", utils::Timestamp::Now().SecWithNsecSinceTheEpoch()}};
|
||||
|
@ -3119,9 +3119,9 @@ PreparedQuery PrepareSystemInfoQuery(ParsedQuery parsed_query, bool in_explicit_
|
||||
{TypedValue("vertex_count"), TypedValue(static_cast<int64_t>(info.vertex_count))},
|
||||
{TypedValue("edge_count"), TypedValue(static_cast<int64_t>(info.edge_count))},
|
||||
{TypedValue("average_degree"), TypedValue(info.average_degree)},
|
||||
{TypedValue("memory_usage"), TypedValue(utils::GetReadableSize(static_cast<double>(info.memory_usage)))},
|
||||
{TypedValue("memory_res"), TypedValue(utils::GetReadableSize(static_cast<double>(info.memory_res)))},
|
||||
{TypedValue("disk_usage"), TypedValue(utils::GetReadableSize(static_cast<double>(info.disk_usage)))},
|
||||
{TypedValue("memory_allocated"),
|
||||
{TypedValue("memory_tracked"),
|
||||
TypedValue(utils::GetReadableSize(static_cast<double>(utils::total_memory_tracker.Amount())))},
|
||||
{TypedValue("allocation_limit"),
|
||||
TypedValue(utils::GetReadableSize(static_cast<double>(utils::total_memory_tracker.HardLimit())))},
|
||||
|
@ -801,7 +801,7 @@ StorageInfo DiskStorage::GetBaseInfo(bool /* unused */) {
|
||||
// NOLINTNEXTLINE(bugprone-narrowing-conversions, cppcoreguidelines-narrowing-conversions)
|
||||
info.average_degree = 2.0 * static_cast<double>(info.edge_count) / info.vertex_count;
|
||||
}
|
||||
info.memory_usage = utils::GetMemoryUsage();
|
||||
info.memory_res = utils::GetMemoryRES();
|
||||
info.disk_usage = GetDiskSpaceUsage();
|
||||
return info;
|
||||
}
|
||||
|
@ -1557,7 +1557,7 @@ StorageInfo InMemoryStorage::GetBaseInfo(bool force_directory) {
|
||||
// NOLINTNEXTLINE(bugprone-narrowing-conversions, cppcoreguidelines-narrowing-conversions)
|
||||
info.average_degree = 2.0 * static_cast<double>(info.edge_count) / info.vertex_count;
|
||||
}
|
||||
info.memory_usage = utils::GetMemoryUsage();
|
||||
info.memory_res = utils::GetMemoryRES();
|
||||
// Special case for the default database
|
||||
auto update_path = [&](const std::filesystem::path &dir) {
|
||||
if (!force_directory && std::filesystem::is_directory(dir) && dir.has_filename()) {
|
||||
|
@ -69,7 +69,7 @@ struct StorageInfo {
|
||||
uint64_t vertex_count;
|
||||
uint64_t edge_count;
|
||||
double average_degree;
|
||||
uint64_t memory_usage;
|
||||
uint64_t memory_res;
|
||||
uint64_t disk_usage;
|
||||
uint64_t label_indices;
|
||||
uint64_t label_property_indices;
|
||||
@ -86,7 +86,7 @@ static inline nlohmann::json ToJson(const StorageInfo &info) {
|
||||
|
||||
res["edges"] = info.edge_count;
|
||||
res["vertices"] = info.vertex_count;
|
||||
res["memory"] = info.memory_usage;
|
||||
res["memory"] = info.memory_res;
|
||||
res["disk"] = info.disk_usage;
|
||||
res["label_indices"] = info.label_indices;
|
||||
res["label_prop_indices"] = info.label_property_indices;
|
||||
|
@ -79,7 +79,7 @@ const nlohmann::json GetResourceUsage(std::filesystem::path root_directory) {
|
||||
auto cpu_total = GetCpuUsage(pid);
|
||||
cpu["usage"] = cpu_total.second;
|
||||
|
||||
return {{"cpu", cpu}, {"memory", utils::GetMemoryUsage()}, {"disk", utils::GetDirDiskUsage(root_directory)}};
|
||||
return {{"cpu", cpu}, {"memory", utils::GetMemoryRES()}, {"disk", utils::GetDirDiskUsage(root_directory)}};
|
||||
}
|
||||
|
||||
} // namespace memgraph::telemetry
|
||||
|
@ -40,7 +40,7 @@ inline uint64_t GetDirDiskUsage(const std::filesystem::path &path) {
|
||||
}
|
||||
|
||||
/// Returns the number of bytes the process is using in the memory.
|
||||
inline uint64_t GetMemoryUsage() {
|
||||
inline uint64_t GetMemoryRES() {
|
||||
// Get PID of entire process.
|
||||
pid_t pid = getpid();
|
||||
uint64_t memory = 0;
|
||||
|
@ -20,9 +20,9 @@ default_storage_info_dict = {
|
||||
"vertex_count": 0,
|
||||
"edge_count": 0,
|
||||
"average_degree": 0,
|
||||
"memory_usage": "", # machine dependent
|
||||
"memory_res": "", # machine dependent
|
||||
"disk_usage": "", # machine dependent
|
||||
"memory_allocated": "", # machine dependent
|
||||
"memory_tracked": "", # machine dependent
|
||||
"allocation_limit": "", # machine dependent
|
||||
"global_isolation_level": "SNAPSHOT_ISOLATION",
|
||||
"session_isolation_level": "",
|
||||
@ -53,7 +53,7 @@ def test_does_default_config_match():
|
||||
config = cursor.fetchall()
|
||||
|
||||
# The default value of these is dependent on the given machine.
|
||||
machine_dependent_configurations = ["memory_usage", "disk_usage", "memory_allocated", "allocation_limit"]
|
||||
machine_dependent_configurations = ["memory_res", "disk_usage", "memory_tracked", "allocation_limit"]
|
||||
|
||||
# Number of different data-points returned by SHOW STORAGE INFO
|
||||
assert len(config) == 12
|
||||
|
@ -160,7 +160,7 @@ def get_tracker_data(session) -> Optional[float]:
|
||||
|
||||
try:
|
||||
data, _ = try_execute(session, f"SHOW STORAGE INFO")
|
||||
memory_tracker_data = isolate_value(data, "memory_allocated")
|
||||
memory_tracker_data = isolate_value(data, "memory_tracked")
|
||||
|
||||
return parse_data(memory_tracker_data)
|
||||
|
||||
|
@ -144,7 +144,7 @@ def run_writer(repetition_count: int, sleep_sec: float, worker_id: int) -> int:
|
||||
def create() -> bool:
|
||||
exception_occured = False
|
||||
|
||||
memory_allocated_before, _ = get_storage_data(session)
|
||||
memory_tracked_before, _ = get_storage_data(session)
|
||||
count_before = execute_till_success(session, f"MATCH (n) RETURN COUNT(n) AS cnt")[0][0]["cnt"]
|
||||
try:
|
||||
try_execute(
|
||||
@ -155,12 +155,12 @@ def run_writer(repetition_count: int, sleep_sec: float, worker_id: int) -> int:
|
||||
log.info(f"Exception occured during create: {ex}")
|
||||
exception_occured = True
|
||||
|
||||
memory_allocated_after, _ = get_storage_data(session)
|
||||
memory_tracked_after, _ = get_storage_data(session)
|
||||
count_after = execute_till_success(session, f"MATCH (n) RETURN COUNT(n) AS cnt")[0][0]["cnt"]
|
||||
if exception_occured:
|
||||
log.info(
|
||||
f"Exception occured, stopping exection of run {Constants.CREATE_FUNCTION} worker."
|
||||
f"Memory stats: before query: {memory_allocated_before}, after query: {memory_allocated_after}."
|
||||
f"Memory stats: before query: {memory_tracked_before}, after query: {memory_tracked_after}."
|
||||
f"Node stats: before query {count_before}, after query {count_after}"
|
||||
)
|
||||
return False
|
||||
@ -228,8 +228,8 @@ def get_storage_data(session) -> Tuple[float, float]:
|
||||
|
||||
try:
|
||||
data = execute_till_success(session, f"SHOW STORAGE INFO")[0]
|
||||
res_data = isolate_value(data, "memory_usage")
|
||||
memory_tracker_data = isolate_value(data, "memory_allocated")
|
||||
res_data = isolate_value(data, "memory_res")
|
||||
memory_tracker_data = isolate_value(data, "memory_tracked")
|
||||
log.info(
|
||||
f"Worker {Constants.MONITOR_CLEANUP_FUNCTION} logged memory: memory tracker {memory_tracker_data} vs res data {res_data}"
|
||||
)
|
||||
|
@ -161,8 +161,8 @@ TYPED_TEST(InfoTest, InfoCheck) {
|
||||
ASSERT_EQ(info.storage_info.vertex_count, 5);
|
||||
ASSERT_EQ(info.storage_info.edge_count, 2);
|
||||
ASSERT_EQ(info.storage_info.average_degree, 0.8);
|
||||
ASSERT_GT(info.storage_info.memory_usage, 10'000'000); // 200MB < > 10MB
|
||||
ASSERT_LT(info.storage_info.memory_usage, 200'000'000);
|
||||
ASSERT_GT(info.storage_info.memory_res, 10'000'000); // 200MB < > 10MB
|
||||
ASSERT_LT(info.storage_info.memory_res, 200'000'000);
|
||||
ASSERT_GT(info.storage_info.disk_usage, 100); // 1MB < > 100B
|
||||
ASSERT_LT(info.storage_info.disk_usage, 1000'000);
|
||||
ASSERT_EQ(info.storage_info.label_indices, 1);
|
||||
|
@ -140,8 +140,8 @@ TYPED_TEST(InfoTest, InfoCheck) {
|
||||
ASSERT_EQ(info.vertex_count, 5);
|
||||
ASSERT_EQ(info.edge_count, 2);
|
||||
ASSERT_EQ(info.average_degree, 0.8);
|
||||
ASSERT_GT(info.memory_usage, 10'000'000); // 200MB < > 10MB
|
||||
ASSERT_LT(info.memory_usage, 200'000'000);
|
||||
ASSERT_GT(info.memory_res, 10'000'000); // 200MB < > 10MB
|
||||
ASSERT_LT(info.memory_res, 200'000'000);
|
||||
ASSERT_GT(info.disk_usage, 100); // 1MB < > 100B
|
||||
ASSERT_LT(info.disk_usage, 1000'000);
|
||||
ASSERT_EQ(info.label_indices, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user