Port codecs; add benchmarks.
Porting codecs to the new NodeAssembler interfaces was straightforward. The new codecs exist in the nodesolution "research" dirs for now, coexisting with the soon-to-be-legacy encoding package. This means we can see benchmarks of both the old and new designs within this commit. (We'll probably give up on this shortly -- when dealing with the traversal package too, it's gonna stop being reasonable -- but for now it's still possible and provides interesting information.) And how *is* that performance, you ask? Peachy. Ballpark answers for marshalling: - 1079ns/op for the new Node - 1435ns/op for the old Node - 1559ns/op for stdlib json marshal of a native map. 144% better than the operations of stdlib json is pretty acceptable. (Will more intense codegen beat that? Oh for sure. But this is *without any codegen*, so this is quite satisfactory.) Note that much of that time left is probably dominated by serialization-related allocations rather than the node traversal. I didn't dive into the pprofs to verify that yet, though. This picture of the overall act of marshalling is nice to have since it's a practical end-to-end user story. This test is also on a very small piece of data, and I expect the improvements will be further much bigger on larger or deeper-recursing structures. And lest this be skimmed over: the excellence of doing better than stdlib's json **while having pluginable codecs** cannot be understated. Pretty happy with this. How's unmarshal? Eh. About the same as before. Remember, we chose *not* to do a lot of amortizations in the new 'basicnode' implementations, because although we *could* (and it's quite clear how to do so), the increase in memory size we'd face since go doesn't allow unions was deemed too large of a constant factor multiplier. We *will* see these improvements in codegen, and we can also make variants of 'basicnode' that do these amortizations in the future. Doing a lot of thinking about how benchmarks and tests will be managed as they continue to grow in count and in variation of semantic targets. Might have to write some tooling around it. We'll see.
Showing
tests/marshalBenchmarks.go
0 → 100644
tests/unmarshalBenchmarks.go
0 → 100644
Please register or sign in to comment