# Clear cache for performance tests

**URL:** https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747
**Category:** Elasticsearch
**Created:** [November 2, 2011, 11:34am UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747 "2011-11-02T11:34:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)
#### Post date: [November 2, 2011, 11:34am UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/1 "2011-11-02T11:34:23Z")

</div>

Hi!

I'm trying to do performance tests on various queries we're using; I'm  
interested in the worst-case performance, that is, how long it takes  
to run the query for the first time without any caching etc. (I  
already know that cached queries are acceptably fast in all cases).  
What I can't figure out is how to achieve this; when I run a query for  
the second time, it is blazingly fast, even if it takes seconds to  
finish on the initial attempt. It appears that ES caches it somewhere,  
but I've tried clearing caches and flushing, to no avail.

I've tried doing the following things before re-running a query (yes,  
ES is running on port 4002, and the index is called my\_river):  
curl -XPOST '[http://localhost:4002/my\_river/\_cache/clear](http://localhost:4002/my_river/_cache/clear)'  
curl -XPOST '[http://localhost:4002/my\_river/\_flush](http://localhost:4002/my_river/_flush)'

What else do I need to do to eliminate this caching behavior?

Thanks!

Felix

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [November 2, 2011, 6:42pm UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/2 "2011-11-02T18:42:56Z")

</div>

There are many aspects to caching. it stats with the OS file system cache.  
The main other cache that is expensive is the one used for sorting /  
facets, which you can clear, but those can take a long time to load for the  
initial query. Are you using facets / sorting (not on score)? Another cache  
is the filters cache, are you using filters?

To clear those, across all indices, you can: curl -XPOST  
localhost/\_cache/clear. What you do, is clear the cache for the \_river  
index, thats not the actual index you have and query...

On Wed, Nov 2, 2011 at 1:34 PM, Felix Sappelt [f.sappelt@clueda.com](mailto:f.sappelt@clueda.com) wrote:

> Hi!
> 
> I'm trying to do performance tests on various queries we're using; I'm  
> interested in the worst-case performance, that is, how long it takes  
> to run the query for the first time without any caching etc. (I  
> already know that cached queries are acceptably fast in all cases).  
> What I can't figure out is how to achieve this; when I run a query for  
> the second time, it is blazingly fast, even if it takes seconds to  
> finish on the initial attempt. It appears that ES caches it somewhere,  
> but I've tried clearing caches and flushing, to no avail.
> 
> I've tried doing the following things before re-running a query (yes,  
> ES is running on port 4002, and the index is called my\_river):  
> curl -XPOST '[http://localhost:4002/my\_river/\_cache/clear](http://localhost:4002/my_river/_cache/clear)'  
> curl -XPOST '[http://localhost:4002/my\_river/\_flush](http://localhost:4002/my_river/_flush)'
> 
> What else do I need to do to eliminate this caching behavior?
> 
> Thanks!
> 
> Felix

---

<div class="post-metadata">

### Author: ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)
#### Post date: [November 3, 2011, 10:46am UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/3 "2011-11-03T10:46:27Z")

</div>

No sorting, filters and facets for now (although I plan to use them  
later on); I've tried the curl command that you mentioned, but I'm  
still having, say, 1000ms when I first run the query and 120ms when i  
run it again later. Most of the searches on our system will probably  
run just once, ever, and we provide our users with the possibility to  
combine queries, so that knowing the point at which queries become too  
complex to run in acceptable time is important. Currently I'm trying  
to make up new queries every time i test something, but this is takes  
around 10 minutes for every single test run and probably is not a good  
idea with regard to comparing the results... anything that can be done  
about this? Any way to prevent ES from saving the cache to disk (so  
that I can just restart it to get rid of the cache) or something like  
that?

Thanks!

Felix

On Nov 2, 7:42 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> There are many aspects to caching. it stats with the OS file system cache.  
> The main other cache that is expensive is the one used for sorting /  
> facets, which you can clear, but those can take a long time to load for the  
> initial query. Are you using facets / sorting (not on score)? Another cache  
> is the filters cache, are you using filters?
> 
> To clear those, across all indices, you can: curl -XPOST  
> localhost/\_cache/clear. What you do, is clear the cache for the \_river  
> index, thats not the actual index you have and query...
> 
> On Wed, Nov 2, 2011 at 1:34 PM, Felix Sappelt [f.sapp...@clueda.com](mailto:f.sapp...@clueda.com) wrote:
> 
> > Hi!
> 
> > I'm trying to do performance tests on various queries we're using; I'm  
> > interested in the worst-case performance, that is, how long it takes  
> > to run the query for the first time without any caching etc. (I  
> > already know that cached queries are acceptably fast in all cases).  
> > What I can't figure out is how to achieve this; when I run a query for  
> > the second time, it is blazingly fast, even if it takes seconds to  
> > finish on the initial attempt. It appears that ES caches it somewhere,  
> > but I've tried clearing caches and flushing, to no avail.
> 
> > I've tried doing the following things before re-running a query (yes,  
> > ES is running on port 4002, and the index is called my\_river):  
> > curl -XPOST '[http://localhost:4002/my\_river/\_cache/clear](http://localhost:4002/my_river/_cache/clear)'  
> > curl -XPOST '[http://localhost:4002/my\_river/\_flush](http://localhost:4002/my_river/_flush)'
> 
> > What else do I need to do to eliminate this caching behavior?
> 
> > Thanks!
> 
> > Felix

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [November 3, 2011, 5:33pm UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/4 "2011-11-03T17:33:34Z")

</div>

You can potentially disable the file system cache, I did it once, on  
ubuntu, but you will need to figure out how to do it. What is the query  
that you execute?

On Thu, Nov 3, 2011 at 12:46 PM, Felix Sappelt [f.sappelt@clueda.com](mailto:f.sappelt@clueda.com) wrote:

> No sorting, filters and facets for now (although I plan to use them  
> later on); I've tried the curl command that you mentioned, but I'm  
> still having, say, 1000ms when I first run the query and 120ms when i  
> run it again later. Most of the searches on our system will probably  
> run just once, ever, and we provide our users with the possibility to  
> combine queries, so that knowing the point at which queries become too  
> complex to run in acceptable time is important. Currently I'm trying  
> to make up new queries every time i test something, but this is takes  
> around 10 minutes for every single test run and probably is not a good  
> idea with regard to comparing the results... anything that can be done  
> about this? Any way to prevent ES from saving the cache to disk (so  
> that I can just restart it to get rid of the cache) or something like  
> that?
> 
> Thanks!
> 
> Felix
> 
> On Nov 2, 7:42 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > There are many aspects to caching. it stats with the OS file system  
> > cache.  
> > The main other cache that is expensive is the one used for sorting /  
> > facets, which you can clear, but those can take a long time to load for  
> > the  
> > initial query. Are you using facets / sorting (not on score)? Another  
> > cache  
> > is the filters cache, are you using filters?
> > 
> > To clear those, across all indices, you can: curl -XPOST  
> > localhost/\_cache/clear. What you do, is clear the cache for the \_river  
> > index, thats not the actual index you have and query...
> > 
> > On Wed, Nov 2, 2011 at 1:34 PM, Felix Sappelt [f.sapp...@clueda.com](mailto:f.sapp...@clueda.com)  
> > wrote:
> > 
> > > Hi!
> > 
> > > I'm trying to do performance tests on various queries we're using; I'm  
> > > interested in the worst-case performance, that is, how long it takes  
> > > to run the query for the first time without any caching etc. (I  
> > > already know that cached queries are acceptably fast in all cases).  
> > > What I can't figure out is how to achieve this; when I run a query for  
> > > the second time, it is blazingly fast, even if it takes seconds to  
> > > finish on the initial attempt. It appears that ES caches it somewhere,  
> > > but I've tried clearing caches and flushing, to no avail.
> > 
> > > I've tried doing the following things before re-running a query (yes,  
> > > ES is running on port 4002, and the index is called my\_river):  
> > > curl -XPOST '[http://localhost:4002/my\_river/\_cache/clear](http://localhost:4002/my_river/_cache/clear)'  
> > > curl -XPOST '[http://localhost:4002/my\_river/\_flush](http://localhost:4002/my_river/_flush)'
> > 
> > > What else do I need to do to eliminate this caching behavior?
> > 
> > > Thanks!
> > 
> > > Felix

---

<div class="post-metadata">

### Author: ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)
#### Post date: [November 7, 2011, 10:45am UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/5 "2011-11-07T10:45:30Z")

</div>

Thanks for the hint regarding the file system cache; turns out that  
was the issue. There's a tool named purge for MacOS X (included in the  
developer tools) which wipes all inactive ram, which is where the file  
system cache resides. That solves it for me.

Regards,  
Felix

On Nov 3, 6:33 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You can potentially disable the file system cache, I did it once, on  
> ubuntu, but you will need to figure out how to do it. What is the query  
> that you execute?
> 
> On Thu, Nov 3, 2011 at 12:46 PM, Felix Sappelt [f.sapp...@clueda.com](mailto:f.sapp...@clueda.com) wrote:
> 
> > No sorting, filters and facets for now (although I plan to use them  
> > later on); I've tried the curl command that you mentioned, but I'm  
> > still having, say, 1000ms when I first run the query and 120ms when i  
> > run it again later. Most of the searches on our system will probably  
> > run just once, ever, and we provide our users with the possibility to  
> > combine queries, so that knowing the point at which queries become too  
> > complex to run in acceptable time is important. Currently I'm trying  
> > to make up new queries every time i test something, but this is takes  
> > around 10 minutes for every single test run and probably is not a good  
> > idea with regard to comparing the results... anything that can be done  
> > about this? Any way to prevent ES from saving the cache to disk (so  
> > that I can just restart it to get rid of the cache) or something like  
> > that?
> 
> > Thanks!
> 
> > Felix
> 
> > On Nov 2, 7:42 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > There are many aspects to caching. it stats with the OS file system  
> > > cache.  
> > > The main other cache that is expensive is the one used for sorting /  
> > > facets, which you can clear, but those can take a long time to load for  
> > > the  
> > > initial query. Are you using facets / sorting (not on score)? Another  
> > > cache  
> > > is the filters cache, are you using filters?
> 
> > > To clear those, across all indices, you can: curl -XPOST  
> > > localhost/\_cache/clear. What you do, is clear the cache for the \_river  
> > > index, thats not the actual index you have and query...
> 
> > > On Wed, Nov 2, 2011 at 1:34 PM, Felix Sappelt [f.sapp...@clueda.com](mailto:f.sapp...@clueda.com)  
> > > wrote:
> > > 
> > > > Hi!
> 
> > > > I'm trying to do performance tests on various queries we're using; I'm  
> > > > interested in the worst-case performance, that is, how long it takes  
> > > > to run the query for the first time without any caching etc. (I  
> > > > already know that cached queries are acceptably fast in all cases).  
> > > > What I can't figure out is how to achieve this; when I run a query for  
> > > > the second time, it is blazingly fast, even if it takes seconds to  
> > > > finish on the initial attempt. It appears that ES caches it somewhere,  
> > > > but I've tried clearing caches and flushing, to no avail.
> 
> > > > I've tried doing the following things before re-running a query (yes,  
> > > > ES is running on port 4002, and the index is called my\_river):  
> > > > curl -XPOST '[http://localhost:4002/my\_river/\_cache/clear](http://localhost:4002/my_river/_cache/clear)'  
> > > > curl -XPOST '[http://localhost:4002/my\_river/\_flush](http://localhost:4002/my_river/_flush)'
> 
> > > > What else do I need to do to eliminate this caching behavior?
> 
> > > > Thanks!
> 
> > > > Felix

---

<div class="post-metadata">

### Author: ![mohammad](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mohammad](https://discuss.elastic.co/u/mohammad)
#### Post date: [February 20, 2014, 8:48am UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/6 "2014-02-20T08:48:32Z")

</div>

Hello everyone, i am getting the following errors when using elastic Search to perform query after a certain time on eclipse console:  
in the launch confiuguration :  
the memory allocation is as follows:  
-XX:MaxPermSize=256m  
-Xmx800m

..  
Error injecting constructor, java.lang.OutOfMemoryError: unable to create new native thread  
at org.elasticsearch.threadpool.ThreadPool.(Unknown Source)  
while locating org.elasticsearch.threadpool.ThreadPool

can anyone explain me how to solve this issue ?  
thanks in advance.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:48am UTC](https://discuss.elastic.co/t/clear-cache-for-performance-tests/5747/7 "2017-07-06T01:48:50Z")

</div>


