netty/netty — pull request #75 by alepar (2011-11-23 11:41:16+00:00)
Title: ObjectDecoder performance optimization

Profiling shows that lot of time is spent in resolving classes.

Usually, number of different classes that you transmit over network is rather limited, so one can benefit a lot by caching resolved classes.

I can see there was some kind of cache introduced under NETTY-419.
Unfortunately, each CompactObjectInputStream has it's own cache instance, meaning that class cache lives only during parsing of current message. After we're done with current message, cache is gc'ed.

To fix performance we need to retain the cache and share it across all stream instances. This is exactly what was implemented here.

I've also made some simple performance testing. First line is esentially how netty performs currently. Next four - are different cache implementations, that I've provided.

Disabled:	14056ms
Soft Non-Shared:	4251ms
Weak Non-Shared:	4439ms
Soft Shared:	4346ms
Weak Shared:	4408ms

Test source code can be found here: https://gist.github.com/aeb693a53165249dc181

Would love to hear your thoughts.