Skip to content

Commit 5da29fd

Browse files
committed
remove zstd-napi (switch to native nodejs)
1 parent d37f2db commit 5da29fd

File tree

7 files changed

+12
-32
lines changed

7 files changed

+12
-32
lines changed

src/packages/backend/conat/persist.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ additional persist server:
1111
import "./index";
1212
import betterSqlite3 from "better-sqlite3";
1313
import { initContext } from "@cocalc/conat/persist/context";
14-
import { compress, decompress } from "zstd-napi";
14+
const { zstdCompressSync, zstdDecompressSync } = require("node:zlib");
1515
import { syncFiles } from "@cocalc/backend/data";
1616
import ensureContainingDirectoryExists from "@cocalc/backend/misc/ensure-containing-directory-exists";
1717
import { statSync, copyFileSync } from "node:fs";
1818

1919
initContext({
2020
betterSqlite3,
21-
compress,
22-
decompress,
21+
compress: zstdCompressSync,
22+
decompress: zstdDecompressSync,
2323
syncFiles,
2424
ensureContainingDirectoryExists,
2525
statSync,

src/packages/backend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@
6363
"reflect-sync": "^0.14.4",
6464
"rimraf": "^5.0.5",
6565
"shell-escape": "^0.2.0",
66-
"tmp-promise": "^3.0.3",
67-
"zstd-napi": "^0.0.12"
66+
"tmp-promise": "^3.0.3"
6867
},
6968
"repository": {
7069
"type": "git",

src/packages/conat/persist/storage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ less than 1 read/write per second for each. Thus memory is critical, and
2121
supporting at least 1000 writes/second is what we need.
2222
Fortunately, this implementation can do ~50,000+ writes per second and read
2323
over 500,000 per second. Yes, it blocks the main thread, but by using
24-
better-sqlite3 and zstd-napi, we get 10x speed increases over async code,
25-
so this is worth it.
24+
better-sqlite3, we get speed increases over async code, so this is worth it.
2625
2726
2827
COMPRESSION:
@@ -36,6 +35,7 @@ https://github.com/antoniomuso/lz4-napi/issues/678
3635
I also tried the rust sync snappy and it had a similar memory leak. Finally,
3736
I tried zstd-napi and it has a very fast sync implementation that does *not*
3837
need async pauses to not leak memory. So zstd-napi it is.
38+
I then switched to the zstd built into nodejs.
3939
And I like zstandard anyways.
4040
4141
TIERED STORAGE:

src/packages/lite/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
"exports": {
66
"./*": "./dist/*.js"
77
},
8-
"keywords": [
9-
"lite",
10-
"cocalc"
11-
],
8+
"keywords": ["lite", "cocalc"],
129
"scripts": {
1310
"preinstall": "npx only-allow pnpm",
1411
"clean": "rm -rf build dist node_modules sea/sea-prep.blob",
1512
"build": "pnpm exec tsc --build",
1613
"tsc": "pnpm exec tsc --watch --pretty --preserveWatchOutput",
1714
"test": "exit 0",
1815
"depcheck": "pnpx depcheck --ignores @types/debug,@types/jest,@types/node,@vercel/ncc",
19-
"build:bundle": "cd sea && ./build-bundle.sh",
16+
"build:static": "cd ../static && pnpm clean && pnpm install && pnpm build",
17+
"build:bundle": "pnpm build:static && cd sea && ./build-bundle.sh",
2018
"build:tarball": "pnpm build:bundle && cd build && tar Jcvf bundle.tar.xz bundle",
2119
"run:bundle": "node ./build/bundle/bundle/index.js",
2220
"sea": "cd sea && ./build-sea.sh",

src/packages/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
"axios@<1.12.0": "^1.12.0",
3535
"tmp@<0.2.4": "^0.2.4"
3636
},
37-
"onlyBuiltDependencies": [
38-
"better-sqlite3",
39-
"node-pty",
40-
"zstd-napi"
41-
]
37+
"onlyBuiltDependencies": ["better-sqlite3", "node-pty"]
4238
}
4339
}

src/packages/pnpm-lock.yaml

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

src/packages/pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ packages:
66
- "!**/cdn/dist/**"
77
onlyBuiltDependencies:
88
- better-sqlite3
9-
- zstd-napi

0 commit comments

Comments
 (0)