Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Optimization in serde_derive Macro #2831

Open
nurmohammed840 opened this issue Oct 3, 2024 · 2 comments
Open

Performance Optimization in serde_derive Macro #2831

nurmohammed840 opened this issue Oct 3, 2024 · 2 comments

Comments

@nurmohammed840
Copy link

Context

The quote2 crate, which is an alternative lightweight version of quote, offers some improvements over quote

Proposal

If requested, I would be happy to submit a pull request to implement these optimizations. My proposal involves refactoring existing code to leverage the improved design in quote2

Please let me know if this contribution would be valuable. I can provide more details or send a pull request directly for review.

@oli-obk
Copy link
Member

oli-obk commented Oct 3, 2024

We don't have the capacity for reviewing an entire crate for feasability.

If you want to make a case, I recommend:

  1. creating benchmarks, ideally by swapping out the quote usage in serde and showing concrete numbers
  2. Running crater-at-home to see if swapping it out will break any crates (this requires extending crater-at-home to allow injecting patched crates)
  3. Writing a paragraph or two explaining the differences between the crates

All of these are significant effort and may not pan out, so only do this if you think there is a strong argument for switching and want to convince us.

@nurmohammed840
Copy link
Author

nurmohammed840 commented Oct 4, 2024

So, At the moment I only refactor serialization part, And the result is very promising 👌

Here’s a link to the prototype implementation

System Info

  • CPU: Ryzen 7 5700 (3.8GHz - 4.6GHz)

Benchmark Result

Iteration File serde_derive serde_derive_next Improvement Faster
1 simple.rs 253.5µs 120µs 52.66% 2.11x
user.rs 339.9µs 210.9µs 37.96% 1.61x
10 simple.rs 536µs 331.8µs 38.06% 1.61x
user.rs 2.8184ms 1.6602ms 41.09% 1.70x
100 simple.rs 4.6072ms 2.8672ms 37.77% 1.61x
user.rs 27.6456ms 15.1838ms 45.08% 1.82x
10,000 simple.rs 447.8222ms 282.0575ms 37.03% 1.59x
user.rs 2.3379857s 1.3935152s 40.43% 1.68x

@oli-obk, let me know, If I should continue refactoring (deserialization part) rest of the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants