diff options
author | 2021-10-03 18:49:31 -0700 | |
---|---|---|
committer | 2021-10-03 18:49:31 -0700 | |
commit | 82bf89a946690c0297cba84bf50214eba705a863 (patch) | |
tree | 22215f2c7651fa07606221a57c35fbfe7b292d85 | |
parent | f4a4e793aa964ba2d0883a19205c32ec01eaf8f0 (diff) | |
download | bun-jarred/linux.tar.gz bun-jarred/linux.tar.zst bun-jarred/linux.zip |
1% perf improvements on Linuxjarred/linux
28 files changed, 170 insertions, 118 deletions
@@ -22,6 +22,7 @@ BUN_BUILD_TAG := bun-v$(PACKAGE_JSON_VERSION) CC := clang CXX := clang++ + bun: vendor build-obj bun-link-lld-release @@ -48,7 +49,11 @@ sign-macos-x64: sign-macos-aarch64: gon sign.macos-aarch64.json -release-macos: all-js build-obj jsc-bindings-mac bun-link-lld-release +release: all-js build-obj jsc-bindings-mac bun-link-lld-release + +release-linux: release strip-debug + + all-js: runtime_js fallback_decoder bun_error node-fallbacks @@ -299,11 +304,14 @@ BUN_LLD_FLAGS += -lstdc++fs \ -pthread \ -ldl \ -lc \ - -fuse-ld=lld \ -Wl,-z,now \ -Wl,--as-needed \ -Wl,-z,stack-size=12800000 \ - -Wl,-z,notext + -Wl,-z,notext \ + -ffunction-sections \ + -fdata-sections \ + -Wl,--gc-sections \ + -fuse-ld=lld endif @@ -312,12 +320,10 @@ mimalloc: bun-link-lld-debug: $(CXX) $(BUN_LLD_FLAGS) \ + -g \ $(DEBUG_BIN)/bun-debug.o \ -W \ -o $(DEBUG_BIN)/bun-debug \ - -march=native \ - -flto - bun-link-lld-release: $(CXX) $(BUN_LLD_FLAGS) \ @@ -326,8 +332,7 @@ bun-link-lld-release: -W \ -flto \ -ftls-model=initial-exec \ - -march=native \ - -O3 + -O3 \ rm $(BIN_DIR)/bun.o bun-link-lld-release-aarch64: @@ -280,7 +280,7 @@ pub fn build(b: *std.build.Builder) !void { var obj_step = b.step("obj", "Build Bun as a .o file"); var obj = b.addObject(bun_executable_name, exe.root_src.?.path); - obj.bundle_compiler_rt = true; + obj.setTarget(target); addPicoHTTP(obj, false); obj.addPackage(.{ .name = "clap", @@ -293,7 +293,15 @@ pub fn build(b: *std.build.Builder) !void { obj.linkLibC(); obj.linkLibCpp(); - obj.setTarget(target); + obj.bundle_compiler_rt = true; + + if (target.getOsTag() == .linux) { + // obj.want_lto = tar; + obj.link_emit_relocs = true; + obj.link_function_sections = true; + } + + } else { b.default_step.dependOn(&exe.step); } diff --git a/examples/hello-next/styles/Home.module.css b/examples/hello-next/styles/Home.module.css index 4a04160d0..539fb3eaf 100644 --- a/examples/hello-next/styles/Home.module.css +++ b/examples/hello-next/styles/Home.module.css @@ -1,4 +1,5 @@ @import url("./2.css"); + .container { min-height: 99vh; padding: 0 0.5rem; @@ -9,7 +10,6 @@ height: 100vh; } - .main { padding: 5rem 0; flex: 1; diff --git a/integration/snapshots/array-args-with-default-values.hmr.js b/integration/snapshots/array-args-with-default-values.hmr.js index aae356eed..f7b40203e 100644 --- a/integration/snapshots/array-args-with-default-values.hmr.js +++ b/integration/snapshots/array-args-with-default-values.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(3474597122, "array-args-with-default-values.js"), exports = hmr.exports; +var hmr = new HMR(186686614, "array-args-with-default-values.js"), exports = hmr.exports; (hmr._load = function() { var lines; const data = () => lines.map(([a = null, b = null, c = null, d = null]) => ({ diff --git a/integration/snapshots/bundled-entry-point.hmr.js b/integration/snapshots/bundled-entry-point.hmr.js index f3008327a..828236c19 100644 --- a/integration/snapshots/bundled-entry-point.hmr.js +++ b/integration/snapshots/bundled-entry-point.hmr.js @@ -7,10 +7,10 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; Bun.activate(false); -var hmr = new HMR(3012834585, "bundled-entry-point.js"), exports = hmr.exports; +var hmr = new HMR(2355916096, "bundled-entry-point.js"), exports = hmr.exports; (hmr._load = function() { var hello = null ?? "world"; function test() { diff --git a/integration/snapshots/bundled-entry-point.js b/integration/snapshots/bundled-entry-point.js index 04f92d63a..e7816245b 100644 --- a/integration/snapshots/bundled-entry-point.js +++ b/integration/snapshots/bundled-entry-point.js @@ -1,7 +1,7 @@ import { __require as require } from "http://localhost:8080/__runtime.js"; -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; var hello = null ?? "world"; export function test() { diff --git a/integration/snapshots/code-simplification-neql-define.hmr.js b/integration/snapshots/code-simplification-neql-define.hmr.js index 1e517c533..7a1c66be5 100644 --- a/integration/snapshots/code-simplification-neql-define.hmr.js +++ b/integration/snapshots/code-simplification-neql-define.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(726376257, "code-simplification-neql-define.js"), exports = hmr.exports; +var hmr = new HMR(1142302163, "code-simplification-neql-define.js"), exports = hmr.exports; (hmr._load = function() { var testFailed = false; const invariant = () => { diff --git a/integration/snapshots/export.hmr.js b/integration/snapshots/export.hmr.js index 6088ffd77..04821c18e 100644 --- a/integration/snapshots/export.hmr.js +++ b/integration/snapshots/export.hmr.js @@ -8,7 +8,7 @@ import what from "http://localhost:8080/_auth.js"; import * as where from "http://localhost:8080/_auth.js"; Bun.activate(false); -var hmr = new HMR(1879780259, "export.js"), exports = hmr.exports; +var hmr = new HMR(4033101122, "export.js"), exports = hmr.exports; (hmr._load = function() { var yoyoyo = "yoyoyo"; function hey() { diff --git a/integration/snapshots/forbid-in-is-correct.hmr.js b/integration/snapshots/forbid-in-is-correct.hmr.js index bd20b7b42..979a6be64 100644 --- a/integration/snapshots/forbid-in-is-correct.hmr.js +++ b/integration/snapshots/forbid-in-is-correct.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(346837007, "forbid-in-is-correct.js"), exports = hmr.exports; +var hmr = new HMR(2952402969, "forbid-in-is-correct.js"), exports = hmr.exports; (hmr._load = function() { var foo = () => { var D = (i, r) => () => (r || i((r = {exports: {} }).exports, r), r.exports); diff --git a/integration/snapshots/global-is-remapped-to-globalThis.hmr.js b/integration/snapshots/global-is-remapped-to-globalThis.hmr.js index a5a3723a6..aa9e9d8b5 100644 --- a/integration/snapshots/global-is-remapped-to-globalThis.hmr.js +++ b/integration/snapshots/global-is-remapped-to-globalThis.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(713665787, "global-is-remapped-to-globalThis.js"), exports = hmr.exports; +var hmr = new HMR(2277846108, "global-is-remapped-to-globalThis.js"), exports = hmr.exports; (hmr._load = function() { function test() { console.assert(globalThis === globalThis); diff --git a/integration/snapshots/lodash-regexp.hmr.js b/integration/snapshots/lodash-regexp.hmr.js index cd9ca40f7..768ad9b0d 100644 --- a/integration/snapshots/lodash-regexp.hmr.js +++ b/integration/snapshots/lodash-regexp.hmr.js @@ -7,11 +7,11 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js"; -var { shuffle} = require($60f52dc2); +import * as $cbd4e379 from "http://localhost:8080/node_modules/lodash/lodash.js"; +var { shuffle} = require($cbd4e379); Bun.activate(false); -var hmr = new HMR(2158065009, "lodash-regexp.js"), exports = hmr.exports; +var hmr = new HMR(1678450382, "lodash-regexp.js"), exports = hmr.exports; (hmr._load = function() { function test() { const foo = [1, 2, 3, 4, 6]; diff --git a/integration/snapshots/lodash-regexp.js b/integration/snapshots/lodash-regexp.js index 6e0e6190a..30dcab4e5 100644 --- a/integration/snapshots/lodash-regexp.js +++ b/integration/snapshots/lodash-regexp.js @@ -1,8 +1,8 @@ import { __require as require } from "http://localhost:8080/__runtime.js"; -import * as $60f52dc2 from "http://localhost:8080/node_modules/lodash/lodash.js"; -var { shuffle} = require($60f52dc2); +import * as $cbd4e379 from "http://localhost:8080/node_modules/lodash/lodash.js"; +var { shuffle} = require($cbd4e379); export function test() { const foo = [1, 2, 3, 4, 6]; diff --git a/integration/snapshots/multiple-imports.hmr.js b/integration/snapshots/multiple-imports.hmr.js index c4a089fd9..df44a70df 100644 --- a/integration/snapshots/multiple-imports.hmr.js +++ b/integration/snapshots/multiple-imports.hmr.js @@ -8,20 +8,20 @@ import { __HMRModule as HMR } from "http://localhost:8080/__runtime.js"; import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -var JSXClassic = require($bbcd215f); +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; +var JSXClassic = require($2ed51059); var jsx = require(JSX).jsxDEV, JSXFrag = require(JSXClassic).Fragment; -var { default: React} = require($bbcd215f); -var { default: React2} = require($bbcd215f); +var { default: React} = require($2ed51059); +var { default: React2} = require($2ed51059); Bun.activate(false); -var hmr = new HMR(2165509932, "multiple-imports.js"), exports = hmr.exports; +var hmr = new HMR(1572769260, "multiple-imports.js"), exports = hmr.exports; (hmr._load = function() { const bacon = React; const bacon2 = jsx(JSXFrag, { children: ["hello"] - }, undefined, true, {}, this); + }, undefined, true, undefined, this); function test() { console.assert(bacon === React); console.assert(bacon === React2); diff --git a/integration/snapshots/multiple-imports.js b/integration/snapshots/multiple-imports.js index dd2c11d93..f4c274567 100644 --- a/integration/snapshots/multiple-imports.js +++ b/integration/snapshots/multiple-imports.js @@ -2,17 +2,17 @@ import { __require as require } from "http://localhost:8080/__runtime.js"; import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -var JSXClassic = require($bbcd215f); +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; +var JSXClassic = require($2ed51059); var jsx = require(JSX).jsxDEV, JSXFrag = require(JSXClassic).Fragment; -var { default: React} = require($bbcd215f); -var { default: React2} = require($bbcd215f); +var { default: React} = require($2ed51059); +var { default: React2} = require($2ed51059); const bacon = React; const bacon2 = jsx(JSXFrag, { children: ["hello"] -}, undefined, true, {}, this); +}, undefined, true, undefined, this); export function test() { console.assert(bacon === React); console.assert(bacon === React2); diff --git a/integration/snapshots/package-json-exports/index.hmr.js b/integration/snapshots/package-json-exports/index.hmr.js index 508dd63ee..26c6c0592 100644 --- a/integration/snapshots/package-json-exports/index.hmr.js +++ b/integration/snapshots/package-json-exports/index.hmr.js @@ -7,15 +7,15 @@ __HMRModule as HMR import { __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; -import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; -var InexactRoot = require($4068f25b); -import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; -var InexactFile = require($d2a171d2); -import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; -var ExactFile = require($522c6d1f); +import * as $cc5b5b4d from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; +var InexactRoot = require($cc5b5b4d); +import * as $3a1d0f08 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; +var InexactFile = require($3a1d0f08); +import * as $6b803e42 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; +var ExactFile = require($6b803e42); Bun.activate(false); -var hmr = new HMR(1953708113, "package-json-exports/index.js"), exports = hmr.exports; +var hmr = new HMR(3722745821, "package-json-exports/index.js"), exports = hmr.exports; (hmr._load = function() { async function test() { console.assert(InexactRoot.target === "browser"); diff --git a/integration/snapshots/package-json-exports/index.js b/integration/snapshots/package-json-exports/index.js index 1b260c7ea..45e3dcaf5 100644 --- a/integration/snapshots/package-json-exports/index.js +++ b/integration/snapshots/package-json-exports/index.js @@ -1,12 +1,12 @@ import { __require as require } from "http://localhost:8080/__runtime.js"; -import * as $4068f25b from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; -var InexactRoot = require($4068f25b); -import * as $d2a171d2 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; -var InexactFile = require($d2a171d2); -import * as $522c6d1f from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; -var ExactFile = require($522c6d1f); +import * as $cc5b5b4d from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/index.js"; +var InexactRoot = require($cc5b5b4d); +import * as $3a1d0f08 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/dir/file.js"; +var InexactFile = require($3a1d0f08); +import * as $6b803e42 from "http://localhost:8080/package-json-exports/node_modules/inexact/browser/foo.js"; +var ExactFile = require($6b803e42); export async function test() { console.assert(InexactRoot.target === "browser"); diff --git a/integration/snapshots/spread_with_key.hmr.tsx b/integration/snapshots/spread_with_key.hmr.tsx index 0209cb3e2..457d61a79 100644 --- a/integration/snapshots/spread_with_key.hmr.tsx +++ b/integration/snapshots/spread_with_key.hmr.tsx @@ -8,14 +8,14 @@ import { __HMRModule as HMR } from "http://localhost:8080/__runtime.js"; import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -var JSXClassic = require($bbcd215f); +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; +var JSXClassic = require($2ed51059); var jsx = require(JSX).jsxDEV, jsxEl = require(JSXClassic).createElement; -var { default: React} = require($bbcd215f); +var { default: React} = require($2ed51059); Bun.activate(false); -var hmr = new HMR(2717584935, "spread_with_key.tsx"), exports = hmr.exports; +var hmr = new HMR(263168651, "spread_with_key.tsx"), exports = hmr.exports; (hmr._load = function() { function SpreadWithTheKey({ className @@ -31,7 +31,7 @@ var hmr = new HMR(2717584935, "spread_with_key.tsx"), exports = hmr.exports; function test() { console.assert(React.isValidElement(jsx(SpreadWithTheKey, { className: "foo" - }, undefined, true, {}, this))); + }, undefined, true, undefined, this))); return testDone(import.meta.url); } hmr.exportAll({ diff --git a/integration/snapshots/spread_with_key.tsx b/integration/snapshots/spread_with_key.tsx index f6cd64c31..b57a92a00 100644 --- a/integration/snapshots/spread_with_key.tsx +++ b/integration/snapshots/spread_with_key.tsx @@ -2,11 +2,11 @@ import { __require as require } from "http://localhost:8080/__runtime.js"; import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -var JSXClassic = require($bbcd215f); +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; +var JSXClassic = require($2ed51059); var jsx = require(JSX).jsxDEV, jsxEl = require(JSXClassic).createElement; -var { default: React} = require($bbcd215f); +var { default: React} = require($2ed51059); export function SpreadWithTheKey({ className }) { @@ -23,6 +23,6 @@ export function SpreadWithTheKey({ export function test() { console.assert(React.isValidElement(jsx(SpreadWithTheKey, { className: "foo" - }, undefined, true, {}, this))); + }, undefined, true, undefined, this))); return testDone(import.meta.url); } diff --git a/integration/snapshots/string-escapes.hmr.js b/integration/snapshots/string-escapes.hmr.js index 9231cb6cf..bebb37923 100644 --- a/integration/snapshots/string-escapes.hmr.js +++ b/integration/snapshots/string-escapes.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(2482749838, "string-escapes.js"), exports = hmr.exports; +var hmr = new HMR(2657253006, "string-escapes.js"), exports = hmr.exports; (hmr._load = function() { var tab = "\t"; var シ = "wow"; diff --git a/integration/snapshots/styledcomponents-output.hmr.js b/integration/snapshots/styledcomponents-output.hmr.js index f3743d4a3..c50113fd4 100644 --- a/integration/snapshots/styledcomponents-output.hmr.js +++ b/integration/snapshots/styledcomponents-output.hmr.js @@ -10,15 +10,15 @@ __HMRModule as HMR import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; var jsx = require(JSX).jsxDEV; -import * as $d4051a2e from "http://localhost:8080/node_modules/styled-components/dist/styled-components.browser.esm.js"; -var { default: styled} = require($d4051a2e); -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -var { default: React} = require($bbcd215f); -import * as $5b3cea55 from "http://localhost:8080/node_modules/react-dom/index.js"; -var { default: ReactDOM} = require($5b3cea55); +import * as $ab83b9cf from "http://localhost:8080/node_modules/styled-components/dist/styled-components.browser.esm.js"; +var { default: styled} = require($ab83b9cf); +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; +var { default: React} = require($2ed51059); +import * as $a259fa9b from "http://localhost:8080/node_modules/react-dom/index.js"; +var { default: ReactDOM} = require($a259fa9b); Bun.activate(false); -var hmr = new HMR(1290604342, "styledcomponents-output.js"), exports = hmr.exports; +var hmr = new HMR(2744898121, "styledcomponents-output.js"), exports = hmr.exports; (hmr._load = function() { const ErrorScreenRoot = styled.div` font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial, @@ -54,7 +54,7 @@ var hmr = new HMR(1290604342, "styledcomponents-output.js"), exports = hmr.expor ReactDOM.render(jsx(ErrorScreenRoot, { id: "error-el", children: ["The react child should have this text"] - }, undefined, true, {}, this), reactEl); + }, undefined, true, undefined, this), reactEl); const style = document.querySelector("style[data-styled]"); console.assert(style, "style tag should exist"); console.assert(style.textContent.split("").every((a) => a.codePointAt(0) < 128), "style tag should not contain invalid unicode codepoints"); diff --git a/integration/snapshots/styledcomponents-output.js b/integration/snapshots/styledcomponents-output.js index 54464dc9a..8a0e25280 100644 --- a/integration/snapshots/styledcomponents-output.js +++ b/integration/snapshots/styledcomponents-output.js @@ -4,12 +4,12 @@ __require as require import * as JSX from "http://localhost:8080/node_modules/react/jsx-dev-runtime.js"; var jsx = require(JSX).jsxDEV; -import * as $d4051a2e from "http://localhost:8080/node_modules/styled-components/dist/styled-components.browser.esm.js"; -var { default: styled} = require($d4051a2e); -import * as $bbcd215f from "http://localhost:8080/node_modules/react/index.js"; -var { default: React} = require($bbcd215f); -import * as $5b3cea55 from "http://localhost:8080/node_modules/react-dom/index.js"; -var { default: ReactDOM} = require($5b3cea55); +import * as $ab83b9cf from "http://localhost:8080/node_modules/styled-components/dist/styled-components.browser.esm.js"; +var { default: styled} = require($ab83b9cf); +import * as $2ed51059 from "http://localhost:8080/node_modules/react/index.js"; +var { default: React} = require($2ed51059); +import * as $a259fa9b from "http://localhost:8080/node_modules/react-dom/index.js"; +var { default: ReactDOM} = require($a259fa9b); const ErrorScreenRoot = styled.div` font-family: "Muli", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif; @@ -45,7 +45,7 @@ export function test() { ReactDOM.render(jsx(ErrorScreenRoot, { id: "error-el", children: ["The react child should have this text"] - }, undefined, true, {}, this), reactEl); + }, undefined, true, undefined, this), reactEl); const style = document.querySelector("style[data-styled]"); console.assert(style, "style tag should exist"); console.assert(style.textContent.split("").every((a) => a.codePointAt(0) < 128), "style tag should not contain invalid unicode codepoints"); diff --git a/integration/snapshots/ts-fallback-rewrite-works.hmr.js b/integration/snapshots/ts-fallback-rewrite-works.hmr.js index e728c5f14..6703d08a1 100644 --- a/integration/snapshots/ts-fallback-rewrite-works.hmr.js +++ b/integration/snapshots/ts-fallback-rewrite-works.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(421762902, "ts-fallback-rewrite-works.ts"), exports = hmr.exports; +var hmr = new HMR(631080924, "ts-fallback-rewrite-works.ts"), exports = hmr.exports; (hmr._load = function() { function test() { return testDone(import.meta.url); diff --git a/integration/snapshots/tsx-fallback-rewrite-works.hmr.js b/integration/snapshots/tsx-fallback-rewrite-works.hmr.js index 3f2f754e2..85b864563 100644 --- a/integration/snapshots/tsx-fallback-rewrite-works.hmr.js +++ b/integration/snapshots/tsx-fallback-rewrite-works.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(2117426367, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports; +var hmr = new HMR(2958250497, "tsx-fallback-rewrite-works.tsx"), exports = hmr.exports; (hmr._load = function() { function test() { return testDone(import.meta.url); diff --git a/integration/snapshots/type-only-imports.hmr.ts b/integration/snapshots/type-only-imports.hmr.ts index 84740d0d9..e36667ddf 100644 --- a/integration/snapshots/type-only-imports.hmr.ts +++ b/integration/snapshots/type-only-imports.hmr.ts @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(650094581, "type-only-imports.ts"), exports = hmr.exports; +var hmr = new HMR(2365801153, "type-only-imports.ts"), exports = hmr.exports; (hmr._load = function() { var baconator = true; var SilentSymbolCollisionsAreOkayInTypeScript = true; diff --git a/integration/snapshots/unicode-identifiers.hmr.js b/integration/snapshots/unicode-identifiers.hmr.js index 5d465d559..0452d6849 100644 --- a/integration/snapshots/unicode-identifiers.hmr.js +++ b/integration/snapshots/unicode-identifiers.hmr.js @@ -6,7 +6,7 @@ __HMRClient as Bun } from "http://localhost:8080/__runtime.js"; Bun.activate(false); -var hmr = new HMR(1398361736, "unicode-identifiers.js"), exports = hmr.exports; +var hmr = new HMR(2975064322, "unicode-identifiers.js"), exports = hmr.exports; (hmr._load = function() { var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; function test() { diff --git a/src/api/demo/styles/Home.module.css b/src/api/demo/styles/Home.module.css index 35454bb74..a2a622da0 100644 --- a/src/api/demo/styles/Home.module.css +++ b/src/api/demo/styles/Home.module.css @@ -119,3 +119,4 @@ flex-direction: column; } } + diff --git a/src/js_printer.zig b/src/js_printer.zig index 1419dbef2..956a00e83 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -3964,9 +3964,45 @@ const FileWriterInternal = struct { ctx: *FileWriterInternal, ) anyerror!void { defer buffer.reset(); - const result = buffer.toOwnedSliceLeaky(); + var result_ = buffer.toOwnedSliceLeaky(); + var result = result_; + + while (result.len > 0) { + switch (result.len) { + 0...4096 => { + const written = try ctx.file.write(result); + if (written == 0 or result.len - written == 0) return; + result = result[written..]; + }, + else => { + const first = result.ptr[0..result.len / 3]; + const second = result[first.len..][0..first.len]; + const remain = first.len+second.len; + const third: []const u8 = result[remain..]; + + var vecs = [_]std.os.iovec_const{ + .{ + .iov_base = first.ptr, + .iov_len = first.len, + }, + .{ + .iov_base = second.ptr, + .iov_len = second.len, + }, + .{ + .iov_base = third.ptr, + .iov_len = third.len, + }, + }; - _ = try ctx.file.writeAll(result); + const written = try std.os.writev(ctx.file.handle, vecs[0..@as(usize, if(third.len > 0) 3 else 2)]); + if (written == 0 or result.len - written == 0) return; + result = result[written..]; + }, + } + } + + } pub fn flush( @@ -4202,14 +4238,20 @@ pub fn printCommonJSThreaded( defer lock.unlock(); lock.lock(); result.off = @truncate(u32, try getPos(getter)); - if (comptime isMac) { + if (comptime isMac or isLinux) { // Don't bother preallocate the file if it's less than 1 KB. Preallocating is potentially two syscalls if (printer.writer.written > 1024) { - try C.preallocate_file( - getter.handle, - @intCast(std.os.off_t, 0), - @intCast(std.os.off_t, printer.writer.written), - ); + if (comptime isMac) { + try C.preallocate_file( + getter.handle, + @intCast(std.os.off_t, 0), + @intCast(std.os.off_t, printer.writer.written), + ); + } + + if (comptime isLinux) { + _ = std.os.system.fallocate(getter.handle, 0, @intCast(i64, result.off), printer.writer.written); + } } } try printer.writer.done(); diff --git a/src/watcher.zig b/src/watcher.zig index f088d31d2..81fb3ab0f 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -68,18 +68,17 @@ pub const INotify = struct { pub fn watchPath(pathname: [:0]const u8) !EventListIndex { std.debug.assert(loaded_inotify); const old_count = watch_count.fetchAdd(1, .Release); - defer if (old_count == 0) std.Thread.Futex.wake(&watch_count, 10); + defer if (old_count == 0) std.Thread.Futex.wake(&watch_count, 10); return std.os.inotify_add_watchZ(inotify_fd, pathname, watch_file_mask); } pub fn watchDir(pathname: [:0]const u8) !EventListIndex { std.debug.assert(loaded_inotify); const old_count = watch_count.fetchAdd(1, .Release); - defer if (old_count == 0) std.Thread.Futex.wake(&watch_count, 10); + defer if (old_count == 0) std.Thread.Futex.wake(&watch_count, 10); return std.os.inotify_add_watchZ(inotify_fd, pathname, watch_dir_mask); } - pub fn unwatch(wd: EventListIndex) void { std.debug.assert(loaded_inotify); _ = watch_count.fetchSub(1, .Release); @@ -97,43 +96,40 @@ pub const INotify = struct { std.debug.assert(loaded_inotify); restart: while (true) { + std.Thread.Futex.wait(&watch_count,0, null) catch unreachable; + const rc = std.os.system.read( + inotify_fd, + @ptrCast([*]u8, @alignCast(@alignOf([*]u8), &eventlist)), + @sizeOf(EventListBuffer), + ); + switch (std.os.errno(rc)) { + .SUCCESS => { + const len = @intCast(usize, rc); - std.Thread.Futex.wait(&watch_count,0, null) catch unreachable; - const rc = std.os.system.read( - inotify_fd, - @ptrCast([*]u8, @alignCast(@alignOf([*]u8), &eventlist)), - @sizeOf(EventListBuffer), - ); - - switch (std.os.errno(rc)) { - .SUCCESS => { - const len = @intCast(usize, rc); + if (len == 0) return &[_]*INotifyEvent{}; - if (len == 0) return &[_]*INotifyEvent{}; + var count: u32 = 0; + var i: u32 = 0; + while (i < len) : (i += @sizeOf(INotifyEvent)) { + const event = @ptrCast(*const INotifyEvent, @alignCast(@alignOf(*const INotifyEvent), eventlist[i..][0..@sizeOf(INotifyEvent)])); + if (event.name_len > 0) { + i += event.name_len; + } - var count: u32 = 0; - var i: u32 = 0; - while (i < len) : (i += @sizeOf(INotifyEvent)) { - const event = @ptrCast(*const INotifyEvent, @alignCast(@alignOf(*const INotifyEvent), eventlist[i..][0..@sizeOf(INotifyEvent)])); - if (event.name_len > 0) { - i += event.name_len; + eventlist_ptrs[count] = event; + count += 1; } - eventlist_ptrs[count] = event; - count += 1; - } - - return eventlist_ptrs[0..count]; - }, - .AGAIN => continue :restart, - .INVAL => return error.ShortRead, - .BADF => return error.INotifyFailedToStart, - - else => unreachable, - } + return eventlist_ptrs[0..count]; + }, + .AGAIN => continue :restart, + .INVAL => return error.ShortRead, + .BADF => return error.INotifyFailedToStart, -} + else => unreachable, + } + } unreachable; } |