Initial boiler plate project
This commit is contained in:
34
node_modules/next/dist/esm/lib/memory/gc-observer.js
generated
vendored
Normal file
34
node_modules/next/dist/esm/lib/memory/gc-observer.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import { PerformanceObserver } from "perf_hooks";
|
||||
import { warn } from "../../build/output/log";
|
||||
import { bold } from "../picocolors";
|
||||
const LONG_RUNNING_GC_THRESHOLD_MS = 15;
|
||||
const gcEvents = [];
|
||||
const obs = new PerformanceObserver((list)=>{
|
||||
const entry = list.getEntries()[0];
|
||||
gcEvents.push(entry);
|
||||
if (entry.duration > LONG_RUNNING_GC_THRESHOLD_MS) {
|
||||
warn(bold(`Long running GC detected: ${entry.duration.toFixed(2)}ms`));
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Starts recording garbage collection events in the process and warn on long
|
||||
* running GCs. To disable, call `stopObservingGc`.
|
||||
*/ export function startObservingGc() {
|
||||
obs.observe({
|
||||
entryTypes: [
|
||||
"gc"
|
||||
]
|
||||
});
|
||||
}
|
||||
export function stopObservingGc() {
|
||||
obs.disconnect();
|
||||
}
|
||||
/**
|
||||
* Returns all recorded garbage collection events. This function will only
|
||||
* return information from when `startObservingGc` was enabled and before
|
||||
* `stopObservingGc` was called.
|
||||
*/ export function getGcEvents() {
|
||||
return gcEvents;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=gc-observer.js.map
|
||||
1
node_modules/next/dist/esm/lib/memory/gc-observer.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/lib/memory/gc-observer.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/lib/memory/gc-observer.ts"],"names":["PerformanceObserver","warn","bold","LONG_RUNNING_GC_THRESHOLD_MS","gcEvents","obs","list","entry","getEntries","push","duration","toFixed","startObservingGc","observe","entryTypes","stopObservingGc","disconnect","getGcEvents"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,aAAY;AAChD,SAASC,IAAI,QAAQ,yBAAwB;AAC7C,SAASC,IAAI,QAAQ,gBAAe;AAEpC,MAAMC,+BAA+B;AAErC,MAAMC,WAA+B,EAAE;AACvC,MAAMC,MAAM,IAAIL,oBAAoB,CAACM;IACnC,MAAMC,QAAQD,KAAKE,UAAU,EAAE,CAAC,EAAE;IAClCJ,SAASK,IAAI,CAACF;IAEd,IAAIA,MAAMG,QAAQ,GAAGP,8BAA8B;QACjDF,KAAKC,KAAK,CAAC,0BAA0B,EAAEK,MAAMG,QAAQ,CAACC,OAAO,CAAC,GAAG,EAAE,CAAC;IACtE;AACF;AAEA;;;CAGC,GACD,OAAO,SAASC;IACdP,IAAIQ,OAAO,CAAC;QAAEC,YAAY;YAAC;SAAK;IAAC;AACnC;AAEA,OAAO,SAASC;IACdV,IAAIW,UAAU;AAChB;AAEA;;;;CAIC,GACD,OAAO,SAASC;IACd,OAAOb;AACT"}
|
||||
19
node_modules/next/dist/esm/lib/memory/shutdown.js
generated
vendored
Normal file
19
node_modules/next/dist/esm/lib/memory/shutdown.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
import { info } from "../../build/output/log";
|
||||
import { bold } from "../picocolors";
|
||||
import { getGcEvents, stopObservingGc } from "./gc-observer";
|
||||
import { getAllMemoryUsageSpans, stopPeriodicMemoryUsageTracing } from "./trace";
|
||||
export function disableMemoryDebuggingMode() {
|
||||
stopPeriodicMemoryUsageTracing();
|
||||
stopObservingGc();
|
||||
info(bold("Memory usage report:"));
|
||||
const gcEvents = getGcEvents();
|
||||
const totalTimeInGcMs = gcEvents.reduce((acc, event)=>acc + event.duration, 0);
|
||||
info(` - Total time spent in GC: ${totalTimeInGcMs.toFixed(2)}ms`);
|
||||
const allMemoryUsage = getAllMemoryUsageSpans();
|
||||
const peakHeapUsage = Math.max(...allMemoryUsage.map((usage)=>usage["memory.heapUsed"]));
|
||||
const peakRssUsage = Math.max(...allMemoryUsage.map((usage)=>usage["memory.rss"]));
|
||||
info(` - Peak heap usage: ${(peakHeapUsage / 1024 / 1024).toFixed(2)} MB`);
|
||||
info(` - Peak RSS usage: ${(peakRssUsage / 1024 / 1024).toFixed(2)} MB`);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=shutdown.js.map
|
||||
1
node_modules/next/dist/esm/lib/memory/shutdown.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/lib/memory/shutdown.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/lib/memory/shutdown.ts"],"names":["info","bold","getGcEvents","stopObservingGc","getAllMemoryUsageSpans","stopPeriodicMemoryUsageTracing","disableMemoryDebuggingMode","gcEvents","totalTimeInGcMs","reduce","acc","event","duration","toFixed","allMemoryUsage","peakHeapUsage","Math","max","map","usage","peakRssUsage"],"mappings":"AAAA,SAASA,IAAI,QAAQ,yBAAwB;AAC7C,SAASC,IAAI,QAAQ,gBAAe;AACpC,SAASC,WAAW,EAAEC,eAAe,QAAQ,gBAAe;AAC5D,SAASC,sBAAsB,EAAEC,8BAA8B,QAAQ,UAAS;AAEhF,OAAO,SAASC;IACdD;IACAF;IAEAH,KAAKC,KAAK;IAEV,MAAMM,WAAWL;IACjB,MAAMM,kBAAkBD,SAASE,MAAM,CACrC,CAACC,KAAKC,QAAUD,MAAMC,MAAMC,QAAQ,EACpC;IAEFZ,KAAK,CAAC,2BAA2B,EAAEQ,gBAAgBK,OAAO,CAAC,GAAG,EAAE,CAAC;IAEjE,MAAMC,iBAAiBV;IACvB,MAAMW,gBAAgBC,KAAKC,GAAG,IACzBH,eAAeI,GAAG,CAAC,CAACC,QAAUA,KAAK,CAAC,kBAAkB;IAE3D,MAAMC,eAAeJ,KAAKC,GAAG,IACxBH,eAAeI,GAAG,CAAC,CAACC,QAAUA,KAAK,CAAC,aAAa;IAEtDnB,KAAK,CAAC,oBAAoB,EAAE,AAACe,CAAAA,gBAAgB,OAAO,IAAG,EAAGF,OAAO,CAAC,GAAG,GAAG,CAAC;IACzEb,KAAK,CAAC,mBAAmB,EAAE,AAACoB,CAAAA,eAAe,OAAO,IAAG,EAAGP,OAAO,CAAC,GAAG,GAAG,CAAC;AACzE"}
|
||||
33
node_modules/next/dist/esm/lib/memory/startup.js
generated
vendored
Normal file
33
node_modules/next/dist/esm/lib/memory/startup.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
import v8 from "v8";
|
||||
import { info, warn } from "../../build/output/log";
|
||||
import { italic } from "../picocolors";
|
||||
import { startObservingGc } from "./gc-observer";
|
||||
import { startPeriodicMemoryUsageTracing } from "./trace";
|
||||
export function enableMemoryDebuggingMode() {
|
||||
// This will generate a heap snapshot when the program is close to the
|
||||
// memory limit. It does not give any warning to the user though which
|
||||
// can be jarring. If memory is large, this may take a long time.
|
||||
if ("setHeapSnapshotNearHeapLimit" in v8) {
|
||||
// @ts-expect-error - this method exists since Node 16.
|
||||
v8.setHeapSnapshotNearHeapLimit(1);
|
||||
}
|
||||
// This flag will kill the process when it starts to GC thrash when it's
|
||||
// close to the memory limit rather than continuing to try to collect
|
||||
// memory ineffectively.
|
||||
v8.setFlagsFromString("--detect-ineffective-gcs-near-heap-limit");
|
||||
// This allows users to generate a heap snapshot on demand just by sending
|
||||
// a signal to the process.
|
||||
process.on("SIGUSR2", ()=>{
|
||||
warn(`Received SIGUSR2 signal. Generating heap snapshot. ${italic("Note: this will take some time.")}`);
|
||||
v8.writeHeapSnapshot();
|
||||
});
|
||||
startObservingGc();
|
||||
startPeriodicMemoryUsageTracing();
|
||||
warn(`Memory debugging mode is enabled. ${italic("Note: This will affect performance.")}`);
|
||||
info(" - Heap snapshots will be automatically generated when the process reaches more than 70% of the memory limit and again when the process is just about to run out of memory.");
|
||||
info(` - To manually generate a heap snapshot, send the process a SIGUSR2 signal: \`kill -SIGUSR2 ${process.pid}\``);
|
||||
info(" - Heap snapshots when there is high memory will take a very long time to complete and may be difficult to analyze in tools.");
|
||||
info(" - See https://nextjs.org/docs/app/building-your-application/optimizing/memory-usage for more information.");
|
||||
}
|
||||
|
||||
//# sourceMappingURL=startup.js.map
|
||||
1
node_modules/next/dist/esm/lib/memory/startup.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/lib/memory/startup.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/lib/memory/startup.ts"],"names":["v8","info","warn","italic","startObservingGc","startPeriodicMemoryUsageTracing","enableMemoryDebuggingMode","setHeapSnapshotNearHeapLimit","setFlagsFromString","process","on","writeHeapSnapshot","pid"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,IAAI,EAAEC,IAAI,QAAQ,yBAAwB;AACnD,SAASC,MAAM,QAAQ,gBAAe;AACtC,SAASC,gBAAgB,QAAQ,gBAAe;AAChD,SAASC,+BAA+B,QAAQ,UAAS;AAEzD,OAAO,SAASC;IACd,sEAAsE;IACtE,sEAAsE;IACtE,iEAAiE;IACjE,IAAI,kCAAkCN,IAAI;QACxC,uDAAuD;QACvDA,GAAGO,4BAA4B,CAAC;IAClC;IAEA,wEAAwE;IACxE,qEAAqE;IACrE,wBAAwB;IACxBP,GAAGQ,kBAAkB,CAAC;IAEtB,0EAA0E;IAC1E,2BAA2B;IAC3BC,QAAQC,EAAE,CAAC,WAAW;QACpBR,KACE,CAAC,mDAAmD,EAAEC,OACpD,mCACA,CAAC;QAELH,GAAGW,iBAAiB;IACtB;IAEAP;IACAC;IAEAH,KACE,CAAC,kCAAkC,EAAEC,OACnC,uCACA,CAAC;IAELF,KACE;IAEFA,KACE,CAAC,4FAA4F,EAAEQ,QAAQG,GAAG,CAAC,EAAE,CAAC;IAEhHX,KACE;IAEFA,KACE;AAEJ"}
|
||||
82
node_modules/next/dist/esm/lib/memory/trace.js
generated
vendored
Normal file
82
node_modules/next/dist/esm/lib/memory/trace.js
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
import v8 from "v8";
|
||||
import { info, warn } from "../../build/output/log";
|
||||
import { trace } from "../../trace";
|
||||
import { bold, italic } from "../picocolors";
|
||||
import { join } from "path";
|
||||
import { traceGlobals } from "../../trace/shared";
|
||||
const HEAP_SNAPSHOT_THRESHOLD_PERCENT = 70;
|
||||
let alreadyGeneratedHeapSnapshot = false;
|
||||
const TRACE_MEMORY_USAGE_TIMER_MS = 20000;
|
||||
let traceMemoryUsageTimer;
|
||||
const allMemoryUsage = [];
|
||||
/**
|
||||
* Begins a timer that will record memory usage periodically to understand
|
||||
* memory usage across the lifetime of the process.
|
||||
*/ export function startPeriodicMemoryUsageTracing() {
|
||||
traceMemoryUsageTimer = setTimeout(()=>{
|
||||
traceMemoryUsage("periodic memory snapshot");
|
||||
startPeriodicMemoryUsageTracing();
|
||||
}, TRACE_MEMORY_USAGE_TIMER_MS);
|
||||
}
|
||||
export function stopPeriodicMemoryUsageTracing() {
|
||||
if (traceMemoryUsageTimer) {
|
||||
clearTimeout(traceMemoryUsageTimer);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the list of all recorded memory usage snapshots from the process.
|
||||
*/ export function getAllMemoryUsageSpans() {
|
||||
return allMemoryUsage;
|
||||
}
|
||||
/**
|
||||
* Records a snapshot of memory usage at this moment in time to the .next/trace
|
||||
* file.
|
||||
*/ export function traceMemoryUsage(description, parentSpan) {
|
||||
const memoryUsage = process.memoryUsage();
|
||||
const v8HeapStatistics = v8.getHeapStatistics();
|
||||
const heapUsed = v8HeapStatistics.used_heap_size;
|
||||
const heapMax = v8HeapStatistics.heap_size_limit;
|
||||
const tracedMemoryUsage = {
|
||||
"memory.rss": memoryUsage.rss,
|
||||
"memory.heapUsed": heapUsed,
|
||||
"memory.heapTotal": memoryUsage.heapTotal,
|
||||
"memory.heapMax": heapMax
|
||||
};
|
||||
allMemoryUsage.push(tracedMemoryUsage);
|
||||
const tracedMemoryUsageAsStrings = Object.fromEntries(Object.entries(tracedMemoryUsage).map(([key, value])=>[
|
||||
key,
|
||||
String(value)
|
||||
]));
|
||||
if (parentSpan) {
|
||||
parentSpan.traceChild("memory-usage", tracedMemoryUsageAsStrings);
|
||||
} else {
|
||||
trace("memory-usage", undefined, tracedMemoryUsageAsStrings);
|
||||
}
|
||||
if (process.env.EXPERIMENTAL_DEBUG_MEMORY_USAGE) {
|
||||
const percentageHeapUsed = 100 * heapUsed / heapMax;
|
||||
info("");
|
||||
info("***************************************");
|
||||
info(`Memory usage report at "${description}":`);
|
||||
info(` - RSS: ${(memoryUsage.rss / 1024 / 1024).toFixed(2)} MB`);
|
||||
info(` - Heap Used: ${(heapUsed / 1024 / 1024).toFixed(2)} MB`);
|
||||
info(` - Heap Total Allocated: ${(memoryUsage.heapTotal / 1024 / 1024).toFixed(2)} MB`);
|
||||
info(` - Heap Max: ${(heapMax / 1024 / 1024).toFixed(2)} MB`);
|
||||
info(` - Percentage Heap Used: ${percentageHeapUsed.toFixed(2)}%`);
|
||||
info("***************************************");
|
||||
info("");
|
||||
if (percentageHeapUsed > HEAP_SNAPSHOT_THRESHOLD_PERCENT) {
|
||||
const distDir = traceGlobals.get("distDir");
|
||||
const heapFilename = join(distDir, `${description.replace(" ", "-")}.heapsnapshot`);
|
||||
warn(bold(`Heap usage is close to the limit. ${percentageHeapUsed.toFixed(2)}% of heap has been used.`));
|
||||
if (!alreadyGeneratedHeapSnapshot) {
|
||||
warn(bold(`Saving heap snapshot to ${heapFilename}. ${italic("Note: this will take some time.")}`));
|
||||
v8.writeHeapSnapshot(heapFilename);
|
||||
alreadyGeneratedHeapSnapshot = true;
|
||||
} else {
|
||||
warn("Skipping heap snapshot generation since heap snapshot has already been generated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=trace.js.map
|
||||
1
node_modules/next/dist/esm/lib/memory/trace.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/lib/memory/trace.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/lib/memory/trace.ts"],"names":["v8","info","warn","trace","bold","italic","join","traceGlobals","HEAP_SNAPSHOT_THRESHOLD_PERCENT","alreadyGeneratedHeapSnapshot","TRACE_MEMORY_USAGE_TIMER_MS","traceMemoryUsageTimer","allMemoryUsage","startPeriodicMemoryUsageTracing","setTimeout","traceMemoryUsage","stopPeriodicMemoryUsageTracing","clearTimeout","getAllMemoryUsageSpans","description","parentSpan","memoryUsage","process","v8HeapStatistics","getHeapStatistics","heapUsed","used_heap_size","heapMax","heap_size_limit","tracedMemoryUsage","rss","heapTotal","push","tracedMemoryUsageAsStrings","Object","fromEntries","entries","map","key","value","String","traceChild","undefined","env","EXPERIMENTAL_DEBUG_MEMORY_USAGE","percentageHeapUsed","toFixed","distDir","get","heapFilename","replace","writeHeapSnapshot"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,IAAI,EAAEC,IAAI,QAAQ,yBAAwB;AACnD,SAAoBC,KAAK,QAAQ,cAAa;AAC9C,SAASC,IAAI,EAAEC,MAAM,QAAQ,gBAAe;AAC5C,SAASC,IAAI,QAAQ,OAAM;AAC3B,SAASC,YAAY,QAAQ,qBAAoB;AAEjD,MAAMC,kCAAkC;AACxC,IAAIC,+BAA+B;AAEnC,MAAMC,8BAA8B;AACpC,IAAIC;AASJ,MAAMC,iBAAgC,EAAE;AAExC;;;CAGC,GACD,OAAO,SAASC;IACdF,wBAAwBG,WAAW;QACjCC,iBAAiB;QACjBF;IACF,GAAGH;AACL;AAEA,OAAO,SAASM;IACd,IAAIL,uBAAuB;QACzBM,aAAaN;IACf;AACF;AAEA;;CAEC,GACD,OAAO,SAASO;IACd,OAAON;AACT;AAEA;;;CAGC,GACD,OAAO,SAASG,iBACdI,WAAmB,EACnBC,UAA6B;IAE7B,MAAMC,cAAcC,QAAQD,WAAW;IACvC,MAAME,mBAAmBvB,GAAGwB,iBAAiB;IAC7C,MAAMC,WAAWF,iBAAiBG,cAAc;IAChD,MAAMC,UAAUJ,iBAAiBK,eAAe;IAChD,MAAMC,oBAAiC;QACrC,cAAcR,YAAYS,GAAG;QAC7B,mBAAmBL;QACnB,oBAAoBJ,YAAYU,SAAS;QACzC,kBAA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