Hi Jay,

On Thu, Nov 23, 2017 at 12:01 AM, Jay Kreps <j...@confluent.io> wrote:

> I was also thinking there could be mechanical improvements that would help
> efficiency such as sharing topic name or TopicPartition objects to reduce
> the footprint in a flyweight style.


Coincidentally, I was thinking of this earlier today and implemented a
quick sketch.

The topic name case is a win in both reduced memory usage and reduced
allocation since we can get the interned topic name string (if it exists)
from the ByteBuffer directly (with very little allocation). For the
TopicPartition case, it seems hard to avoid allocating the TopicPartition
instance itself (which is lightweight if the topic name string has already
been interned)  so the benefit would be reduced memory usage only.

Ismael

Reply via email to