fix: replace slow deep-equal with fastDeepEqual to resolve CPU bottleneck (#19771)

## Summary

- Replaced the `deep-equal` npm package with the existing
`fastDeepEqual` from `twenty-shared/utils` across 5 files in the server
and shared packages
- `deep-equal` was causing severe CPU overhead in the record update hot
path (`executeMany` → `formatTwentyOrmEventToDatabaseBatchEvent` →
`objectRecordChangedValues` → `deepEqual`, called **per field per
record**)
- `fastDeepEqual` is ~100x faster for plain JSON database records since
it skips unnecessary prototype chain inspection and edge-case handling
- Removed the now-unnecessary `LARGE_JSON_FIELDS` branching in
`objectRecordChangedValues` since all fields now use the fast
implementation
This commit is contained in:
Charles Bochet
2026-04-16 17:23:50 +02:00
committed by GitHub
parent d3df58046c
commit 4103efcb84
5 changed files with 16 additions and 36 deletions
@@ -1,7 +1,10 @@
import { msg } from '@lingui/core/macro';
import deepEqual from 'deep-equal';
import { FieldMetadataType } from 'twenty-shared/types';
import { getUniqueConstraintsFields, isDefined } from 'twenty-shared/utils';
import {
fastDeepEqual,
getUniqueConstraintsFields,
isDefined,
} from 'twenty-shared/utils';
import { RelationType } from 'src/engine/metadata-modules/field-metadata/interfaces/relation-type.interface';
@@ -326,7 +329,7 @@ const checkUniqueConstraintsAreSameOrThrow = (
uniqueConstraintFields: FlatFieldMetadata<FieldMetadataType>[],
) => {
if (
!deepEqual(
!fastDeepEqual(
relationConnectQueryConfig.uniqueConstraintFields,
uniqueConstraintFields,
)