-
-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Summary
Relates to #1374 — CliXml serialization via System.Management.Automation.Serializer is the main performance bottleneck in SPE remoting. This adds a -OutputFormat Json option as a faster alternative.
Problem
ConvertTo-CliXml uses reflection to walk the entire object graph with deep type information. For large result sets (hundreds of Sitecore items), this dominates response time. The existing -Raw switch bypasses serialization but returns unstructured .ToString() output.
Solution
New -OutputFormat parameter (CliXml | Json | Raw) on the remoting pipeline:
- Server (
RemoteScriptCall.ashx.cs): ParsesoutputFormatquery param, adds JSON branch usingConvertTo-Json -Depth 3 -Compresswith{"output":[], "errors":[]}envelope, setsContent-Type: application/json - Client (
Invoke-RemoteScript.ps1): New-OutputFormatparam onInvoke-RemoteScript, backwards-compat mapping from-Rawswitch, JSON parse with fallback to CliXml for old servers - Benchmark: Updated scenarios with 500 objects × 10 properties to stress-test serialization
Benchmark Results (500 objects × 10 properties)
| Format | P50 (ms) | Avg (ms) |
|---|---|---|
| CliXml | 596 | 827 |
| Json | 350 | 347 |
| Raw | 134 | 139 |
JSON is 2.4x faster than CliXml at P50 while preserving structured property data.
Backwards Compatibility
-Rawswitch continues to work unchanged- Old client → new server:
rawOutput=truemaps torawformat - New client → old server: Falls back to CliXml with a warning if JSON parse fails
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels