TL;DR After upgrading to shopify_function 1.1.1, we’re seeing 11% higher instruction counts when processing JSON metafields due to the required JsonValue
→ serde_json::Value
conversion.
Details
After upgrading shopify_function from 0.8.1 to 1.1.1 we are seeing a higher instruction count, specifically relating to complex cart operations.
Our Cart Transform function processes cart items with JSON metadata stored in metafields. After upgrading to take advantage of the new Wasm API, we’re seeing:
Performance Metrics:
-
Simple carts (1 item):
Improved (~3% reduction in instruction count)
-
Complex carts (items with large JSON structures):
Regression (~11% increase in instruction count)
-
Mixed carts:
Improved overall
Example measurements:
- Complex item on old version: 0.5285M instructions
- Same item on v1.1.1: 0.5892M instructions
This appears to stem from the change from serde_json::Value
to shopify_function::scalars::JsonValue
in the new API. We have had to convert JSON structures using our own json_value_to_serde() pattern, and it is computationally expensive, especially for deeply nested objects with many fields.
-
Are there recommended patterns for working with large JSON structures without converting to serde_json?
-
Is Shopify planning optimizations for
JsonValue
or alternative approaches for complex JSON manipulation?
We’re concerned about scalability as our customers often have multiple complex items in their carts, and the instruction count scales linearly with complexity.
Any insights or recommended approaches would be greatly appreciated!
Thanks
Gabbie