⚡ Bolt: [performance improvement] optimize serde deserialization - #99
⚡ Bolt: [performance improvement] optimize serde deserialization#99cloudesize67-cmd wants to merge 1 commit into
Conversation
- Replaced `from_value::<T>(value.clone())` with `T::deserialize(value)` in `xdk-openapi/src/parser.rs`. - This avoids unnecessary deep clones of Serde's `Value` tree (which heavily allocates Strings). - Tests passed locally using `make check`. Co-authored-by: cloudesize67-cmd <237356855+cloudesize67-cmd@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What:
Replaced calls to
serde_yaml::from_value::<T>(value.clone())andserde_json::from_value::<T>(value.clone())withT::deserialize(value)across component parsing blocks inxdk-openapi/src/parser.rs. Added the necessaryuse serde::Deserialize;import.🎯 Why:
Parsing OpenAPI specs in two passes required cloning intermediate AST
Valuenodes into strongly typed models (like schemas, parameters, etc.). Cloning Serde values deeply allocates and copies heap strings, leading to excessive memory allocation and GC overhead for large OpenAPI schemas. By usingDeserializedirectly on the&Valuereference, Serde borrows the underlying string data safely, eliminating the massive cloning cost.📊 Impact:
Significantly reduces memory allocations and heap copying during the spec parsing phase, leading to faster startup times and lower peak memory consumption for the generator, particularly when processing large, deeply nested OpenAPI specifications.
🔬 Measurement:
make checkto verify formatting and linting rules are met.make test-generatorandcargo testto verify parsing still works accurately and no regressions are introduced.PR created automatically by Jules for task 9660156277547468027 started by @cloudesize67-cmd