<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">I have been looking at the code and think I have a starting point on the design. Remember, the goal here is to be able to create a cache that uses expiration but has no defined cache size limit. Reading through the code, if ‘-1’ is specified for the eviction maxEntries, then a ConcurrentHashMap is created and used as the data container and no eviction is performed. Otherwise a BoundedConcurrentHashMap is created and used as the data container and eviction is performed according to the specified strategy.</SPAN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">Eviction currently appears to happen in two different ways:</SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">1.</SPAN><SPAN style="COLOR: navy; FONT-SIZE: 7pt"><FONT face="Times New Roman"> </FONT></SPAN><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">If an entry is expired, then it can be evicted.</SPAN><o:p></o:p></P>
<P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">2.</SPAN><SPAN style="COLOR: navy; FONT-SIZE: 7pt"><FONT face="Times New Roman"> </FONT></SPAN><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">If the number of entries in a segment of the cache contains more entries than “allowed” by the configuration.</SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">Here are the modifications that I think need to be made. I have not made any code mods yet, so I don’t know for sure if this will work. Definitely looking for feedback.</SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<OL style="MARGIN-TOP: 0in" type=1>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level1 lfo1; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Modify configuration in some way so that the following can be specified:</SPAN><o:p></o:p></LI>
<OL style="MARGIN-TOP: 0in" type=a>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level2 lfo1; tab-stops: list 1.0in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">The percentage value of used JVM memory (i.e. 95) at which entries should be evicted to try and avoid an OOM error.</SPAN><o:p></o:p></LI>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level2 lfo1; tab-stops: list 1.0in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">The number of items that should be evicted when memory reaches this threshold</SPAN><o:p></o:p></LI></OL>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level1 lfo1; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Modify LRU and LIRS Eviction class so that the accessQueue member can be accessed by the new Eviction class so that two access queues don’t have to be maintained.</SPAN><o:p></o:p></LI>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level1 lfo1; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Create a new Eviction class, a subclass of LIRS, where the accessQueue is used from the Eviction strategy the user specifies and the for loop in the execute method is exited when the evicted set equals value from 1.b above.</SPAN><o:p></o:p></LI>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level1 lfo1; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Modify DataContainerFactory.construct() to call DefaultDataContainer.boundedDataContainer() regardless of eviction policy. This will always create a BoundedConcurrentHashMap</SPAN><o:p></o:p></LI>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level1 lfo1; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Create an instance of the new Eviction class in each segment.</SPAN><o:p></o:p></LI>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l2 level1 lfo1; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Modify BoundedConcurrentHashMap.Segment put and replace methods such that when new values are going to be put into the Segment, the memory usage is checked and the execute method is called on the new Eviction class.</SPAN><o:p></o:p></LI></OL>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">Questions:</SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<OL style="MARGIN-TOP: 0in" type=1>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l1 level1 lfo2; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">What are the implications of using a BoundedConcurrentHashMap instead of a ConcurrentHashMap when maxEntries is set to -1?</SPAN><o:p></o:p></LI></OL>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">Thoughts</SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<OL style="MARGIN-TOP: 0in" type=1>
<LI style="MARGIN: 0in 0in 0pt; COLOR: navy; mso-list: l0 level1 lfo3; tab-stops: list .5in" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">This will not guarantee that an OOM error does not occur. It will attempt to guard against an OOM caused by putting new values into the cache. This will probably be more effective when the cache is being used in client/server mode, and less effective when used in embedded mode as to other code running in the JVM.</SPAN><o:p></o:p></LI></OL>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt"> </SPAN><o:p></o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: Arial; COLOR: navy; FONT-SIZE: 10pt">-- Dave Marion</SPAN><o:p></o:p></P>
<BR> <BR>
<HR id=stopSpelling>
From: manik@jboss.org<BR>Date: Tue, 11 Jan 2011 11:46:40 +0000<BR>To: infinispan-dev@lists.jboss.org<BR>Subject: [infinispan-dev] Poor man's size-based eviction Re: ISPN-863<BR><BR>
<META name=Generator content="Microsoft SafeHTML">
<DIV>Hi Dave</DIV>
<DIV><BR></DIV>
<DIV>Just saw that you signed the contributor agreement.</DIV>
<DIV><BR></DIV>
<DIV>So yeah, what you may want to look into is the EvictionManager [1] which will periodically have its processEviction() [2] method called. This doesn't actually do any evictions here (named so for legacy reasons) since the current data container is self-sizing/evicting. However it is still periodically invoked to purge expired entries. </DIV>
<DIV><BR></DIV>
<DIV>You can piggyback on the same invocation to test upper and lower bounds of memory utilisation (if enabled), but the bit that I still think you need to figure out is deciding which entries to evict, and how many of them to evict.</DIV>
<DIV><BR></DIV>
<DIV>Cheers</DIV>
<DIV>Manik</DIV>
<DIV><BR></DIV>
<DIV>[1] <A href="https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java" target=_blank>https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java</A></DIV>
<DIV>[2] <A href="https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java#L84" target=_blank>https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java#L84</A></DIV><BR>
<DIV>
<DIV>On 10 Jan 2011, at 11:08, Manik Surtani wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE>
<DIV style="WORD-WRAP: break-word">Excellent, Dave.
<DIV><BR></DIV>
<DIV>You should probably come up with a design first - or maybe a prototype on your fork of the project on GitHub - and post it here for comment.</DIV>
<DIV><BR></DIV>
<DIV>Cheers</DIV>
<DIV>Manik</DIV>
<DIV><BR>
<DIV>
<DIV>On 8 Jan 2011, at 00:34, david marion wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE>
<DIV style="FONT-FAMILY: Tahoma; FONT-SIZE: 10pt" class=ecxhmmessage>
<DIV style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; MARGIN-BOTTOM: 0pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; PADDING-TOP: 0px"><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Manik,</SPAN></DIV>
<DIV style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; MARGIN-BOTTOM: 0pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; PADDING-TOP: 0px"><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt"> </SPAN></DIV>
<DIV style="PADDING-BOTTOM: 0px; TEXT-INDENT: 6pt; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; MARGIN-BOTTOM: 0pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; PADDING-TOP: 0px"><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">I am on the list. I will start getting my dev environment setup according to instructions on site.</SPAN></DIV>
<DIV style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; MARGIN-BOTTOM: 0pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; PADDING-TOP: 0px"><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt"> </SPAN></DIV>
<DIV style="PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; MARGIN-BOTTOM: 0pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; PADDING-TOP: 0px"><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt">Dave Marion</SPAN></DIV><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 10pt"> </SPAN><SPAN class=ecxApple-converted-space> </SPAN>_______________________________________________<BR>infinispan-dev mailing list<BR><A href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</A><BR><A href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target=_blank>https://lists.jboss.org/mailman/listinfo/infinispan-dev</A></DIV></BLOCKQUOTE></DIV><BR>
<DIV>
<DIV>
<DIV>--</DIV>
<DIV>Manik Surtani</DIV>
<DIV><A href="mailto:manik@jboss.org">manik@jboss.org</A></DIV>
<DIV><A href="http://twitter.com/maniksurtani" target=_blank>twitter.com/maniksurtani</A></DIV>
<DIV><BR></DIV>
<DIV>Lead, Infinispan</DIV>
<DIV><A href="http://www.infinispan.org/" target=_blank>http://www.infinispan.org</A></DIV>
<DIV><BR></DIV></DIV><BR class=ecxApple-interchange-newline></DIV><BR></DIV></DIV>_______________________________________________<BR>infinispan-dev mailing list<BR><A href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</A><BR>https://lists.jboss.org/mailman/listinfo/infinispan-dev</BLOCKQUOTE></DIV><BR>
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV>
<DIV>--</DIV>
<DIV>Manik Surtani</DIV>
<DIV><A href="mailto:manik@jboss.org">manik@jboss.org</A></DIV>
<DIV><A href="http://twitter.com/maniksurtani" target=_blank>twitter.com/maniksurtani</A></DIV>
<DIV><BR></DIV>
<DIV>Lead, Infinispan</DIV>
<DIV><A href="http://www.infinispan.org/" target=_blank>http://www.infinispan.org</A></DIV>
<DIV><BR></DIV></DIV></SPAN><BR class=ecxApple-interchange-newline></DIV><BR><BR>_______________________________________________ infinispan-dev mailing list infinispan-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/infinispan-dev                                            </body>
</html>