mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
Expose max memory size (#242)
This commit is contained in:
parent
69a42cf111
commit
5c2b9d442b
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -216,7 +216,7 @@ version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "avm-server"
|
||||
version = "0.17.0"
|
||||
version = "0.18.0"
|
||||
dependencies = [
|
||||
"air-interpreter-interface",
|
||||
"avm-data-store",
|
||||
@ -1205,9 +1205,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.121"
|
||||
version = "0.2.122"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
|
||||
checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@ -2134,9 +2134,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "1.12.0"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec1e6ec4d8950e5b1e894eac0d360742f3b1407a6078a604a731c4b3f49cefbc"
|
||||
checksum = "946fa04a8ac43ff78a1f4b811990afb9ddbdf5890b46d6dda0ba1998230138b7"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
"serde",
|
||||
@ -2145,9 +2145,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "1.5.1"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e"
|
||||
checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "avm-server"
|
||||
description = "Fluence AIR VM"
|
||||
version = "0.17.0"
|
||||
version = "0.18.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
license = "Apache-2.0"
|
||||
|
@ -17,6 +17,7 @@
|
||||
use super::avm_runner::AVMRunner;
|
||||
use super::AVMDataStore;
|
||||
use super::AVMError;
|
||||
use super::AVMMemoryStats;
|
||||
use super::AVMOutcome;
|
||||
use super::CallResults;
|
||||
use crate::config::AVMConfig;
|
||||
@ -99,8 +100,8 @@ impl<E> AVM<E> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Return size of interpreter heap in bytes.
|
||||
pub fn memory_size(&self) -> usize {
|
||||
self.runner.memory_size()
|
||||
/// Return memory stat of an interpreter heap.
|
||||
pub fn memory_stats(&self) -> AVMMemoryStats {
|
||||
self.runner.memory_stats()
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ pub use avm::AVM;
|
||||
pub use config::AVMConfig;
|
||||
pub use errors::AVMError;
|
||||
pub use interface::*;
|
||||
pub use runner::AVMMemoryStats;
|
||||
|
||||
pub mod avm_runner {
|
||||
pub use crate::interface::raw_outcome::RawAVMOutcome;
|
||||
|
@ -34,6 +34,15 @@ pub struct AVMRunner {
|
||||
wasm_filename: String,
|
||||
}
|
||||
|
||||
/// Return statistic of AVM server Wasm module heap footprint.
|
||||
pub struct AVMMemoryStats {
|
||||
/// Size of currently used linear memory in bytes.
|
||||
/// Please note that linear memory contains not only heap, but globals, shadow stack and so on.
|
||||
pub memory_size: usize,
|
||||
/// Possibly set max memory size for AVM server.
|
||||
pub max_memory_size: Option<usize>,
|
||||
}
|
||||
|
||||
impl AVMRunner {
|
||||
/// Create AVM with provided config.
|
||||
pub fn new(
|
||||
@ -87,12 +96,16 @@ impl AVMRunner {
|
||||
Ok(outcome)
|
||||
}
|
||||
|
||||
pub fn memory_size(&self) -> usize {
|
||||
pub fn memory_stats(&self) -> AVMMemoryStats {
|
||||
let stats = self.faas.module_memory_stats();
|
||||
|
||||
// only the interpreters must be loaded in FaaS
|
||||
debug_assert!(stats.len() == 1);
|
||||
stats[0].memory_size
|
||||
|
||||
AVMMemoryStats {
|
||||
memory_size: stats[0].memory_size,
|
||||
max_memory_size: stats[0].max_memory_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user