watt icon indicating copy to clipboard operation
watt copied to clipboard

100x slower performance on serde_derive (with recent serde and syn?)

Open acshi opened this issue 3 years ago • 0 comments

I just tried to use watt with serde_derive to improve performance in a project of mine, only to find it got much slower running the derive macros. Just compiling the shim serde_derive crate is of course much faster.

For this snippet:

use serde_derive::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct Information {
    pub a: Option<f32>,
    pub b: Option<f32>,
    pub c: Option<f32>,
    pub d: Option<f32>,
    pub e: Option<f32>,
    pub f: Option<f32>,
    pub g: Option<f32>,
}

fn main() {}

cargo +nightly rustc -- -Z time-passes gives me: time: 2.753; rss: 53MB -> 113MB ( +60MB) macro_expand_crate

When using the normal serde_derive I get: time: 0.027; rss: 53MB -> 75MB ( +21MB) macro_expand_crate

I am using a patched syn (rebased on master from jakobhellermann's): https://github.com/acshi/syn-watt/tree/watt-feature And my patched serde is here: https://github.com/acshi/serde/tree/watt The final shim crate I have is: https://github.com/acshi/serde_derive_wa

I am guessing this might have something to do with using the latest versions of syn and serde? For some reason I found I also had to patch serde_derive to output r#try! or I would get compilation errors because try is a reserved keyword.

acshi avatar Sep 20 '21 22:09 acshi