Hello Travis,
The default setup should be fine. The pool implementation is basically
a variant of jemalloc, so if you don't have prior knowledge about
jemalloc, it will not be easy to understand.
To explain very simply, the allocator creates a large buffer called
'chunk' and slice it into smaller ones to lend it to you. The size of a
chunk is determined by pageSize and maxOrder: chunkSize = pageSize <<
maxOrder, where the default pageSize is 4096 and maxOrder is 11 (i.e.
chunkSize is 16 MiB). pageShift is another derived variable which is
rather relevant only to the internals.
If a user asks for the buffer larger than chunkSize, it will allocate an
unpooled buffer. If a user asks for a small buffer like less than half
of pageSize (or maybe some other value I can't remember right now), it
will slice a 4096-byte page into smaller ones. Otherwise the buffer
will span over multiple pages.
So, I think the default configuration parameter should be fine in most
cases unless you allocate a buffer greater than 16 MiB. If you want the
allocator to create a smaller chunk, I'd recommend you to decrease
maxOrder. Also, allocating a buffer that spans over multiple pages
takes longer than allocating a sub-page buffer, so you might want to
increase the pageSize if you allocate buffers greater than 4096B very often.
HTH,
T
--
https://twitter.com/trustin
https://twitter.com/trustin_ko
https://twitter.com/netty_project