OrderedScheduler and OrderedSafeExecutor
While profiling the allocations of a BookKeeper client (from current
master) writing entries, I've noticed that there are multiple allocations
per entry related to the OrderedScheduler.
I think OrderedScheduler was introduced in 4.6 and now OrderedSafeExecutor
is just an extension of OrderedScheduler as well.
The main problem is that since OrderedScheduler supports both immediate and
delayed execution, it uses a ScheduledThreadPoolExecutor per each bucket,
plus some decorating wrappers.
The ScheduledThreadPoolExecutor, needs a Priority queue and also always
return future objects.
>From my memory snapshot I have counted 12 objects allocated (per addEntry
operation) for a total of 472 bytes per each entry, all due the scheduled
I think the delayed execution is only used in unit tests. In critical paths
we're only using the immediate task submission.
I think it might be worth to refactor OrderedScheduler or
OrderedSafeExecutor to avoid that overhead.