mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) add GVISOR_LIMIT_MEMORY to cap memory available in sandbox
Summary: This allows limiting the memory available to documents in the sandbox when gvisor is used. If memory limit is exceeded, we offer to open doc in recovery mode. Recovery mode is tweaked to open docs with tables in "ondemand" mode, which will generally take less memory and allow for deleting rows. The limit is on the size of the virtual address space available to the sandbox (`RLIMIT_AS`), which in practice appears to function as one would want, and is the only practical option. There is a documented `RLIMIT_RSS` limit to `specifies the limit (in bytes) of the process's resident set (the number of virtual pages resident in RAM)` but this is no longer enforced by the kernel (neither the host nor gvisor). When the sandbox runs out of memory, there are many ways it can fail. This diff catches all the ones I saw, but there could be more. Test Plan: added tests Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3398
This commit is contained in:
@@ -25,11 +25,13 @@ export class OnDemandActions {
|
||||
private _tablesMeta: TableData = this._docData.getMetaTable('_grist_Tables');
|
||||
private _columnsMeta: TableData = this._docData.getMetaTable('_grist_Tables_column');
|
||||
|
||||
constructor(private _storage: OnDemandStorage, private _docData: DocData) {}
|
||||
constructor(private _storage: OnDemandStorage, private _docData: DocData,
|
||||
private _forceOnDemand: boolean = false) {}
|
||||
|
||||
// TODO: Ideally a faster data structure like an index by tableId would be used to decide whether
|
||||
// the table is onDemand.
|
||||
public isOnDemand(tableId: string): boolean {
|
||||
if (this._forceOnDemand) { return true; }
|
||||
const tableRef = this._tablesMeta.findRow('tableId', tableId);
|
||||
// OnDemand tables must have a record in the _grist_Tables metadata table.
|
||||
return tableRef ? Boolean(this._tablesMeta.getValue(tableRef, 'onDemand')) : false;
|
||||
|
||||
Reference in New Issue
Block a user