vega / vl-convert

Utilities for converting Vega-Lite specs from the command line and Python
BSD 3-Clause "New" or "Revised" License
84 stars 9 forks source link

Allow to set heap limit for v8 #160

Open nbars opened 3 months ago

nbars commented 3 months ago

Hey,

Thanks for this great project! I am running into out-of-memory errors when plotting complex plots via Altair, and I guess that should be fixable by bumping the heap limit of the v8 engine. Would it be sufficient to add something like this

let options = WorkerOptions {
    extensions: vec![
        vl_convert_text_runtime::init_ops(),
        vl_convert_converter_runtime::init_ops(),
    ],
    module_loader: module_loader.clone(),
    ..Default::default(),
    BootstrapOptions {
        args: fillFromEvnVarOrUseDefaults(), // set, e.g., --max-old-space-size=131072,--max-heap-size=131072
         ..Default::default(),
    }
};

here

https://github.com/vega/vl-convert/blob/e941288af64025b60a13493b3d7ad70da980f698/vl-convert-rs/src/converter.rs#L570-L577

Or is there a better place to start?

Best, Nils

jonmmease commented 3 months ago

Hi @nbars, thanks for the kind words! Making the v8 heap configurable would be great. I haven't looked into this, so you probably know more about this than I do right now. Do you want to try making a PR?

As an aside, if your charts include aggregations then it may help to enable the VegaFusion data transformer. When this is enabled, data transformations (like filtering and aggregation) will be applied in Python before the data is sent to the vl-convert. For charts without aggregations, it will also remove unused columns which can also reduce memory usage.

But even if this helps, it would still be great to have the v8 configuration option exposed.

nbars commented 3 months ago

Hi @jonmmease, thanks for the swift response. Using VegaFusion works like a charm! I am happy to make a PR. Is it possible to assign me to the issue so that it is added to my "GitHub todo list"?

jonmmease commented 3 months ago

Glad that worked! Yes, I just assigned to you. Thanks!