Skip to content

perf: skip double deserialization and enable release LTO#315

Open
KENILSHAHH wants to merge 1 commit intoPolymarket:mainfrom
KENILSHAHH:perf/deserialization-and-release-profile
Open

perf: skip double deserialization and enable release LTO#315
KENILSHAHH wants to merge 1 commit intoPolymarket:mainfrom
KENILSHAHH:perf/deserialization-and-release-profile

Conversation

@KENILSHAHH
Copy link
Copy Markdown

@KENILSHAHH KENILSHAHH commented Apr 2, 2026

Summary

  • Skip intermediate serde_json::Value parsing for HTTP responses when tracing is disabled, cutting deserialization work in half for normal production usage
  • Replace deep Value::clone() with flat Value::to_string() in the tracing deserialization path, reducing many small heap allocations to a single one
  • Add [profile.release] with lto = "thin" and codegen-units = 1 to match existing bench profile, enabling cross-crate inlining and more aggressive compiler
    optimizations for release builds

Note

Medium Risk
Changes the HTTP response deserialization path and cfg gating around serde_helpers, which could surface subtle differences in how optional/unknown fields are handled across feature sets. Build/profile changes (release LTO + single codegen unit) may also affect compile times and binary characteristics but not runtime behavior correctness.

Overview
Improves runtime and build-time performance for the SDK client.

When tracing is disabled, the main HTTP request path now deserializes responses directly into the target type instead of first parsing into serde_json::Value (avoiding a second deserialization pass). When tracing is enabled, the warning/error logging path in deserialize_with_warnings is updated to avoid deep Value cloning by storing a single raw_json string and re-parsing only when needed.

Adds a release profile in Cargo.toml to match bench (lto = "thin", codegen-units = 1) for more aggressive release optimizations.

Written by Cursor Bugbot for commit 4b9d385. This will update automatically on new commits. Configure here.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.54%. Comparing base (a5dc726) to head (4b9d385).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #315   +/-   ##
=======================================
  Coverage   85.54%   85.54%           
=======================================
  Files          32       32           
  Lines        5167     5168    +1     
=======================================
+ Hits         4420     4421    +1     
  Misses        747      747           
Flag Coverage Δ
rust 85.54% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KENILSHAHH KENILSHAHH force-pushed the perf/deserialization-and-release-profile branch from 240dfb2 to 4b9d385 Compare April 2, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant