air_interpreter_interface/
run_args_memory_limits.rs

1/*
2 * Copyright 2024 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17const MB: u64 = 1024 * 1024;
18
19/// These are RAM consumption related limits to be enforced by AquaVM.
20/// There are two enforcing modes in AquaVM: soft and hard limit. The mode
21/// is signalled by AquaVM function Invoker via its run parameters.
22/// Soft limit mode sets a set of flags to return to the Invoker.
23/// Hard limit mode forces AquaVM to return Uncatchable error if the limits
24/// are exceeded.
25/// The math behind the limits value is based on:
26/// - 4GB value that provder guaratees for a Computation Unit that also has 1 CPU core.
27/// - the fact that peak RAM consumption linearly depends on: particle size,
28///     number of instructions and their types.
29/// The limits values are to be re-considered after more RAM efficient in-memory representation.
30pub static MAX_AIR_SIZE: u64 = 16 * MB;
31pub static MAX_PARTICLE_SIZE: u64 = 64 * MB;
32pub static MAX_CALL_RESULT_SIZE: u64 = 32 * MB;