-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page-based cache recycling. #4559
Conversation
} | ||
context.queryResult().aggregations(new InternalAggregations(aggregations)); | ||
} finally { | ||
for (Aggregator aggregator : aggregators) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have some utils for Releasable
like IOUtils.close(Closeable)
that ensures that all of them are released
?
public static ByteSizeValue parseBytesSizeValueOrHeapRatio(String sValue) { | ||
if (sValue.endsWith("%")) { | ||
double percent = Double.parseDouble(sValue.substring(0, sValue.length() - 1)); | ||
return new ByteSizeValue((long) ((percent / 100) * JvmInfo.jvmInfo().getMem().getHeapMax().bytes()), ByteSizeUnit.BYTES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think putting the heap knowledge in here is the wrong place encapsulation wise? Maybe add to Settings
a getAsMemory
, that will do this?
New commit pushed:
|
|
||
private static int maximumSearchThreadPoolSize(ThreadPool threadPool) { | ||
final Executor executor = threadPool.executor(ThreadPool.Names.SEARCH); | ||
return ((ThreadPoolExecutor) executor).getMaximumPoolSize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the ThreadPool#info API here, so we don't have to cast to ThreadPoolExecutor
, and be able to get the max back through the info class.
@Inject | ||
public MockPageCacheRecycler(Settings settings, ThreadPool threadPool) { | ||
super(settings, threadPool); | ||
random = new Random(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the settings should get a random seed per index maybe I should pass on the node seed from the test cluster as well so you can get it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this here 602c63d
added some smallish comments - looks really good though. Lets get this in soon! |
Refactor cache recycling so that it only caches large arrays (pages) that can later be used to build more complex data-structures such as hash tables. - QueueRecycler now takes a limit like other non-trivial recyclers. - New PageCacheRecycler (inspired of CacheRecycler) has the ability to cache byte[], int[], long[], double[] or Object[] arrays using a fixed amount of memory (either globally or per-thread depending on the Recycler impl, eg. queue is global while thread_local is per-thread). - Paged arrays in o.e.common.util can now optionally take a PageCacheRecycler to reuse existing pages. - All aggregators' data-structures now use PageCacheRecycler: - for all arrays (counts, mins, maxes, ...) - LongHash can now take a PageCacheRecycler - there is a new BytesRefHash (inspired from Lucene but quite different, still; for instance it cheats on BytesRef comparisons by using Unsafe) that also takes a PageCacheRecycler Close elastic#4557
Thanks for the comments, @s1monw. I rebased and did the changes you suggested:
|
LGTM +1 to push |
Here is an attempt to refactor cache recycling so that it only caches large
arrays (pages) that can later be used to build more complex data-structures
such as hash tables.
byte[], int[], long[], double[] or Object[] arrays using a fixed amount of
memory (either globally or per-thread depending on the Recycler impl, eg.
queue is global while thread_local is per-thread).
to reuse existing pages.
still; for instance it cheats on BytesRef comparisons by using Unsafe)
that also takes a PageCacheRecycler
Close #4557