Skip to content

Reduce Deserializer CPU Usage by almost 3x - #82

Open
agnosticdev wants to merge 2 commits into
mainfrom
agnosticdev/DeserializerPerformance
Open

Reduce Deserializer CPU Usage by almost 3x#82
agnosticdev wants to merge 2 commits into
mainfrom
agnosticdev/DeserializerPerformance

Conversation

@agnosticdev

Copy link
Copy Markdown
Collaborator

Reduce the deserializer CPU usage by almost 3x. Added a benchmark for incremental investigation.

Top of tree:

434.41 M 89.1%	52.65 M	      specialized static Deserializer<>.deserialize<>(_:claim:_:)	
298.24 M 61.1%	13.00 M	       static Deserializer<>.deserialize<>(_:_:)	
262.99 M 53.9%	12.00 M	        specialized static Deserializer<>.deserialize<>(_:_:)	
22.24 M  4.6%	22.24 M	        partial apply for closure #1 in runtest()	
83.53 M  17.1%	72.53 M	       Frame.bytes.getter	
11.00 M  2.3%	11.00 M	        Frame.startOffset.getter	
15.83 M  3.2%	15.83 M	      specialized static Deserializer<>.deserialize<>(_:_:)	
8.00 M   1.6%	8.00 M 	     specialized static Deserializer<>.deserialize<>(_:claim:_:)	

With this change:

154.37 M 69.8%	8.55 M 	      static Deserializer<>.deserialize<>(_:claim:_:)	
145.81 M 66.0%	34.19 M	       specialized static Deserializer<>.deserialize<>(_:_:)	
107.62 M 48.7%	9.77 M 	        partial apply for closure #1 in runtest()	
97.86 M  44.3%	-      	         closure #1 in runtest()	
43.31 M  19.6%	43.31 M	          specialized Deserializer<>.uint8(_:)	
24.36 M  11.0%	24.36 M	          specialized Deserializer<>.uint32NetworkByteOrder(_:)	
16.18 M  7.3%	16.18 M	          specialized Deserializer<>.uint64NetworkByteOrder(_:)	
14.00 M  6.3%	14.00 M	          specialized Deserializer<>.uint16NetworkByteOrder(_:)	
4.00 M   1.8%	4.00 M 	        specialized Deserializer<>.finalResult.getter	
25.28 M  11.4%	15.32 M	      static Deserializer<>.deserialize<>(_:claim:_:)	

if #available(anyAppleOS 26, *) {
// Take command line arguments
var iterations = 1 // 5gb total (if 500000 sendSize)
var iterations = 10000 // 5gb total (if 500000 sendSize)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this accidentally changed before?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was... by me...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing =) Just confirming

@agnosticdev agnosticdev added the 🔨 semver/patch No public API change. label Aug 13, 2026
@tfpauly

tfpauly commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Benchmark build failing with

error: 'runtest()' is only available in iOS 26 or newer
    runtest()

@agnosticdev

Copy link
Copy Markdown
Collaborator Author

Benchmark build failing with

error: 'runtest()' is only available in iOS 26 or newer
    runtest()

Addressed in 6c958f8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants