-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of String.prototype.split uses #56746
Improve performance of String.prototype.split uses #56746
Conversation
perf: use "limit" param on split on asset prefix parsing
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
did you verify that all the limit args make sense where you added them? |
Normally this wouldn't break anything, on the cases where split was not followed by a [0], I read the code to adapt it to the cases. For example, in cases where the "spread" operator was used, I counted the number of resulting variables. On the other hand, I left unchanged cases where, for example, Sometimes it can be "too much" in cases like hostname parsing, but I think it can bring small performance improvements |
Tests Passed |
I reviewed all the files and it looks safe. However, the benchmark you provided seems to indicate performance won't change or could get worse for small strings. The first example,
|
Stats from current PRDefault BuildGeneral Overall increase
|
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
buildDuration | 10.7s | 10.4s | N/A |
buildDurationCached | 6.1s | 6.1s | N/A |
nodeModulesSize | 175 MB | 175 MB | |
nextStartRea..uration (ms) | 535ms | 531ms | N/A |
Client Bundles (main, webpack)
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
199-HASH.js gzip | 27.5 kB | 27.5 kB | N/A |
3f784ff6-HASH.js gzip | 53.3 kB | 53.3 kB | ✓ |
99.HASH.js gzip | 182 B | 182 B | ✓ |
framework-HASH.js gzip | 45.3 kB | 45.3 kB | ✓ |
main-app-HASH.js gzip | 254 B | 252 B | N/A |
main-HASH.js gzip | 32.9 kB | 32.9 kB | N/A |
webpack-HASH.js gzip | 1.75 kB | 1.75 kB | N/A |
Overall change | 98.8 kB | 98.8 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
_app-HASH.js gzip | 206 B | 205 B | N/A |
_error-HASH.js gzip | 182 B | 180 B | N/A |
amp-HASH.js gzip | 506 B | 505 B | N/A |
css-HASH.js gzip | 322 B | 323 B | N/A |
dynamic-HASH.js gzip | 2.57 kB | 2.57 kB | N/A |
edge-ssr-HASH.js gzip | 260 B | 259 B | N/A |
head-HASH.js gzip | 350 B | 350 B | ✓ |
hooks-HASH.js gzip | 369 B | 369 B | ✓ |
image-HASH.js gzip | 4.35 kB | 4.36 kB | N/A |
index-HASH.js gzip | 256 B | 256 B | ✓ |
link-HASH.js gzip | 2.64 kB | 2.63 kB | N/A |
routerDirect..HASH.js gzip | 312 B | 311 B | N/A |
script-HASH.js gzip | 385 B | 384 B | N/A |
withRouter-HASH.js gzip | 307 B | 308 B | N/A |
1afbb74e6ecf..834.css gzip | 106 B | 106 B | ✓ |
Overall change | 1.08 kB | 1.08 kB | ✓ |
Client Build Manifests
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
_buildManifest.js gzip | 485 B | 482 B | N/A |
Overall change | 0 B | 0 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
index.html gzip | 528 B | 529 B | N/A |
link.html gzip | 541 B | 542 B | N/A |
withRouter.html gzip | 524 B | 524 B | ✓ |
Overall change | 524 B | 524 B | ✓ |
Edge SSR bundle Size
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
edge-ssr.js gzip | 93.7 kB | 93.7 kB | N/A |
page.js gzip | 155 kB | 155 kB | N/A |
Overall change | 0 B | 0 B | ✓ |
Middleware size
vercel/next.js canary | Yovach/next.js perf/optimize-split-optional-param | Change | |
---|---|---|---|
middleware-b..fest.js gzip | 624 B | 621 B | N/A |
middleware-r..fest.js gzip | 150 B | 151 B | N/A |
middleware.js gzip | 22.5 kB | 22.5 kB | N/A |
edge-runtime..pack.js gzip | 1.92 kB | 1.92 kB | ✓ |
Overall change | 1.92 kB | 1.92 kB | ✓ |
Diff details
Diff for page.js
Diff too large to display
Diff for middleware.js
@@ -2,7 +2,7 @@
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
[826],
{
- /***/ 6335: /***/ (
+ /***/ 3717: /***/ (
__unused_webpack_module,
__webpack_exports__,
__webpack_require__
@@ -21,7 +21,7 @@
__webpack_require__.r(middleware_namespaceObject);
__webpack_require__.d(middleware_namespaceObject, {
default: () => middleware,
- }); // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/globals.js
+ }); // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/globals.js
async function registerInstrumentation() {
if (
@@ -91,7 +91,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
// Eagerly fire instrumentation hook to make the startup faster.
void ensureInstrumentationRegistered();
}
- enhanceGlobals(); //# sourceMappingURL=globals.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/error.js
+ enhanceGlobals(); //# sourceMappingURL=globals.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/error.js
class PageSignatureError extends Error {
constructor({ page }) {
@@ -118,7 +118,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
`);
}
- } //# sourceMappingURL=error.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/utils.js
+ } //# sourceMappingURL=error.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/utils.js
/**
* Converts a Node.js IncomingHttpHeaders object to a Headers object. Any
@@ -253,7 +253,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
);
}
- } //# sourceMappingURL=utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/fetch-event.js
+ } //# sourceMappingURL=utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/fetch-event.js
const responseSymbol = Symbol("response");
const passThroughSymbol = Symbol("passThrough");
@@ -299,7 +299,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
page: this.sourcePage,
});
}
- } //# sourceMappingURL=fetch-event.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/i18n/detect-domain-locale.js
+ } //# sourceMappingURL=fetch-event.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/i18n/detect-domain-locale.js
function detectDomainLocale(domainItems, hostname, detectedLocale) {
if (!domainItems) return;
@@ -312,7 +312,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
const domainHostname =
(_item_domain = item.domain) == null
? void 0
- : _item_domain.split(":")[0].toLowerCase();
+ : _item_domain.split(":", 1)[0].toLowerCase();
if (
hostname === domainHostname ||
detectedLocale === item.defaultLocale.toLowerCase() ||
@@ -325,7 +325,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
return item;
}
}
- } //# sourceMappingURL=detect-domain-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/remove-trailing-slash.js
+ } //# sourceMappingURL=detect-domain-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/remove-trailing-slash.js
/**
* Removes the trailing slash for a given route or page path. Preserves the
@@ -335,7 +335,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
* - `/` -> `/`
*/ function removeTrailingSlash(route) {
return route.replace(/\/$/, "") || "/";
- } //# sourceMappingURL=remove-trailing-slash.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/parse-path.js
+ } //# sourceMappingURL=remove-trailing-slash.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/parse-path.js
/**
* Given a path this function will find the pathname, query and hash and return
@@ -363,7 +363,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
query: "",
hash: "",
};
- } //# sourceMappingURL=parse-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/add-path-prefix.js
+ } //# sourceMappingURL=parse-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/add-path-prefix.js
/**
* Adds the provided prefix to the given path. It first ensures that the path
@@ -374,7 +374,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
const { pathname, query, hash } = parsePath(path);
return "" + prefix + pathname + query + hash;
- } //# sourceMappingURL=add-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/add-path-suffix.js
+ } //# sourceMappingURL=add-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/add-path-suffix.js
/**
* Similarly to `addPathPrefix`, this function adds a suffix at the end on the
@@ -386,7 +386,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
const { pathname, query, hash } = parsePath(path);
return "" + pathname + suffix + query + hash;
- } //# sourceMappingURL=add-path-suffix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/path-has-prefix.js
+ } //# sourceMappingURL=add-path-suffix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/path-has-prefix.js
/**
* Checks if a given path starts with a given prefix. It ensures it matches
@@ -400,7 +400,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
const { pathname } = parsePath(path);
return pathname === prefix || pathname.startsWith(prefix + "/");
- } //# sourceMappingURL=path-has-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/add-locale.js
+ } //# sourceMappingURL=path-has-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/add-locale.js
/**
* For a given path and a locale, if the locale is given, it will prefix the
@@ -419,7 +419,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
// Add the locale prefix to the path.
return addPathPrefix(path, "/" + locale);
- } //# sourceMappingURL=add-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/format-next-pathname-info.js
+ } //# sourceMappingURL=add-locale.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/format-next-pathname-info.js
function formatNextPathnameInfo(info) {
let pathname = addLocale(
@@ -443,7 +443,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
? addPathSuffix(pathname, "/")
: pathname
: removeTrailingSlash(pathname);
- } //# sourceMappingURL=format-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/get-hostname.js
+ } //# sourceMappingURL=format-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/get-hostname.js
/**
* Takes an object with a hostname property (like a parsed URL) and some
@@ -458,12 +458,12 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
(headers == null ? void 0 : headers.host) &&
!Array.isArray(headers.host)
) {
- hostname = headers.host.toString().split(":")[0];
+ hostname = headers.host.toString().split(":", 1)[0];
} else if (parsed.hostname) {
hostname = parsed.hostname;
} else return;
return hostname.toLowerCase();
- } //# sourceMappingURL=get-hostname.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/i18n/normalize-locale-path.js
+ } //# sourceMappingURL=get-hostname.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/i18n/normalize-locale-path.js
/**
* For a pathname that may include a locale from a list of locales, it
@@ -493,7 +493,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
pathname,
detectedLocale,
};
- } //# sourceMappingURL=normalize-locale-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/remove-path-prefix.js
+ } //# sourceMappingURL=normalize-locale-path.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/remove-path-prefix.js
/**
* Given a path and a prefix it will remove the prefix when it exists in the
@@ -527,7 +527,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
// If the path without the prefix doesn't start with a `/` we need to add it
// back to the path to make sure it's a valid path.
return "/" + withoutPrefix;
- } //# sourceMappingURL=remove-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/get-next-pathname-info.js
+ } //# sourceMappingURL=remove-path-prefix.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/get-next-pathname-info.js
function getNextPathnameInfo(pathname, options) {
var _options_nextConfig;
@@ -585,7 +585,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
}
return info;
- } //# sourceMappingURL=get-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/next-url.js
+ } //# sourceMappingURL=get-next-pathname-info.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/next-url.js
const REGEX_LOCALHOST_HOSTNAME =
/(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|\[::1\]|localhost)/;
@@ -812,8 +812,8 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
} //# sourceMappingURL=next-url.js.map
- // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
- var _edge_runtime_cookies = __webpack_require__(3842); // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/cookies.js // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/request.js
+ // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
+ var _edge_runtime_cookies = __webpack_require__(5511); // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/cookies.js // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/request.js
//# sourceMappingURL=cookies.js.map
const INTERNALS = Symbol("internal request");
@@ -890,7 +890,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
get url() {
return this[INTERNALS].url;
}
- } //# sourceMappingURL=request.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/response.js
+ } //# sourceMappingURL=request.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/response.js
const response_INTERNALS = Symbol("internal response");
const REDIRECTS = new Set([301, 302, 303, 307, 308]);
@@ -988,7 +988,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
headers,
});
}
- } //# sourceMappingURL=response.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/relativize-url.js
+ } //# sourceMappingURL=response.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/relativize-url.js
/**
* Given a URL as a string and a base URL it will make the URL relative
@@ -1001,7 +1001,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
return relative.protocol + "//" + relative.host === origin
? relative.toString().replace(origin, "")
: relative.toString();
- } //# sourceMappingURL=relativize-url.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/client/components/app-router-headers.js
+ } //# sourceMappingURL=relativize-url.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/client/components/app-router-headers.js
const RSC = "RSC";
const ACTION = "Next-Action";
@@ -1022,7 +1022,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
[NEXT_ROUTER_STATE_TREE],
[NEXT_ROUTER_PREFETCH],
];
- const NEXT_RSC_UNION_QUERY = "_rsc"; //# sourceMappingURL=app-router-headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/internal-utils.js
+ const NEXT_RSC_UNION_QUERY = "_rsc"; //# sourceMappingURL=app-router-headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/internal-utils.js
const INTERNAL_QUERY_NAMES = [
"__nextFallback",
@@ -1071,7 +1071,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
for (const key of INTERNAL_HEADERS) {
delete headers[key];
}
- } //# sourceMappingURL=internal-utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
+ } //# sourceMappingURL=internal-utils.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
/**
* Normalizes an app route so it represents the actual request path. Essentially
@@ -1122,7 +1122,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
* Since this function is used on full urls it checks `?` for searchParams handling.
*/ function normalizeRscPath(pathname, enabled) {
return enabled ? pathname.replace(/\.rsc($|\?)/, "$1") : pathname;
- } //# sourceMappingURL=app-paths.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/lib/constants.js
+ } //# sourceMappingURL=app-paths.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/lib/constants.js
const NEXT_QUERY_PARAM_PREFIX = "nxtP";
const PRERENDER_REVALIDATE_HEADER = "x-prerender-revalidate";
@@ -1287,7 +1287,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
metadata: "__next_metadata__",
metadataRoute: "__next_metadata_route__",
metadataImageMeta: "__next_metadata_image_meta__",
- }; // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js
+ }; // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/adapters/reflect.js
//# sourceMappingURL=constants.js.map
class ReflectAdapter {
@@ -1307,7 +1307,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
static deleteProperty(target, prop) {
return Reflect.deleteProperty(target, prop);
}
- } //# sourceMappingURL=reflect.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js
+ } //# sourceMappingURL=reflect.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/adapters/headers.js
/**
* @internal
@@ -1488,7 +1488,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
[Symbol.iterator]() {
return this.entries();
}
- } //# sourceMappingURL=headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js
+ } //# sourceMappingURL=headers.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/spec-extension/adapters/request-cookies.js
/**
* @internal
@@ -1621,7 +1621,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
},
});
}
- } //# sourceMappingURL=request-cookies.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/api-utils/index.js
+ } //# sourceMappingURL=request-cookies.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/api-utils/index.js
/**
*
@@ -1676,7 +1676,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
if (SYMBOL_CLEARED_COOKIES in res) {
return res;
}
- const { serialize } = __webpack_require__(7171);
+ const { serialize } = __webpack_require__(847);
const previous = res.getHeader("Set-Cookie");
res.setHeader(`Set-Cookie`, [
...(typeof previous === "string"
@@ -1773,7 +1773,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
});
},
});
- } //# sourceMappingURL=index.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/async-storage/draft-mode-provider.js
+ } //# sourceMappingURL=index.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/async-storage/draft-mode-provider.js
class DraftModeProvider {
constructor(previewProps, req, cookies, mutableCookies) {
@@ -1826,7 +1826,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
expires: new Date(0),
});
}
- } //# sourceMappingURL=draft-mode-provider.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/async-storage/request-async-storage-wrapper.js
+ } //# sourceMappingURL=draft-mode-provider.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/async-storage/request-async-storage-wrapper.js
function getHeaders(headers) {
const cleaned = HeadersAdapter.from(headers);
@@ -1911,10 +1911,10 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
},
}; //# sourceMappingURL=request-async-storage-wrapper.js.map
- // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/client/components/async-local-storage.js
- var async_local_storage = __webpack_require__(7940); // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/client/components/request-async-storage.external.js
+ // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/client/components/async-local-storage.js
+ var async_local_storage = __webpack_require__(4049); // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/client/components/request-async-storage.external.js
const requestAsyncStorage = (0,
- async_local_storage /* createAsyncLocalStorage */.P)(); //# sourceMappingURL=request-async-storage.external.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/adapter.js
+ async_local_storage /* createAsyncLocalStorage */.P)(); //# sourceMappingURL=request-async-storage.external.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/adapter.js
class NextRequestHint extends NextRequest {
constructor(params) {
@@ -2178,14 +2178,14 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
waitUntil: Promise.all(event[waitUntilSymbol]),
fetchMetrics: request.fetchMetrics,
};
- } //# sourceMappingURL=adapter.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/exports/next-response.js // CONCATENATED MODULE: ./middleware.js
+ } //# sourceMappingURL=adapter.js.map // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/web/exports/next-response.js // CONCATENATED MODULE: ./middleware.js
// This file is for modularized imports for next/server to get fully-treeshaking.
//# sourceMappingURL=next-response.js.map
async function middleware() {
return NextResponse.next();
- } // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=private-next-root-dir%2Fmiddleware.js&page=%2Fmiddleware&rootDir=%2Ftmp%2Fnext-statsfsR5qv%2Fstats-app&matchers=&preferredRegion=&middlewareConfig=e30%3D!
+ } // CONCATENATED MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=private-next-root-dir%2Fmiddleware.js&page=%2Fmiddleware&rootDir=%2Ftmp%2Fnext-statsfsR5qv%2Fstats-app&matchers=&preferredRegion=&middlewareConfig=e30%3D!
// Import the userland code.
@@ -2212,7 +2212,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
/***/
},
- /***/ 3842: /***/ (module) => {
+ /***/ 5511: /***/ (module) => {
"use strict";
var __defProp = Object.defineProperty;
@@ -2562,7 +2562,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
/***/
},
- /***/ 7171: /***/ (module) => {
+ /***/ 847: /***/ (module) => {
"use strict";
var __dirname = "/";
@@ -2692,7 +2692,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
/***/
},
- /***/ 7940: /***/ (
+ /***/ 4049: /***/ (
__unused_webpack_module,
__webpack_exports__,
__webpack_require__
@@ -2738,7 +2738,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
// webpackRuntimeModules
/******/ var __webpack_exec__ = (moduleId) =>
__webpack_require__((__webpack_require__.s = moduleId));
- /******/ var __webpack_exports__ = __webpack_exec__(6335);
+ /******/ var __webpack_exports__ = __webpack_exec__(3717);
/******/ (_ENTRIES =
typeof _ENTRIES === "undefined" ? {} : _ENTRIES).middleware_middleware =
__webpack_exports__;
Diff for edge-ssr.js
Diff too large to display
Diff for image-HASH.js
@@ -1,7 +1,7 @@
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([
[358],
{
- /***/ 1552: /***/ function (
+ /***/ 4070: /***/ function (
__unused_webpack_module,
__unused_webpack_exports,
__webpack_require__
@@ -9,7 +9,7 @@
(window.__NEXT_P = window.__NEXT_P || []).push([
"/image",
function () {
- return __webpack_require__(528);
+ return __webpack_require__(5921);
},
]);
if (false) {
@@ -18,7 +18,7 @@
/***/
},
- /***/ 4036: /***/ function (module, exports, __webpack_require__) {
+ /***/ 2155: /***/ function (module, exports, __webpack_require__) {
"use strict";
/* __next_internal_client_entry_do_not_use__ cjs */
Object.defineProperty(exports, "__esModule", {
@@ -39,15 +39,15 @@
__webpack_require__(422)
);
const _head = /*#__PURE__*/ _interop_require_default._(
- __webpack_require__(8777)
+ __webpack_require__(9561)
);
- const _getimgprops = __webpack_require__(2391);
- const _imageconfig = __webpack_require__(1138);
- const _imageconfigcontextsharedruntime = __webpack_require__(5615);
- const _warnonce = __webpack_require__(7536);
- const _routercontextsharedruntime = __webpack_require__(6174);
+ const _getimgprops = __webpack_require__(3787);
+ const _imageconfig = __webpack_require__(3767);
+ const _imageconfigcontextsharedruntime = __webpack_require__(8744);
+ const _warnonce = __webpack_require__(6908);
+ const _routercontextsharedruntime = __webpack_require__(937);
const _imageloader = /*#__PURE__*/ _interop_require_default._(
- __webpack_require__(7512)
+ __webpack_require__(2534)
);
// This is replaced by webpack define plugin
const configEnv = {
@@ -127,7 +127,7 @@
});
}
function getDynamicProps(fetchPriority) {
- const [majorStr, minorStr] = _react.version.split(".");
+ const [majorStr, minorStr] = _react.version.split(".", 2);
const major = parseInt(majorStr, 10);
const minor = parseInt(minorStr, 10);
if (major > 18 || (major === 18 && minor >= 3)) {
@@ -372,7 +372,7 @@
/***/
},
- /***/ 2391: /***/ function (
+ /***/ 3787: /***/ function (
__unused_webpack_module,
exports,
__webpack_require__
@@ -388,9 +388,9 @@
return getImgProps;
},
});
- const _warnonce = __webpack_require__(7536);
- const _imageblursvg = __webpack_require__(9080);
- const _imageconfig = __webpack_require__(1138);
+ const _warnonce = __webpack_require__(6908);
+ const _imageblursvg = __webpack_require__(9317);
+ const _imageconfig = __webpack_require__(3767);
const VALID_LOADING_VALUES =
/* unused pure expression or super */ null && [
"lazy",
@@ -759,7 +759,7 @@
/***/
},
- /***/ 9080: /***/ function (__unused_webpack_module, exports) {
+ /***/ 9317: /***/ function (__unused_webpack_module, exports) {
"use strict";
/**
* A shared function, used on both client and server, to generate a SVG blur placeholder.
@@ -814,7 +814,7 @@
/***/
},
- /***/ 33: /***/ function (
+ /***/ 7196: /***/ function (
__unused_webpack_module,
exports,
__webpack_require__
@@ -841,11 +841,11 @@
},
});
const _interop_require_default = __webpack_require__(1351);
- const _getimgprops = __webpack_require__(2391);
- const _warnonce = __webpack_require__(7536);
- const _imagecomponent = __webpack_require__(4036);
+ const _getimgprops = __webpack_require__(3787);
+ const _warnonce = __webpack_require__(6908);
+ const _imagecomponent = __webpack_require__(2155);
const _imageloader = /*#__PURE__*/ _interop_require_default._(
- __webpack_require__(7512)
+ __webpack_require__(2534)
);
const unstable_getImgProps = (imgProps) => {
(0, _warnonce.warnOnce)(
@@ -877,7 +877,7 @@
/***/
},
- /***/ 7512: /***/ function (__unused_webpack_module, exports) {
+ /***/ 2534: /***/ function (__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
@@ -912,7 +912,7 @@
/***/
},
- /***/ 528: /***/ function (
+ /***/ 5921: /***/ function (
__unused_webpack_module,
__webpack_exports__,
__webpack_require__
@@ -933,8 +933,8 @@
// EXTERNAL MODULE: ./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js
var jsx_runtime = __webpack_require__(1527);
- // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+main-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/image.js
- var next_image = __webpack_require__(1577);
+ // EXTERNAL MODULE: ./node_modules/.pnpm/file+..+diff-repo+packages+next+next-packed.tgz_react-dom@18.2.0_react@18.2.0/node_modules/next/image.js
+ var next_image = __webpack_require__(73);
var image_default = /*#__PURE__*/ __webpack_require__.n(next_image); // CONCATENATED MODULE: ./pages/nextjs.png
/* harmony default export */ var nextjs = {
src: "/_next/static/media/nextjs.cae0b805.png",
@@ -964,12 +964,12 @@
/***/
},
- /***/ 1577: /***/ function (
+ /***/ 73: /***/ function (
module,
__unused_webpack_exports,
__webpack_require__
) {
- module.exports = __webpack_require__(33);
+ module.exports = __webpack_require__(7196);
/***/
},
@@ -980,7 +980,7 @@
return __webpack_require__((__webpack_require__.s = moduleId));
};
/******/ __webpack_require__.O(0, [774, 888, 179], function () {
- return __webpack_exec__(1552);
+ return __webpack_exec__(4070);
});
/******/ var __webpack_exports__ = __webpack_require__.O();
/******/ _N_E = __webpack_exports__;
Diff for 199-HASH.js
Diff too large to display
Diff for main-HASH.js
Diff too large to display
I made new tests with more realistic data from Next.js apps (cookie parsing, url parsing, retrieve hash from URL, get hostname) and in single-time execution, it's faster than without "limit" parameter. Single executionCookie parsing
Hostname parsing
URL Hash parsing
URL parsing (to retrieve domain name)
but in multiple times executions.. Multiple executions (in loop)Cookie parsing
Hostname parsing
URL Hash parsing
URL Parsing
In multiple executions (in a for loop), it's worse in most cases... I don't know how to judge that, maybe using a "for" loop for benchmarking isn't appropriate Multiple times (in for-loop), string with indexCookie Parsing
Hostname parsing
URL Hash parsing
URL parsing
NOTE: Node.js 18.18.1 | Ubuntu 22.04.3 LTS EDIT: I don't know how exactly JIT works, but the codes with "limit" param is ~ 2x faster than without in the following case . |
This comment was marked as duplicate.
This comment was marked as duplicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks! 🎉
There must be a typo somewhere because the tests are failing https://github.com/vercel/next.js/actions/runs/6565033937/job/17834734816?pr=56746#step:28:633 Looks like this click handler fails next.js/test/e2e/app-dir/actions/app/header/ui.js Lines 19 to 25 in 758b9d2
|
Hi, sorry I made a mistake on the test "should support headers and cookies" It was const id = res.split(':', 2) but |
This PR adds the optional
limit
parameter on String.prototype.split uses.MDN
While the performance gain may not be significant for small texts, it can be huge for large ones.
I made a benchmark on the following repository : https://github.com/Yovach/benchmark-nodejs
On my machine, I get the following results:
node index.js
node index-optimized.js
The "benchmarks" numbers are :