Skip to content

Commit

Permalink
fix(gzip): Use Compression Streams API in place of pako (#674)
Browse files Browse the repository at this point in the history
This is expected to be faster and also reduces the bundle size.
  • Loading branch information
jbms authored Dec 2, 2024
1 parent 98595ee commit c581f20
Show file tree
Hide file tree
Showing 25 changed files with 40 additions and 191 deletions.
4 changes: 2 additions & 2 deletions build_tools/update-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ packageJson.imports = imports;

packageJson.exports = {
".": "./src/main_module.ts",
"./*.js": "./src/*.ts",
"./*": "./src/*",
"./unstable/*.js": "./src/*.ts",
"./unstable/*": "./src/*",
};

const tempPackageJsonPath = packageJsonPath + ".tmp";
Expand Down
5 changes: 2 additions & 3 deletions examples/parcel/parcel-project-built/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions examples/parcel/parcel-project-source/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions examples/vite/vite-project-built/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 2 additions & 13 deletions examples/vite/vite-project-source/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions examples/webpack/webpack-project-built/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 2 additions & 14 deletions examples/webpack/webpack-project-source/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@types/gl-matrix": "^2.4.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.12",
"@types/pako": "^2.0.3",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
Expand Down Expand Up @@ -83,8 +82,7 @@
"ikonate": "github:mikolajdobrucki/ikonate#a86b4107c6ec717e7877f880a930d1ccf0b59d89",
"lodash-es": "^4.17.21",
"nifti-reader-js": "^0.6.8",
"numcodecs": "^0.3.2",
"pako": "^2.1.0"
"numcodecs": "^0.3.2"
},
"overrides": {
"@puppeteer/browsers": ">=2"
Expand Down Expand Up @@ -265,12 +263,6 @@
"neuroglancer/datasource/nifti:disabled": "./src/datasource/nifti/backend.ts",
"default": "./src/datasource/nifti/backend.ts"
},
"#datasource/nifti/async_computation": {
"neuroglancer/datasource/nifti:enabled": "./src/datasource/nifti/async_computation.ts",
"neuroglancer/datasource:none_by_default": "./src/util/false.ts",
"neuroglancer/datasource/nifti:disabled": "./src/datasource/nifti/async_computation.ts",
"default": "./src/datasource/nifti/async_computation.ts"
},
"#datasource/nifti/register_default": {
"neuroglancer/datasource/nifti:enabled": "./src/datasource/nifti/register_default.ts",
"neuroglancer/datasource:none_by_default": "./src/util/false.ts",
Expand Down
23 changes: 0 additions & 23 deletions src/async_computation/decode_gzip.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/async_computation/decode_gzip_request.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/datasource/boss/async_computation.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import "#src/async_computation/decode_jpeg.js";
import "#src/async_computation/decode_gzip.js";
1 change: 0 additions & 1 deletion src/datasource/enabled_async_computation_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "#datasource/deepzoom/async_computation";
import "#datasource/dvid/async_computation";
import "#datasource/graphene/async_computation";
import "#datasource/n5/async_computation";
import "#datasource/nifti/async_computation";
import "#datasource/obj/async_computation";
import "#datasource/precomputed/async_computation";
import "#datasource/render/async_computation";
Expand Down
1 change: 0 additions & 1 deletion src/datasource/graphene/async_computation.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import "#src/async_computation/decode_jpeg.js";
import "#src/async_computation/decode_gzip.js";
1 change: 0 additions & 1 deletion src/datasource/n5/async_computation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import "#src/async_computation/decode_gzip.js";
import "#src/async_computation/decode_blosc.js";
import "#src/async_computation/decode_zstd.js";
9 changes: 2 additions & 7 deletions src/datasource/n5/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { decodeBlosc } from "#src/async_computation/decode_blosc_request.js";
import { decodeGzip } from "#src/async_computation/decode_gzip_request.js";
import { decodeZstd } from "#src/async_computation/decode_zstd_request.js";
import { requestAsyncComputation } from "#src/async_computation/request.js";
import { WithParameters } from "#src/chunk_manager/backend.js";
Expand All @@ -29,6 +28,7 @@ import type { VolumeChunk } from "#src/sliceview/volume/backend.js";
import { VolumeChunkSource } from "#src/sliceview/volume/backend.js";
import type { CancellationToken } from "#src/util/cancellation.js";
import { Endianness } from "#src/util/endian.js";
import { decodeGzip } from "#src/util/gzip.js";
import {
isNotFoundError,
responseArrayBuffer,
Expand Down Expand Up @@ -62,12 +62,7 @@ async function decodeChunk(
let buffer = new Uint8Array(response, offset);
switch (encoding) {
case VolumeChunkEncoding.GZIP:
buffer = await requestAsyncComputation(
decodeGzip,
cancellationToken,
[buffer.buffer],
buffer,
);
buffer = new Uint8Array(await decodeGzip(buffer));
break;
case VolumeChunkEncoding.BLOSC:
buffer = await requestAsyncComputation(
Expand Down
1 change: 0 additions & 1 deletion src/datasource/nifti/async_computation.ts

This file was deleted.

Loading

2 comments on commit c581f20

@shangmu
Copy link

@shangmu shangmu commented on c581f20 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbms This breaks zlib-compressed Zarr data source support. Will that be brought back next?

@jbms
Copy link
Collaborator Author

@jbms jbms commented on c581f20 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I will definitely fix that, sorry.

Please sign in to comment.