mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
perf(core, runtime): Further improve startup time (#17860)
This commit further improves startup time by: - no relying on "JsRuntime::execute_script" for runtime bootstrapping, this is instead done using V8 APIs directly - registering error classes during the snapshot time, instead of on startup Further improvements can be made, mainly around removing "core.initializeAsyncOps()" which takes around 2ms. This commit should result in ~1ms startup time improvement.
This commit is contained in:
parent
5becfd6381
commit
4c6db7aa14
6 changed files with 184 additions and 94 deletions
|
@ -231,6 +231,69 @@ function formatException(error) {
|
|||
}
|
||||
}
|
||||
|
||||
core.registerErrorClass("NotFound", errors.NotFound);
|
||||
core.registerErrorClass("PermissionDenied", errors.PermissionDenied);
|
||||
core.registerErrorClass("ConnectionRefused", errors.ConnectionRefused);
|
||||
core.registerErrorClass("ConnectionReset", errors.ConnectionReset);
|
||||
core.registerErrorClass("ConnectionAborted", errors.ConnectionAborted);
|
||||
core.registerErrorClass("NotConnected", errors.NotConnected);
|
||||
core.registerErrorClass("AddrInUse", errors.AddrInUse);
|
||||
core.registerErrorClass("AddrNotAvailable", errors.AddrNotAvailable);
|
||||
core.registerErrorClass("BrokenPipe", errors.BrokenPipe);
|
||||
core.registerErrorClass("AlreadyExists", errors.AlreadyExists);
|
||||
core.registerErrorClass("InvalidData", errors.InvalidData);
|
||||
core.registerErrorClass("TimedOut", errors.TimedOut);
|
||||
core.registerErrorClass("Interrupted", errors.Interrupted);
|
||||
core.registerErrorClass("WouldBlock", errors.WouldBlock);
|
||||
core.registerErrorClass("WriteZero", errors.WriteZero);
|
||||
core.registerErrorClass("UnexpectedEof", errors.UnexpectedEof);
|
||||
core.registerErrorClass("BadResource", errors.BadResource);
|
||||
core.registerErrorClass("Http", errors.Http);
|
||||
core.registerErrorClass("Busy", errors.Busy);
|
||||
core.registerErrorClass("NotSupported", errors.NotSupported);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionOperationError",
|
||||
function DOMExceptionOperationError(msg) {
|
||||
return new DOMException(msg, "OperationError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionQuotaExceededError",
|
||||
function DOMExceptionQuotaExceededError(msg) {
|
||||
return new DOMException(msg, "QuotaExceededError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionNotSupportedError",
|
||||
function DOMExceptionNotSupportedError(msg) {
|
||||
return new DOMException(msg, "NotSupported");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionNetworkError",
|
||||
function DOMExceptionNetworkError(msg) {
|
||||
return new DOMException(msg, "NetworkError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionAbortError",
|
||||
function DOMExceptionAbortError(msg) {
|
||||
return new DOMException(msg, "AbortError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionInvalidCharacterError",
|
||||
function DOMExceptionInvalidCharacterError(msg) {
|
||||
return new DOMException(msg, "InvalidCharacterError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionDataError",
|
||||
function DOMExceptionDataError(msg) {
|
||||
return new DOMException(msg, "DataError");
|
||||
},
|
||||
);
|
||||
|
||||
function runtimeStart(runtimeOptions, source) {
|
||||
core.setMacrotaskCallback(timers.handleTimerMacrotask);
|
||||
core.setMacrotaskCallback(promiseRejectMacrotaskCallback);
|
||||
|
@ -247,72 +310,6 @@ function runtimeStart(runtimeOptions, source) {
|
|||
colors.setNoColor(runtimeOptions.noColor || !runtimeOptions.isTty);
|
||||
// deno-lint-ignore prefer-primordials
|
||||
Error.prepareStackTrace = core.prepareStackTrace;
|
||||
registerErrors();
|
||||
}
|
||||
|
||||
function registerErrors() {
|
||||
core.registerErrorClass("NotFound", errors.NotFound);
|
||||
core.registerErrorClass("PermissionDenied", errors.PermissionDenied);
|
||||
core.registerErrorClass("ConnectionRefused", errors.ConnectionRefused);
|
||||
core.registerErrorClass("ConnectionReset", errors.ConnectionReset);
|
||||
core.registerErrorClass("ConnectionAborted", errors.ConnectionAborted);
|
||||
core.registerErrorClass("NotConnected", errors.NotConnected);
|
||||
core.registerErrorClass("AddrInUse", errors.AddrInUse);
|
||||
core.registerErrorClass("AddrNotAvailable", errors.AddrNotAvailable);
|
||||
core.registerErrorClass("BrokenPipe", errors.BrokenPipe);
|
||||
core.registerErrorClass("AlreadyExists", errors.AlreadyExists);
|
||||
core.registerErrorClass("InvalidData", errors.InvalidData);
|
||||
core.registerErrorClass("TimedOut", errors.TimedOut);
|
||||
core.registerErrorClass("Interrupted", errors.Interrupted);
|
||||
core.registerErrorClass("WouldBlock", errors.WouldBlock);
|
||||
core.registerErrorClass("WriteZero", errors.WriteZero);
|
||||
core.registerErrorClass("UnexpectedEof", errors.UnexpectedEof);
|
||||
core.registerErrorClass("BadResource", errors.BadResource);
|
||||
core.registerErrorClass("Http", errors.Http);
|
||||
core.registerErrorClass("Busy", errors.Busy);
|
||||
core.registerErrorClass("NotSupported", errors.NotSupported);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionOperationError",
|
||||
function DOMExceptionOperationError(msg) {
|
||||
return new DOMException(msg, "OperationError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionQuotaExceededError",
|
||||
function DOMExceptionQuotaExceededError(msg) {
|
||||
return new DOMException(msg, "QuotaExceededError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionNotSupportedError",
|
||||
function DOMExceptionNotSupportedError(msg) {
|
||||
return new DOMException(msg, "NotSupported");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionNetworkError",
|
||||
function DOMExceptionNetworkError(msg) {
|
||||
return new DOMException(msg, "NetworkError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionAbortError",
|
||||
function DOMExceptionAbortError(msg) {
|
||||
return new DOMException(msg, "AbortError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionInvalidCharacterError",
|
||||
function DOMExceptionInvalidCharacterError(msg) {
|
||||
return new DOMException(msg, "InvalidCharacterError");
|
||||
},
|
||||
);
|
||||
core.registerErrorBuilder(
|
||||
"DOMExceptionDataError",
|
||||
function DOMExceptionDataError(msg) {
|
||||
return new DOMException(msg, "DataError");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const pendingRejections = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue