Skip to content

Commit

Permalink
src: log more spaces info
Browse files Browse the repository at this point in the history
PR-URL: https://github.com/hyj1991/xprofiler/pull/42
Reviewed-By: peze <cpj1106@gmail.com>
  • Loading branch information
hyj1991 authored Dec 26, 2019
1 parent dd64878 commit 654941c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 14 deletions.
66 changes: 55 additions & 11 deletions src/logbypass/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ void SetHeapSpaceStatistics() {
size_t number_of_heap_spaces = isolate->NumberOfHeapSpaces();
for (size_t i = 0; i < number_of_heap_spaces; i++) {
isolate->GetHeapSpaceStatistics(&s, i);
// todo: read_only_space, large_object_space, code_large_object_space
#define V(name) \
if (strcmp(s.space_name(), #name) == 0) { \
heap_space_statistics->name##_size = s.space_size(); \
heap_space_statistics->name##_used = s.space_used_size(); \
heap_space_statistics->name##_available = s.space_used_size(); \
heap_space_statistics->name##_committed = s.physical_space_size(); \
#define V(name) \
if (strcmp(s.space_name(), #name) == 0) { \
heap_space_statistics->name##_size = s.space_size(); \
heap_space_statistics->name##_used = s.space_used_size(); \
heap_space_statistics->name##_available = s.space_available_size(); \
heap_space_statistics->name##_committed = s.physical_space_size(); \
}
// new space
V(new_space)
Expand All @@ -55,6 +54,15 @@ void SetHeapSpaceStatistics() {
V(map_space)
// large object space
V(large_object_space)
// read only space
// needs v8 version >= 6.8
V(read_only_space)
// new large object space
// needs v8 version >= 6.9
V(new_large_object_space)
// code large object space
// needs v8 version >= 7.3
V(code_large_object_space)
#undef V
}
}
Expand Down Expand Up @@ -113,7 +121,19 @@ void WriteMemoryInfoToLog(bool log_format_alinode) {
"lo_space_size: %zu, "
"lo_space_used: %zu, "
"lo_space_available: %zu, "
"lo_space_committed: %zu",
"lo_space_committed: %zu, "
"read_only_space_size: %zu, "
"read_only_space_used: %zu, "
"read_only_space_available: %zu, "
"read_only_space_committed: %zu, "
"new_lo_space_size: %zu, "
"new_lo_space_used: %zu, "
"new_lo_space_available: %zu, "
"new_lo_space_committed: %zu, "
"code_lo_space_size: %zu, "
"code_lo_space_used: %zu, "
"code_lo_space_available: %zu, "
"code_lo_space_committed: %zu",
// rss
rss,
// heap statistics
Expand All @@ -132,7 +152,13 @@ void WriteMemoryInfoToLog(bool log_format_alinode) {
// map space
V(map),
// large object space
V(large_object));
V(large_object),
// read only space
V(read_only),
// new large object space
V(new_large_object),
// code large object space
V(code_large_object));
} else {
Info("memory",
"memory_usage(byte) "
Expand Down Expand Up @@ -164,7 +190,19 @@ void WriteMemoryInfoToLog(bool log_format_alinode) {
"lo_space_size: %zu, "
"lo_space_used: %zu, "
"lo_space_available: %zu, "
"lo_space_committed: %zu",
"lo_space_committed: %zu, "
"read_only_space_size: %zu, "
"read_only_space_used: %zu, "
"read_only_space_available: %zu, "
"read_only_space_committed: %zu, "
"new_lo_space_size: %zu, "
"new_lo_space_used: %zu, "
"new_lo_space_available: %zu, "
"new_lo_space_committed: %zu, "
"code_lo_space_size: %zu, "
"code_lo_space_used: %zu, "
"code_lo_space_available: %zu, "
"code_lo_space_committed: %zu",
// rss
rss,
// heap statistics
Expand All @@ -183,7 +221,13 @@ void WriteMemoryInfoToLog(bool log_format_alinode) {
// map space
V(map),
// large object space
V(large_object));
V(large_object),
// read only space
V(read_only),
// new large object space
V(new_large_object),
// code large object space
V(code_large_object));
}
#undef V
}
Expand Down
10 changes: 10 additions & 0 deletions src/logbypass/heap.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _SRC_LOGBYPASS_HEAP_H
#define _SRC_LOGBYPASS_HEAP_H

#include "node_version.h"
#include "v8.h"

namespace xprofiler {
Expand Down Expand Up @@ -54,6 +55,15 @@ typedef struct {
V(map)
// large object space
V(large_object)
// read only space
// needs v8 version >= 6.8
V(read_only)
// new large object space
// needs v8 version >= 6.9
V(new_large_object)
// code large object space
// needs v8 version >= 7.3
V(code_large_object)
#undef V
} heap_space_statistics_t;

Expand Down
4 changes: 2 additions & 2 deletions src/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ using std::to_string;
using v8::Local;
using v8::String;

static const int kMaxMessageLength = 1024;
static const int kMaxFormatLength = 1024;
static const int kMaxMessageLength = 2048;
static const int kMaxFormatLength = 2048;

static uv_mutex_t logger_mutex;

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/logbypass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getMemoryRules(list, alinode) {
return setRules(list, alinode, { alinodeRule: alindoeMemoryRule, xprofilerRule: xprofilerMemoryRule });
}
function setSpaceKeys(list) {
const spaces = ['new', 'old', 'code', 'map', 'lo'];
const spaces = ['new', 'old', 'code', 'map', 'lo', 'read_only', 'new_lo', 'code_lo'];
for (const key of spaces) {
list.push(`${key}_space_size`);
list.push(`${key}_space_used`);
Expand Down

0 comments on commit 654941c

Please sign in to comment.