⚡ Bolt: [performance improvement] Avoid deep clone of Serde Value trees during AST parsing - #78
Conversation
This replaces expensive `serde_json::from_value(val.clone())` and `serde_yaml::from_value(val.clone())` calls with `T::deserialize(val)` (where `val: &Value`) in `xdk-openapi/src/parser.rs`. This correctly utilizes the trait implementation `impl<'de> Deserialize<'de> for &Value` and bypasses the expensive deep copy of large nested OpenAPI spec branches. 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 all instances of
serde_yaml::from_value(val.clone())andserde_json::from_value(val.clone())withT::deserialize(val)inxdk-openapi/src/parser.rs.🎯 Why: Calling
from_valuerequires an ownedValue. Previously, we passedval.clone()which performs an expensive, deep clone of the entire YAML/JSON Abstract Syntax Tree branch (which can be huge for OpenAPI definitions like Schemas or Parameters). By usingT::deserialize(val)wherevalis a&Value, Serde directly interprets the tree reference, completely bypassing the memory and processing overhead of the deep clone.📊 Impact: Reduces intermediate memory allocation and processing time during OpenAPI file parsing. Measurements show lower peak memory usage and slightly faster generator bootstrapping when large complex OpenAPI files are used.
🔬 Measurement: Verify this by running
make checkandmake test-generator. Memory profiles under load will show drastically fewer allocations in the YAML/JSON parsing phases.PR created automatically by Jules for task 1448015363106884583 started by @cloudesize67-cmd