You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by 孙 岚 <re...@hotmail.com> on 2016/10/26 06:27:22 UTC

[PROPOSAL]Refine the implementation of LRUCache

Hi all,

         I found the LRUCache that Groovy is using is not efficient enough because it is based on Collections.synchronizeMap, the LRUCache is used by some important classes(e.g. ProxyGenerator, Closure), so it can impact the performance somehow.

         I propose to replace the implementation with Caffeine(https://github.com/ben-manes/caffeine), which is a high performance caching library for Java 8 and licensed under APL2.

        Any thoughts?

Cheers,
Daniel.Sun



Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by Jochen Theodorou <bl...@gmx.org>.

On 26.10.2016 10:51, Guillaume Laforge wrote:
> Also it'd be nice to somehow be able to do a benchmark to see if it
> makes a big difference or not.

synchronized Map is about the slowest Java has to offer for a concurrent 
map. But why do we not use ConcurrentHashMap?

bye Jochen


Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by Guillaume Laforge <gl...@gmail.com>.
Also it'd be nice to somehow be able to do a benchmark to see if it makes a
big difference or not.

On Wed, Oct 26, 2016 at 10:48 AM, Guillaume Laforge <gl...@gmail.com>
wrote:

> We're careful not to add core dependencies usually, we only have ASM and
> Antlr basically, but that'd add a new one, just for the LRU cache.
> Caffeine would have to be jarjar'ed like the other core deps.
>
> And I'm wondering if it can be trimmed down, some more...
>
> It seems to be around 142KB:
> https://mvnrepository.com/artifact/com.github.ben-manes.
> caffeine/caffeine/2.3.3
>
> On Wed, Oct 26, 2016 at 10:28 AM, Cédric Champeau <
> cedric.champeau@gmail.com> wrote:
>
>> We still cannot do this on `master`, at least until 2.5 is out, because
>> it's Java 7. Also things we need to consider when using external libs
>> include how much the distribution would grow.
>>
>> 2016-10-26 8:27 GMT+02:00 孙 岚 <re...@hotmail.com>:
>>
>>> Hi all,
>>>
>>>          I found the LRUCache that Groovy is using is not efficient
>>> enough because it is based on Collections.synchronizeMap, the LRUCache is
>>> used by some important classes(e.g. ProxyGenerator, Closure), so it can
>>> impact the performance somehow.
>>>
>>>          I propose to replace the implementation with Caffeine(
>>> https://github.com/ben-manes/caffeine), which is a high performance
>>> caching library for Java 8 and licensed under APL2.
>>>
>>>         Any thoughts?
>>>
>>> Cheers,
>>> Daniel.Sun
>>>
>>>
>>>
>>
>
>
> --
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Developer Advocate @ Google Cloud Platform
>
> Blog: http://glaforge.appspot.com/
> Social: @glaforge <http://twitter.com/glaforge> / Google+
> <https://plus.google.com/u/0/114130972232398734985/posts>
>



-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by Guillaume Laforge <gl...@gmail.com>.
We're careful not to add core dependencies usually, we only have ASM and
Antlr basically, but that'd add a new one, just for the LRU cache.
Caffeine would have to be jarjar'ed like the other core deps.

And I'm wondering if it can be trimmed down, some more...

It seems to be around 142KB:
https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine/2.3.3

On Wed, Oct 26, 2016 at 10:28 AM, Cédric Champeau <cedric.champeau@gmail.com
> wrote:

> We still cannot do this on `master`, at least until 2.5 is out, because
> it's Java 7. Also things we need to consider when using external libs
> include how much the distribution would grow.
>
> 2016-10-26 8:27 GMT+02:00 孙 岚 <re...@hotmail.com>:
>
>> Hi all,
>>
>>          I found the LRUCache that Groovy is using is not efficient
>> enough because it is based on Collections.synchronizeMap, the LRUCache is
>> used by some important classes(e.g. ProxyGenerator, Closure), so it can
>> impact the performance somehow.
>>
>>          I propose to replace the implementation with Caffeine(
>> https://github.com/ben-manes/caffeine), which is a high performance
>> caching library for Java 8 and licensed under APL2.
>>
>>         Any thoughts?
>>
>> Cheers,
>> Daniel.Sun
>>
>>
>>
>


-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by Cédric Champeau <ce...@gmail.com>.
We still cannot do this on `master`, at least until 2.5 is out, because
it's Java 7. Also things we need to consider when using external libs
include how much the distribution would grow.

2016-10-26 8:27 GMT+02:00 孙 岚 <re...@hotmail.com>:

> Hi all,
>
>          I found the LRUCache that Groovy is using is not efficient enough
> because it is based on Collections.synchronizeMap, the LRUCache is used by
> some important classes(e.g. ProxyGenerator, Closure), so it can impact the
> performance somehow.
>
>          I propose to replace the implementation with Caffeine(
> https://github.com/ben-manes/caffeine), which is a high performance
> caching library for Java 8 and licensed under APL2.
>
>         Any thoughts?
>
> Cheers,
> Daniel.Sun
>
>
>

Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by "Daniel.Sun" <re...@hotmail.com>.
I created a JIRA issue to track the proposal:
https://issues.apache.org/jira/browse/GROOVY-7977

Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-Refine-the-implementation-of-LRUCache-tp5736323p5736346.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by "Daniel.Sun" <re...@hotmail.com>.
Hi Jochen,

> Could somebody double check the file size? 
943.78k...  but I find groovy is lack of a high performance LRU cache
currently, which is important for Groovy.

> Then of course there is the question why we do not use ConcurrentHashMap 
> instead.... because? 

Because ConcurrentHashMap does not supply any function to remove oldest
element automatically :)


Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-Refine-the-implementation-of-LRUCache-tp5736323p5736329.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: [PROPOSAL]Refine the implementation of LRUCache

Posted by Jochen Theodorou <bl...@gmx.org>.

On 26.10.2016 08:27, \u5b59 \u5c9a wrote:
> Hi all,
>
>          I found the LRUCache that Groovy is using is not efficient
> enough because it is based on Collections.synchronizeMap, the LRUCache
> is used by some important classes(e.g. ProxyGenerator, Closure), so it
> can impact the performance somehow.
>
>          I propose to replace the implementation with
> Caffeine(https://github.com/ben-manes/caffeine), which is a high
> performance caching library for Java 8 and licensed under APL2.
>
>         Any thoughts?

using 
https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine/2.3.3

APL2, check.
available in maven, check.
required dependencies, none I think, check.
filesize... 142k, should be ok... but, once downloaded it says 966k 
instead. Something not right here. 966k is too much for inklusion in 
Groovy imho. Could somebody double check the file size?

Otherwise... we should ensure the library can handle the newest jigsaw 
build. And if not but we would like to otherwise include it, we should 
contact the author and ask about the status in that area.

Then of course there is the question why we do not use ConcurrentHashMap 
instead.... because?

bye Jochen