Skip to content

Commit 91dcb2f

Browse files
committed
Speed up CBOR decoding
1 parent 75e1b50 commit 91dcb2f

File tree

6 files changed

+10
-17
lines changed

6 files changed

+10
-17
lines changed

ui/bun.lockb

-332 Bytes
Binary file not shown.

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"cbor": "^10.0.3",
13+
"cborg": "^4.2.10",
1414
"classnames": "^2.5.1",
1515
"debounce": "^2.2.0",
1616
"react": "^19.1.0",

ui/src/components/Sim/hooks/worker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ISimulationAggregatedDataState, ISimulationIntermediateDataState } from '@/contexts/SimContext/types';
2-
import * as cbor from 'cbor';
2+
import * as cbor from 'cborg';
33
import type { ReadableStream } from 'stream/web';
44
import { IServerMessage } from '../types';
55
import { processMessage } from './utils';
@@ -49,11 +49,11 @@ const createCborTransformer = <T>(): TransformStream<Uint8Array, T> => {
4949
buffer = buffer ? Buffer.concat([buffer, chunk]) : Buffer.from(chunk);
5050
while (buffer != null) {
5151
try {
52-
const { value, unused } = cbor.decodeFirstSync(buffer, { extendedResults: true });
52+
const [value, unused] = cbor.decodeFirst(buffer);
5353
buffer = unused as Buffer;
5454
controller.enqueue(value);
5555
} catch (error: any) {
56-
if (error.message === 'Insufficient data') {
56+
if (error.message.startsWith('CBOR decode error:')) {
5757
break;
5858
} else {
5959
throw error;

ui/src/contexts/SimContext/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const defaultState: ISimContextState = {
2626
blocks: {},
2727
activeTab: Tab.Graph,
2828
batchSize: 5000,
29-
speedMultiplier: 1,
29+
speedMultiplier: 10,
3030
aggregatedData: defaultAggregatedData,
3131
maxTime: 0,
3232
tracePath: '',

ui/yarn.lock

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
22
# yarn lockfile v1
3-
# bun ./bun.lockb --hash: 5B922A279112C0FF-408c96441b5fc012-CD1616088D21BE3E-2e50fde5513a0644
3+
# bun ./bun.lockb --hash: 96870DF7D5AEDD4A-709a51daa2d05e8b-432F0DD73F35DFE5-c96677935b3e8261
44

55

66
"@ampproject/remapping@^2.2.0":
@@ -1104,12 +1104,10 @@ caniuse-lite@^1.0.30001688:
11041104
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001713.tgz"
11051105
integrity sha512-wCIWIg+A4Xr7NfhTuHdX+/FKh3+Op3LBbSp2N5Pfx6T/LhdQy3GTyoTg48BReaW/MyMNZAkTadsBtai3ldWK0Q==
11061106

1107-
cbor@^10.0.3:
1108-
version "10.0.3"
1109-
resolved "https://registry.npmjs.org/cbor/-/cbor-10.0.3.tgz"
1110-
integrity sha512-72Jnj81xMsqepqdcSdf2+fflz/UDsThOHy5hj2MW5F5xzHL8Oa0KQ6I6V9CwVUPxg5pf+W9xp6W2KilaRXWWtw==
1111-
dependencies:
1112-
nofilter "^3.0.2"
1107+
cborg@^4.2.10:
1108+
version "4.2.10"
1109+
resolved "https://registry.npmjs.org/cborg/-/cborg-4.2.10.tgz"
1110+
integrity sha512-ZVA0xrVn8uBfDJYgfKKZzB/93z/Uiz7YtRdBPsZi/gyHNyqFdHMLHURVEk9dejOHepaX0zhcMyNva2/vF972SA==
11131111

11141112
chalk@^4.0.0:
11151113
version "4.1.2"
@@ -2225,11 +2223,6 @@ node-stdlib-browser@^1.2.0:
22252223
util "^0.12.4"
22262224
vm-browserify "^1.0.1"
22272225

2228-
nofilter@^3.0.2:
2229-
version "3.1.0"
2230-
resolved "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz"
2231-
integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g==
2232-
22332226
object-assign@^4.1.1:
22342227
version "4.1.1"
22352228
resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"

0 commit comments

Comments
 (0)