Live data from Hacker News

I sped up serde_json strings by 20%

purplesyringa.moe

1–10 of 124 posts

Re: I sped up serde_json strings by 20%

#3
Serde json has 3gb of dependencies once you do a build for debug and a build for release. Use serde on a few active projects and you run out of disk space. I don’t know why json parsing needs 3gb of dependencies.

I’m all for code reuse but Serde for json is a bit of a dogs breakfast when it comes to dependencies. all you need is an exploit in on of those dependencies and half of the rust ecosystem is vulnerable.

Rust should have Jason built in.

Re: I sped up serde_json strings by 20%

#5
post #3

Serde json has 3gb of dependencies once you do a build for debug and a build for release. Use serde on a few active projects and you run out of disk space. I don’t know why json parsing needs 3gb of dependencies. I’m all for code reuse but Serde for json is a bit of a dogs breakfast when it comes to dependencies. all you need is an exploit in on of those dependencies and half of the rust ecosystem is vulnerable. Rust…

It has 5 dependencies, one of which is optional, and another is serde itself: https://github.com/serde-rs/json/blob/master/Cargo.toml

    indexmap = { version = "2.2.3", optional = true }
    itoa = "1.0"
    memchr = { version = "2", default-features = false }
    ryu = "1.0"
    serde = { version = "1.0.194", default-features = false }
I don’t think you’re measuring what you think you’re measuring when you say it has 3GB of dependencies. But I can’t say for sure because you don’t provide any evidence for it, you just declare it as true.

If I were to guess, I’d say you’re doing a lot of #[derive(Serialize, Deserialize)] and it’s generating tons of code (derive does code generation, after all) and you’re measuring the total size of your target directory after all of this. But this is just a guess… other commenters have shown that a simple build produces code on the order of tens of MB…

Re: I sped up serde_json strings by 20%

#6
post #3

Serde json has 3gb of dependencies once you do a build for debug and a build for release. Use serde on a few active projects and you run out of disk space. I don’t know why json parsing needs 3gb of dependencies. I’m all for code reuse but Serde for json is a bit of a dogs breakfast when it comes to dependencies. all you need is an exploit in on of those dependencies and half of the rust ecosystem is vulnerable. Rust…

Please show your work. I cannot reproduce "3gb of dependencies".

Here is my test:

Cargo.toml

   [package]
   name = "serde-test"
   version = "0.1.0"
   edition = "2021"
   
   [dependencies]
   serde = { version = "1.0.208", features = ["derive"] }
   serde_json = "1.0.127"
src/main.rs

    use serde::Deserialize;
    
    #[derive(Deserialize)]
    struct Foo {
        bar: String,
    }
    
    fn main() {
        let foo: Foo = serde_json::from_str("\"bar\": \"baz\"").unwrap();
    
        println!("{}", foo.bar);
    }
$ cargo build && cargo build --release && du -sh target

    ...

    78M target

Re: I sped up serde_json strings by 20%

#8
post #3

Serde json has 3gb of dependencies once you do a build for debug and a build for release. Use serde on a few active projects and you run out of disk space. I don’t know why json parsing needs 3gb of dependencies. I’m all for code reuse but Serde for json is a bit of a dogs breakfast when it comes to dependencies. all you need is an exploit in on of those dependencies and half of the rust ecosystem is vulnerable. Rust…

this 100%. serde is a bloated monster, its sad that its the popular JSON, because all it does is make Rust look bad in my opinion. here are some smaller options:

https://lib.rs/crates/humphrey_json

https://lib.rs/crates/rust_json

https://lib.rs/crates/sj

Re: I sped up serde_json strings by 20%

#10
post #3

Serde json has 3gb of dependencies once you do a build for debug and a build for release. Use serde on a few active projects and you run out of disk space. I don’t know why json parsing needs 3gb of dependencies. I’m all for code reuse but Serde for json is a bit of a dogs breakfast when it comes to dependencies. all you need is an exploit in on of those dependencies and half of the rust ecosystem is vulnerable. Rust…

I swear the target folder for literally any project of any scale is at least several GB in size.
Post reply on HN