mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
feat(base): env vars for per-instance duckdb memory limit + threads
This commit is contained in:
@@ -6,6 +6,8 @@ export type QueryCacheConfig = {
|
|||||||
minRows: number;
|
minRows: number;
|
||||||
maxCollections: number;
|
maxCollections: number;
|
||||||
warmTopN: number;
|
warmTopN: number;
|
||||||
|
memoryLimit: string;
|
||||||
|
threads: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -17,6 +19,8 @@ export class QueryCacheConfigProvider {
|
|||||||
minRows: env.getBaseQueryCacheMinRows(),
|
minRows: env.getBaseQueryCacheMinRows(),
|
||||||
maxCollections: env.getBaseQueryCacheMaxCollections(),
|
maxCollections: env.getBaseQueryCacheMaxCollections(),
|
||||||
warmTopN: env.getBaseQueryCacheWarmTopN(),
|
warmTopN: env.getBaseQueryCacheWarmTopN(),
|
||||||
|
memoryLimit: env.getBaseQueryCacheMemoryLimit(),
|
||||||
|
threads: env.getBaseQueryCacheThreads(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,4 +343,23 @@ export class EnvironmentService {
|
|||||||
.toLowerCase() === 'true'
|
.toLowerCase() === 'true'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBaseQueryCacheMemoryLimit(): string {
|
||||||
|
// Per-DuckDB-instance memory ceiling. DuckDB accepts human-readable sizes:
|
||||||
|
// '32MB', '128MB', '1GB'. Default keeps a single instance from
|
||||||
|
// monopolising the heap if a runaway query needs to spill.
|
||||||
|
return this.configService.get<string>(
|
||||||
|
'BASE_QUERY_CACHE_MEMORY_LIMIT',
|
||||||
|
'64MB',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getBaseQueryCacheThreads(): number {
|
||||||
|
// Per-DuckDB-instance thread budget. Defaults to 2 so multiple concurrent
|
||||||
|
// instances don't fight for every core on a shared host.
|
||||||
|
return parseInt(
|
||||||
|
this.configService.get<string>('BASE_QUERY_CACHE_THREADS', '2'),
|
||||||
|
10,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user