Comments (5)
Thanks for testing it out! Your example does download the full ISO on my machine, but memory use seemed to peak at ~4GB, so there is definitely some room to improve memory use around large HTTP responses. I will investigate a little further today.
from extism.
I just opened a PR to update the CLI to add the --http-response-max
: extism/cli#64 after adding the new manifest field: #674
Other than that the only other limit I can think of is the 32-bit address space. Also, this setting only applies to calls to extism_http_request
, it doesn't have any affect on any WASI configuration.
from extism.
Now I get a random signal : killed
, monitoring the execution using 'top' the memory goes up to ~5gb. (my vm has 6gb max)
Steps :
- Clone
extism/extism
,extism/cli
,extism/rust-pdk
,extism/plugins
into/tmp
- Change
/tmp/plugins/Cargo.toml
to use/tmp/rust-pdk
instead of git version. - Change
/tmp/rust-pdk/Cargo.toml
to use/tmp/extism/manifest
and/tmp/extism/convert
instead of public version.
(the /tmp/extism is the last version from git) - Update
/tmp/cli
with PR 'http-response-max'gh pr checkout 64
- Build plugins
cd /tmp/plugins && cargo build
- Run
go run /tmp/cli/extism/main.go --allow-host "cdimage.debian.org" --http-response-max 1048576000 call /tmp/plugins/target/wasm32-unknown-unknown/debug/http.wasm http_get --input '{"url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.4.0-amd64-netinst.iso"}' > debian.iso
(1048576000
~= 1gb)
from what I gathered --http-response-max xyz
works fine, when I specify 524288000
(~=500Mb) as a value I get the usual request body too large
. (the iso size is ~700Mb)
I ran a quick check and I might be missing things, my guess the excessive memory usage happens in
extism/runtime/src/current_plugin.rs
Line 103 in fc22412
// +1gb allocated in `http_request`, then in
pub fn memory_new<'a, T: ToBytes<'a>>(&mut self, t: T) -> Result<MemoryHandle, Error> {
let data = t.to_bytes()?; //<= +700mb ?
let data = data.as_ref();
if data.is_empty() {
return Ok(MemoryHandle::null());
}
let handle = self.memory_alloc(data.len() as u64)?; //<= +700mb ?
let bytes = self.memory_bytes_mut(handle)?;
bytes.copy_from_slice(data.as_ref()); //<= +700mb ?
Ok(handle)
}
//=> ~4gb and I am probably missing out some other allocations.
I didn't have time to run Valgrind to confirm, in any case, this is not urgent but I think it's worth following up as there is room for improvement that would benefit the memory management and speed of extism runtime.
from extism.
@mtb0x1 we merged a solution for this last week, just want to follow up to make sure you saw & see if it works for you!
from extism.
I tested with the change in http plugin, memory usage did improve and peak usage did go down from +4Gb to 2.7Gb.
(This is not a real use-case on my side and I am not sure if you need to spend more time on it)
You can close it :)
from extism.
Related Issues (20)
- Add support for multiple arguments HOT 1
- Pass plug-in ID into `set_log_callback` callback function
- option for a WASM instr limit per call HOT 2
- look into calling `_initialize` on all linked plugins when initializing the guest runtime, not just the main module HOT 1
- Question about plugin return types HOT 3
- Direct disk/filesystem access HOT 9
- Cost of the function call throught host/guest boundary HOT 9
- Synchronizing the content of `wasm` folder HOT 3
- feat: add manifest field to limit the size of Extism vars HOT 1
- Extism gem fails to load on Ruby 3.3.0 on macOS HOT 6
- Async / Await / Generators / Coroutines in Plugins HOT 4
- How to unload a plugin? HOT 4
- Could we get access to the `id` on `CurrentPlugin`
- add a feature to control which wasm backend is enabled? HOT 4
- wasm files are very slow to load (C# PDK, Rust SDK) HOT 7
- getting a list of a plugin’s exported functions HOT 8
- ZMQ with Extism Plugins HOT 7
- allowlist WASI features/interfaces HOT 2
- Improve the libextism story on mac
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extism.