Git Product home page Git Product logo

Comments (5)

zshipko avatar zshipko commented on June 12, 2024 2

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.

zshipko avatar zshipko commented on June 12, 2024

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.

mtb0x1 avatar mtb0x1 commented on June 12, 2024

Now I get a random signal : killed, monitoring the execution using 'top' the memory goes up to ~5gb. (my vm has 6gb max)
image

Steps :

  1. Clone extism/extism,extism/cli,extism/rust-pdk,extism/plugins into /tmp
  2. Change /tmp/plugins/Cargo.toml to use /tmp/rust-pdk instead of git version.
  3. 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)
  4. Update /tmp/cli with PR 'http-response-max' gh pr checkout 64
  5. Build plugins cd /tmp/plugins && cargo build
  6. 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

pub fn memory_new<'a, T: ToBytes<'a>>(&mut self, t: T) -> Result<MemoryHandle, Error> {

// +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.

nilslice avatar nilslice commented on June 12, 2024

@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.

mtb0x1 avatar mtb0x1 commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.