diff options
author | James M Snell <jasnell@gmail.com> | 2021-01-29 03:34:27 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2021-02-22 19:46:11 +0300 |
commit | f3eb224c83f96cff9231f17b1c0a36b762942f48 (patch) | |
tree | 42b62cc1122ef355a47cfe49780a34465887810b /src/node_http2.h | |
parent | 9f2efaa6f3878509a053a5aa9dab7b1b96d2add3 (diff) |
perf_hooks: complete overhaul of the implementation
* Update the user timing implementation to conform to
User Timing Level 3.
* Reimplement user timing and timerify with pure JavaScript
implementations
* Simplify the C++ implementation for gc and http2 perf
* Runtime deprecate additional perf entry properties
in favor of the standard detail argument
* Disable the `buffered` option on PerformanceObserver,
all entries are queued and dispatched on setImmediate.
Only entries with active observers are buffered.
* This does remove the user timing and timerify
trace events. Because the trace_events are still
considered experimental, those can be removed without
a deprecation cycle. They are removed to improve
performance and reduce complexity.
Old: `perf_hooks/usertiming.js n=100000: 92,378.01249733355`
New: perf_hooks/usertiming.js n=100000: 270,393.5280638482`
PR-URL: https://github.com/nodejs/node/pull/37136
Refs: https://github.com/nodejs/diagnostics/issues/464
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'src/node_http2.h')
-rw-r--r-- | src/node_http2.h | 106 |
1 files changed, 24 insertions, 82 deletions
diff --git a/src/node_http2.h b/src/node_http2.h index 9c7ffce2c41..4fa2dc446c0 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -7,6 +7,7 @@ #include <cstdint> #include "nghttp2/nghttp2.h" +#include "env.h" #include "allocated_buffer.h" #include "aliased_struct.h" #include "node_http2_state.h" @@ -456,6 +457,7 @@ class Http2Stream : public AsyncWrap, uint64_t first_byte_sent; // Time first DATA frame byte was sent uint64_t sent_bytes; uint64_t received_bytes; + uint64_t id; }; Statistics statistics_ = {}; @@ -761,6 +763,7 @@ class Http2Session : public AsyncWrap, int32_t stream_count; size_t max_concurrent_streams; double stream_average_duration; + SessionType session_type; }; Statistics statistics_ = {}; @@ -925,96 +928,35 @@ class Http2Session : public AsyncWrap, friend class Http2StreamListener; }; -class Http2SessionPerformanceEntry : public performance::PerformanceEntry { - public: - Http2SessionPerformanceEntry( - Http2State* http2_state, - const Http2Session::Statistics& stats, - SessionType type) : - performance::PerformanceEntry( - http2_state->env(), "Http2Session", "http2", - stats.start_time, - stats.end_time), - ping_rtt_(stats.ping_rtt), - data_sent_(stats.data_sent), - data_received_(stats.data_received), - frame_count_(stats.frame_count), - frame_sent_(stats.frame_sent), - stream_count_(stats.stream_count), - max_concurrent_streams_(stats.max_concurrent_streams), - stream_average_duration_(stats.stream_average_duration), - session_type_(type), - http2_state_(http2_state) { } - - uint64_t ping_rtt() const { return ping_rtt_; } - uint64_t data_sent() const { return data_sent_; } - uint64_t data_received() const { return data_received_; } - uint32_t frame_count() const { return frame_count_; } - uint32_t frame_sent() const { return frame_sent_; } - int32_t stream_count() const { return stream_count_; } - size_t max_concurrent_streams() const { return max_concurrent_streams_; } - double stream_average_duration() const { return stream_average_duration_; } - SessionType type() const { return session_type_; } - Http2State* http2_state() const { return http2_state_.get(); } +struct Http2SessionPerformanceEntryTraits { + static constexpr performance::PerformanceEntryType kType = + performance::NODE_PERFORMANCE_ENTRY_TYPE_HTTP2; - void Notify(v8::Local<v8::Value> obj) { - performance::PerformanceEntry::Notify(env(), kind(), obj); - } + using Details = Http2Session::Statistics; - private: - uint64_t ping_rtt_; - uint64_t data_sent_; - uint64_t data_received_; - uint32_t frame_count_; - uint32_t frame_sent_; - int32_t stream_count_; - size_t max_concurrent_streams_; - double stream_average_duration_; - SessionType session_type_; - BaseObjectPtr<Http2State> http2_state_; + static v8::MaybeLocal<v8::Object> GetDetails( + Environment* env, + const performance::PerformanceEntry<Http2SessionPerformanceEntryTraits>& + entry); }; -class Http2StreamPerformanceEntry - : public performance::PerformanceEntry { - public: - Http2StreamPerformanceEntry( - Http2State* http2_state, - int32_t id, - const Http2Stream::Statistics& stats) : - performance::PerformanceEntry( - http2_state->env(), "Http2Stream", "http2", - stats.start_time, - stats.end_time), - id_(id), - first_header_(stats.first_header), - first_byte_(stats.first_byte), - first_byte_sent_(stats.first_byte_sent), - sent_bytes_(stats.sent_bytes), - received_bytes_(stats.received_bytes), - http2_state_(http2_state) { } - - int32_t id() const { return id_; } - uint64_t first_header() const { return first_header_; } - uint64_t first_byte() const { return first_byte_; } - uint64_t first_byte_sent() const { return first_byte_sent_; } - uint64_t sent_bytes() const { return sent_bytes_; } - uint64_t received_bytes() const { return received_bytes_; } - Http2State* http2_state() const { return http2_state_.get(); } +struct Http2StreamPerformanceEntryTraits { + static constexpr performance::PerformanceEntryType kType = + performance::NODE_PERFORMANCE_ENTRY_TYPE_HTTP2; - void Notify(v8::Local<v8::Value> obj) { - performance::PerformanceEntry::Notify(env(), kind(), obj); - } + using Details = Http2Stream::Statistics; - private: - int32_t id_; - uint64_t first_header_; - uint64_t first_byte_; - uint64_t first_byte_sent_; - uint64_t sent_bytes_; - uint64_t received_bytes_; - BaseObjectPtr<Http2State> http2_state_; + static v8::MaybeLocal<v8::Object> GetDetails( + Environment* env, + const performance::PerformanceEntry<Http2StreamPerformanceEntryTraits>& + entry); }; +using Http2SessionPerformanceEntry = + performance::PerformanceEntry<Http2SessionPerformanceEntryTraits>; +using Http2StreamPerformanceEntry = + performance::PerformanceEntry<Http2StreamPerformanceEntryTraits>; + class Http2Ping : public AsyncWrap { public: explicit Http2Ping( |