Improve performances (#14869)

## Improvements

- Add logs to all gql operations and rest calls to help debug CPU issues
on the backend. These are temporary and should be removed
- Remove nested relations from workflowVersions load (used to add manual
triggers in the side bar). On some workspaces this call result in a
response of 4MB which is heavy on CPU
- Investigated Redis Usage ==> made a few improvements, we are should
still migrate to the new cache service once available
- investigated db calls in messaging / calendar fetch list + workflow
enqueue run cron jobs. Everything seems to be properly batched
This commit is contained in:
Charles Bochet
2025-10-03 17:22:03 +02:00
committed by GitHub
parent f973a1bcdb
commit c5cdf45f85
19 changed files with 308 additions and 199 deletions
@@ -25,7 +25,7 @@ import {
import { EntitySchemaFactory } from 'src/engine/twenty-orm/factories/entity-schema.factory';
import { PromiseMemoizer } from 'src/engine/twenty-orm/storage/promise-memoizer.storage';
import { type CacheKey } from 'src/engine/twenty-orm/storage/types/cache-key.type';
import { getFromCacheWithRecompute } from 'src/engine/utils/get-data-from-cache-with-recompute.util';
import { GetDataFromCacheWithRecomputeService } from 'src/engine/workspace-cache-storage/services/get-data-from-cache-with-recompute.service';
import { WorkspaceCacheStorageService } from 'src/engine/workspace-cache-storage/workspace-cache-storage.service';
import { WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
@@ -53,6 +53,10 @@ export class WorkspaceDatasourceFactory {
@InjectRepository(Workspace)
private readonly workspaceRepository: Repository<Workspace>,
private readonly workspaceEventEmitter: WorkspaceEventEmitter,
private readonly getFromCacheWithRecomputeService: GetDataFromCacheWithRecomputeService<
string,
ObjectsPermissionsByRoleIdDeprecated
>,
) {}
private async safelyDestroyDataSource(
@@ -236,10 +240,7 @@ export class WorkspaceDatasourceFactory {
}: {
workspaceId: string;
}): Promise<CacheResult<string, ObjectsPermissionsByRoleIdDeprecated>> {
return getFromCacheWithRecompute<
string,
ObjectsPermissionsByRoleIdDeprecated
>({
return this.getFromCacheWithRecomputeService.getFromCacheWithRecompute({
workspaceId,
getCacheData: () =>
this.workspacePermissionsCacheStorageService.getRolesPermissions(
@@ -255,7 +256,6 @@ export class WorkspaceDatasourceFactory {
}),
cachedEntityName: ROLES_PERMISSIONS,
exceptionCode: TwentyORMExceptionCode.ROLES_PERMISSIONS_VERSION_NOT_FOUND,
logger: this.logger,
});
}