Why do downloads (storedownloadd) from the Mac App Store consume so much CPU? I have noticed this often with large downloads such as Xcode updates and OS X updates and that sort of thing. 

Basically we see this for however much time it takes for the download to proceed: 



Today (currently) I am downloading Xcode 7.2.1. 

You can see storedownloadd appears to be pegging an entire core, and about 30% of this work is handled by the kernel.

What I'm puzzled about is what is this "work"? Why does it need to do this work? What amount of processing could it possibly be doing, because decrypting a stream at a few megabytes per second does not require this much resources. I could be downloading a large file like this using hundreds of connections over the internet and running integrity checks on it (with a protocol like bittorrent) and it wouldn't approach anywhere close to what's happening here with resource use.
Ran into the same issue today when updating XCode: storedownloadd pegs a CPU core for 20 minutes. 

I tried breaking into  storedownloadd with a debugger and saw some really long stack traces and a lot of time spent inside Security::CodeSigning.

I suspect that it is recursively verifying the digital signatures of a lot of tiny files one-by-one. I have no idea why it would do that instead of verifying the whole package as it is being downloaded. I also see a lot of string manipulation inside Security_CodeSigning::RequirementLexer::RequirementLexer. 

Whatever storedownloadd does, it is too damn slow!