Skip to content

Commit 79174b4

Browse files
felipecrsmxcl
andauthored
Use deno 1.45: binaries ~25% smaller, ~10% faster (#978)
* dep on deno 1.40 * Bump deno to 1.41 * Relax deno from 1.41.0 to 1.41 * Use pkgx's denort * Restore deno.lock * Pin deno to 1.41.2, regenerate the lockfile * Deno 1.42 * Add benchmark * Fix compile task when using official's deno * Try to improve benchmark * Improve bench again * deno 1.42.1 * [email protected], @deno/[email protected] Regenerated the lock file as well. * Revert compile task after pkgxdev/pantry#5750 * Delete benchmark script * Remove other bench file * deno 1.42.3 * deno 1.42.4 * [email protected] * Deno 1.44 * deno 1.44.4 * Fix some flaky execve tests * Undo formatting changes * Update Deno from 1.44.4 to 1.46.3 * Downgrade Deno from 1.46 to 1.45 --------- Co-authored-by: Max Howell <[email protected]>
1 parent bdfc7cd commit 79174b4

File tree

10 files changed

+204
-579
lines changed

10 files changed

+204
-579
lines changed

.github/workflows/ci.shellcode.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: denoland/setup-deno@v1
2121
with:
22-
deno-version: 1.39
22+
deno-version: 1.45.5
2323
- uses: actions/checkout@v4
2424
- run: deno task compile
2525
- uses: actions/upload-artifact@v4

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- uses: actions/checkout@v4
3535
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
3636
with:
37-
deno-version: 1.39
37+
deno-version: 1.45.5
3838
- run: deno cache **/*.test.ts
3939
- run: deno task test --coverage=cov_profile --no-check
4040
- run: deno coverage cov_profile --lcov --exclude=tests/ --output=cov_profile.lcov
@@ -59,7 +59,7 @@ jobs:
5959
- uses: actions/checkout@v4
6060
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
6161
with:
62-
deno-version: 1.39
62+
deno-version: 1.45.5
6363
- run: deno lint
6464

6565
typecheck:
@@ -68,5 +68,5 @@ jobs:
6868
- uses: actions/checkout@v4
6969
- uses: denoland/setup-deno@v1
7070
with:
71-
deno-version: 1.39
71+
deno-version: 1.45.5
7272
- run: deno task typecheck

deno.jsonc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
},
66
"tasks": {
77
// runs this source checkout, args will be passed
8-
"run": "deno run --unstable -A ./entrypoint.ts",
8+
"run": "deno run --unstable-fs --unstable-ffi -A ./entrypoint.ts",
99

1010
// you can specify paths to specific tests if you need
1111
// follows is the ideal permissions lines, unfortunately deno considers making symlinks to require full read/write permissions for fuck knows why reasons
1212
//"test": "deno test --allow-read=$PWD,$TMPDIR,$HOME,/ --allow-env --allow-write=$TMPDIR --allow-ffi --unstable",
13-
"test": "deno test --allow-read --allow-env --allow-write --allow-ffi --unstable",
13+
"test": "deno test --unstable-ffi --allow-ffi --allow-read --allow-env --allow-write",
1414
// ^^ ffi & unstable needed for execve.ts
1515

1616
// installs to /usr/local/bin/pkgx
1717
"install": "deno task compile && ./pkgx +gnu.org/coreutils /usr/bin/sudo install -D ./pkgx /usr/local/bin/pkgx",
1818

1919
//--------------------------------------- ci/cd/admin
20-
"coverage" : "scripts/run-coverage.sh",
21-
"typecheck": "deno check --unstable ./entrypoint.ts",
22-
"compile": "deno compile --lock=deno.lock --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable --output $INIT_CWD/pkgx ./entrypoint.ts"
20+
"coverage": "scripts/run-coverage.sh",
21+
"typecheck": "deno check ./entrypoint.ts",
22+
"compile": "deno compile --lock=deno.lock --allow-read --allow-write --allow-net --allow-run --allow-env --allow-ffi --unstable-ffi --unstable-fs --output \"$INIT_CWD/pkgx\" ./entrypoint.ts"
2323
},
24-
"pkgx": "deno~1.39",
24+
"pkgx": "deno~1.45.5",
2525
"lint": {
2626
"exclude": ["src/**/*.test.ts"]
2727
},
@@ -33,7 +33,7 @@
3333
"pkgx": "https://deno.land/x/[email protected]/mod.ts",
3434
"pkgx/": "https://deno.land/x/[email protected]/src/",
3535
"outdent": "https://deno.land/x/[email protected]/mod.ts",
36-
"cliffy/": "https://deno.land/x/[email protected].3/",
37-
"deno/": "https://deno.land/std@0.196.0/" // cliffy is on 196 so we standardized on it
36+
"cliffy/": "https://deno.land/x/[email protected].4/",
37+
"deno/": "https://deno.land/std@0.221.0/" // cliffy is on 221 so we standardized on it
3838
}
3939
}

deno.lock

Lines changed: 165 additions & 550 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

entrypoint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { render as perror } from "./src/err-handler.ts"
77
import { setColorEnabled } from "deno/fmt/colors.ts"
88
import clicolor from "./src/utils/clicolor.ts"
99

10-
setColorEnabled(clicolor(Deno.stderr.rid))
10+
setColorEnabled(clicolor(Deno.stderr))
1111

1212
///////////////////////////////////////////////////////// backwards compatability
1313
const argstr = Deno.args.join(' ')
@@ -71,7 +71,7 @@ try {
7171

7272
/////////////////////////////////////////////////////////////////////////// utils
7373
function logger_prefix() {
74-
if (Deno.env.get("CI") || !Deno.isatty(Deno.stdin.rid)) {
74+
if (Deno.env.get("CI") || !Deno.stdin.isTerminal()) {
7575
return 'pkgx'
7676
}
7777
}

src/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export default async function({ flags, ...opts }: Args, logger_prefix?: string)
105105
console.log(shellcode())
106106
break
107107
case 'help':
108-
setColorEnabled(clicolor(Deno.stdout.rid))
108+
setColorEnabled(clicolor(Deno.stdout))
109109
console.log(help(flags.verbosity))
110110
break
111111
case 'env': {
@@ -135,7 +135,7 @@ async function ensure_pantry() {
135135

136136
function make_logger(verbosity: number, logger_prefix?: string): IInstallLogger {
137137
const logger = new Logger(logger_prefix)
138-
if (verbosity <= -2 || !Deno.isatty(Deno.stderr.rid)) {
138+
if (verbosity <= -2 || !Deno.stderr.isTerminal()) {
139139
return {
140140
replace: () => {},
141141
clear: () => {},

src/modes/integrate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { writeAll } from "deno/streams/write_all.ts"
2-
import { readAll } from "deno/streams/read_all.ts"
1+
import { writeAll } from "deno/io/write_all.ts"
2+
import { readAll } from "deno/io/read_all.ts"
33
import { readLines } from "deno/io/read_lines.ts"
44
import { Path, PkgxError, utils } from "pkgx"
55
import announce from "../utils/announce.ts"
@@ -80,7 +80,7 @@ export default async function(op: 'install' | 'uninstall', { dryrun }: { dryrun:
8080
}
8181
break
8282
case 'install':
83-
if (!_internals.isatty(Deno.stdout.rid)) {
83+
if (!_internals.isatty(Deno.stdout)) {
8484
// we're being sourced, output the hook
8585
_internals.stdout(shellcode())
8686
} else if (opd_at_least_once) {
@@ -125,7 +125,7 @@ function shells(): [Path, string][] {
125125
export const _internals = {
126126
home: Path.home,
127127
host,
128-
isatty: Deno.isatty,
128+
isatty: (x: {isTerminal: () => boolean}) => x.isTerminal(),
129129
stdout: console.log,
130130
stderr: console.error
131131
}

src/utils/clicolor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
export default function(dst = Deno.stdout.rid, env = Deno.env.toObject()) {
2+
export default function(dst = Deno.stdout, env = Deno.env.toObject()) {
33
// interprets https://no-color.org
44
// see: https://deno.land/api@v1.37.1?s=Deno.noColor
55
if (Deno.noColor) {
@@ -8,9 +8,9 @@ export default function(dst = Deno.stdout.rid, env = Deno.env.toObject()) {
88

99
//https://bixense.com/clicolors/
1010

11-
//NOTE we (mostly) only output colors to stderr hence the isatty check for that
11+
//NOTE we (mostly) only output colors to stderr hence the isTerminal() check for that
1212
//FIXME not true for --help tho
13-
if (env.CLICOLOR !== '0' && Deno.isatty(dst)) {
13+
if (env.CLICOLOR !== '0' && dst.isTerminal()) {
1414
return true
1515
}
1616
if ((env.CLICOLOR_FORCE ?? '0') != '0') {

src/utils/execve.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,31 @@ export default function({cmd: args, env}: {cmd: string[], env: Record<string, st
1515
const argv = new CStringArray(args)
1616
const envp = new CStringArray(Object.entries(env).map(([key, value]) => `${key}=${value}`))
1717

18-
const errno = _internals.execve(
19-
Deno.UnsafePointer.of(path),
20-
Deno.UnsafePointer.of(argv),
21-
Deno.UnsafePointer.of(envp))
18+
const errno = (() => {
19+
let tries = 10;
20+
while (true) {
21+
const errno = _internals.execve(
22+
Deno.UnsafePointer.of(path),
23+
Deno.UnsafePointer.of(argv),
24+
Deno.UnsafePointer.of(envp)
25+
);
26+
if (!tries--) return errno;
27+
// 11 = EAGAIN = Try again
28+
if (errno == 11) continue;
29+
return errno;
30+
}
31+
})();
2232

2333
switch (errno) {
24-
case 2: //ENOENT:
34+
case 2: //ENOENT:
35+
case 316: //FIXME ALERT! ALERT! BUG! SOMETHING IS WRONG WITH OUR USE OR ERRNO AND THIS SOMETIMES RESULTS, USUALLY ON MACOS :/
2536
// yes: strange behavior from execve here indeed
2637
if (parse_Path(args[0])?.exists()) {
2738
throw new Deno.errors.PermissionDenied()
2839
} else {
2940
throw new Deno.errors.NotFound()
3041
}
3142
case 13:
32-
case 316: //FIXME ALERT! ALERT! BUG! SOMETHING IS WRONG WITH OUR USE OR ERRNO AND THIS SOMETIMES RESULTS :/
3343
throw new Deno.errors.PermissionDenied()
3444
case 63: //ENAMETOOLONG:
3545
case 7: //E2BIG:

0 commit comments

Comments
 (0)