perf_hooks: add resourcetiming buffer limit

Add WebPerf API `performance.setResourceTimingBufferSize` and event
`'resourcetimingbufferfull'` support.

The resource timing entries are added to the global performance
timeline buffer automatically when using fetch. If users are not
proactively cleaning these events, it can grow without limit. Apply
the https://www.w3.org/TR/timing-entrytypes-registry/ default
resource timing buffer max size so that the buffer can be limited
to not grow indefinitely.

PR-URL: https://github.com/nodejs/node/pull/44220
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
Chengzhong Wu 2022-08-21 10:43:39 +08:00 committed by legendecas
parent 0d46cf6af8
commit 798a6edddf
No known key found for this signature in database
GPG key ID: CB3C9EC2BC27057C
10 changed files with 339 additions and 11 deletions

View file

@ -18,7 +18,10 @@ const {
PerformanceMark,
PerformanceMeasure,
} = require('internal/perf/usertiming');
const { InternalPerformance } = require('internal/perf/performance');
const {
Performance,
performance,
} = require('internal/perf/performance');
const {
createHistogram
@ -27,6 +30,7 @@ const {
const monitorEventLoopDelay = require('internal/perf/event_loop_delay');
module.exports = {
Performance,
PerformanceEntry,
PerformanceMark,
PerformanceMeasure,
@ -35,7 +39,7 @@ module.exports = {
PerformanceResourceTiming,
monitorEventLoopDelay,
createHistogram,
performance: new InternalPerformance(),
performance,
};
ObjectDefineProperty(module.exports, 'constants', {