From e049e2c4b60a797cd9d79a00a9df3edebd1ff418 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 18 Jan 2024 14:25:20 +0000 Subject: [PATCH] fix: revert "feat: faster json parsing" (#19838) Revert "feat: faster json parsing" --- plugin-server/package.json | 1 - plugin-server/pnpm-lock.yaml | 14 ------------- .../session-recording/utils.ts | 10 ++------- .../session-recording/utils.test.ts | 21 +------------------ 4 files changed, 3 insertions(+), 43 deletions(-) diff --git a/plugin-server/package.json b/plugin-server/package.json index c6e15f9bad08d..56a1c2a04c25f 100644 --- a/plugin-server/package.json +++ b/plugin-server/package.json @@ -80,7 +80,6 @@ "prom-client": "^14.2.0", "re2": "^1.20.3", "safe-stable-stringify": "^2.4.0", - "simdjson": "^0.9.2", "tail": "^2.2.6", "uuid": "^8.3.2", "v8-profiler-next": "^1.9.0", diff --git a/plugin-server/pnpm-lock.yaml b/plugin-server/pnpm-lock.yaml index f1764208f99f7..b6e4ff292cea8 100644 --- a/plugin-server/pnpm-lock.yaml +++ b/plugin-server/pnpm-lock.yaml @@ -133,9 +133,6 @@ dependencies: safe-stable-stringify: specifier: ^2.4.0 version: 2.4.3 - simdjson: - specifier: ^0.9.2 - version: 0.9.2 tail: specifier: ^2.2.6 version: 2.2.6 @@ -8083,10 +8080,6 @@ packages: semver: 7.5.0 dev: false - /node-addon-api@2.0.2: - resolution: {integrity: sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==} - dev: false - /node-fetch@2.6.9: resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==} engines: {node: 4.x || >=6.0.0} @@ -9252,13 +9245,6 @@ packages: engines: {node: '>=14'} dev: false - /simdjson@0.9.2: - resolution: {integrity: sha512-CW97acb8ty4EcxJGsCTrgxh1iiqLKbcuaIAte4DjPdoytK2ps1cRN1HpBJjIzqaL5cn1m/Dqc4AqA6NlKPPKKA==} - requiresBuild: true - dependencies: - node-addon-api: 2.0.2 - dev: false - /simple-concat@1.0.1: resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} dev: true diff --git a/plugin-server/src/main/ingestion-queues/session-recording/utils.ts b/plugin-server/src/main/ingestion-queues/session-recording/utils.ts index 025c393bf054b..34c2f59c29fee 100644 --- a/plugin-server/src/main/ingestion-queues/session-recording/utils.ts +++ b/plugin-server/src/main/ingestion-queues/session-recording/utils.ts @@ -2,7 +2,6 @@ import { captureException, captureMessage } from '@sentry/node' import { DateTime } from 'luxon' import { KafkaConsumer, Message, MessageHeader, PartitionMetadata, TopicPartition } from 'node-rdkafka' import path from 'path' -import { parse } from 'simdjson' import { KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS } from '../../../config/kafka-topics' import { PipelineEvent, RawEventMessage, RRWebEvent } from '../../../types' @@ -177,13 +176,8 @@ export const parseKafkaMessage = async ( let event: PipelineEvent try { - // we only read distinct_id, team_id, token, and data from the message payload - // data is read into event - // TODO: simd json can lazily parse json, so if we could avoid parsing "events" from the data - // we'd get the biggest perf win, since that is the potentially large "blob" of data - // see: https://github.com/luizperes/simdjson_nodejs?tab=readme-ov-file#parsing-a-json-string-lazily - messagePayload = parse(message.value.toString()) - event = parse(messagePayload.data) + messagePayload = JSON.parse(message.value.toString()) + event = JSON.parse(messagePayload.data) } catch (error) { return dropMessage('invalid_json', { error }) } diff --git a/plugin-server/tests/main/ingestion-queues/session-recording/utils.test.ts b/plugin-server/tests/main/ingestion-queues/session-recording/utils.test.ts index 28e5cf52c6307..44d6fa2c2fb5e 100644 --- a/plugin-server/tests/main/ingestion-queues/session-recording/utils.test.ts +++ b/plugin-server/tests/main/ingestion-queues/session-recording/utils.test.ts @@ -68,25 +68,7 @@ describe('session-recording utils', () => { ) expect(parsedMessage).toEqual({ distinct_id: String(numericId), - events: [ - { - data: { - payload: { - level: 'log', - payload: ['"Hedgehog: Will \'jump\' for 2916.6666666666665ms"'], - trace: [ - 'HedgehogActor.setAnimation (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105543:17)', - 'HedgehogActor.setRandomAnimation (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105550:14)', - 'HedgehogActor.update (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105572:16)', - 'loop (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105754:15)', - ], - }, - plugin: 'rrweb/console@1', - }, - timestamp: 1693422950693, - type: 6, - }, - ], + events: expect.any(Array), metadata: { offset: 1, partition: 1, @@ -97,7 +79,6 @@ describe('session-recording utils', () => { session_id: '018a47c2-2f4a-70a8-b480-5e51d8b8d070', team_id: 1, window_id: '018a47c2-2f4a-70a8-b480-5e52f5480448', - snapshot_source: undefined, }) })