1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#ifndef SRC_NODE_PERF_COMMON_H_
#define SRC_NODE_PERF_COMMON_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "node.h"
#include "uv.h"
#include "v8.h"
#include <algorithm>
#include <map>
#include <string>
namespace node {
namespace performance {
#define PERFORMANCE_NOW() uv_hrtime()
// These occur before the environment is created. Cache them
// here and add them to the milestones when the env is init'd.
extern uint64_t performance_node_start;
extern uint64_t performance_v8_start;
#define NODE_PERFORMANCE_MILESTONES(V) \
V(ENVIRONMENT, "environment") \
V(NODE_START, "nodeStart") \
V(V8_START, "v8Start") \
V(LOOP_START, "loopStart") \
V(LOOP_EXIT, "loopExit") \
V(BOOTSTRAP_COMPLETE, "bootstrapComplete")
#define NODE_PERFORMANCE_ENTRY_TYPES(V) \
V(NODE, "node") \
V(MARK, "mark") \
V(MEASURE, "measure") \
V(GC, "gc") \
V(FUNCTION, "function") \
V(HTTP2, "http2")
enum PerformanceMilestone {
#define V(name, _) NODE_PERFORMANCE_MILESTONE_##name,
NODE_PERFORMANCE_MILESTONES(V)
#undef V
NODE_PERFORMANCE_MILESTONE_INVALID
};
enum PerformanceEntryType {
#define V(name, _) NODE_PERFORMANCE_ENTRY_TYPE_##name,
NODE_PERFORMANCE_ENTRY_TYPES(V)
#undef V
NODE_PERFORMANCE_ENTRY_TYPE_INVALID
};
class performance_state {
public:
explicit performance_state(v8::Isolate* isolate) :
root(
isolate,
sizeof(performance_state_internal)),
milestones(
isolate,
offsetof(performance_state_internal, milestones),
NODE_PERFORMANCE_MILESTONE_INVALID,
root),
observers(
isolate,
offsetof(performance_state_internal, observers),
NODE_PERFORMANCE_ENTRY_TYPE_INVALID,
root) {
for (size_t i = 0; i < milestones.Length(); i++)
milestones[i] = -1.;
}
AliasedBuffer<uint8_t, v8::Uint8Array> root;
AliasedBuffer<double, v8::Float64Array> milestones;
AliasedBuffer<uint32_t, v8::Uint32Array> observers;
uint64_t performance_last_gc_start_mark = 0;
void Mark(enum PerformanceMilestone milestone,
uint64_t ts = PERFORMANCE_NOW());
private:
struct performance_state_internal {
// doubles first so that they are always sizeof(double)-aligned
double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
};
};
} // namespace performance
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_NODE_PERF_COMMON_H_
|