5 Replies Latest reply on Sep 28, 2010 1:18 PM by Edouard Boily

    No cache pruning when evicting if expiration is active

    Edouard Boily Newbie

      Hi,

       

      The eviction manager processes evictions in the following manner:
      1. Causes the data container to purge expired entries
      2. Causes cache stores (if any) to purge expired entries
      3. Prunes the data container to a specific size, determined by maxElements
      EvictionManagerImpl.processEviction, does not prune the cache. It only purge expired entries in the data container and cache store.
      Moreover, with config
      <eviction strategy="LRU" wakeUpInterval="5000" maxEntries="4"/>
      <expiration lifespan="-1" maxIdle="-1"/> 
      pruning is properly performed as objects are put in the cache, while
      <eviction strategy="LRU" wakeUpInterval="5000" maxEntries="4"/>
      <expiration lifespan="2000" maxIdle="1000"/>
      no pruning is done and the number of objects can put in exceed maxEntries.

      The eviction documentation (http://community.jboss.org/wiki/EvictionExamples) says

      The eviction manager processes evictions in the following manner:

      1. Causes the data container to purge expired entries
      2. Causes cache stores (if any) to purge expired entries
      3. Prunes the data container to a specific size, determined by maxElements

       

      However, EvictionManagerImpl.processEviction, does not seem to prune the cache. It only purges expired entries in the data container and cache store (as per code review).

       

      With config

       

      <eviction strategy="LRU" wakeUpInterval="5000" maxEntries="4"/>

      <expiration lifespan="-1" maxIdle="-1"/> 

       

      pruning is properly performed as objects are put in the cache. However, with the configuration

       

      <eviction strategy="LRU" wakeUpInterval="5000" maxEntries="4"/>

      <expiration lifespan="200000" maxIdle="100000"/>

       

      no pruning is done either at cache insertion or by the EvictionManager thread and the number of objects I can put in the cache can exceed maxEntries and stays that way until they expire.

       

      This is observed on both 4.1.0-FINAL and 4.2.0-ALPHA2.

       

      Any idea for a quick patch?

       

      Thanks.

       

      - Edouard

        • 1. Re: No cache pruning when evicting if expiration is active
          Vladimir Blagojevic Master

          Edouard,

           

          I believe what you are experiencing is related to https://jira.jboss.org/browse/ISPN-670

           

          Cheers,

          Vladimir

          • 2. Re: No cache pruning when evicting if expiration is active
            Vladimir Blagojevic Master

            Also, all eviction is done piggyback now while purging is done from a dedicated thread. I hesitated updating docs as this is still somewhat work in progress. As 4.2 nears release docs will be up to date.

             

            Vladimir

            • 3. Re: No cache pruning when evicting if expiration is active
              Edouard Boily Newbie

              Vladimir,

               

              Yes, it is clearly related to https://jira.jboss.org/browse/ISPN-670.

               

              As I understand it, the eviction is to limit the memory usage of the cache, while expiration is more business related, like not keeping objects more than 24 hours or so. Eviction and Expiration have two different objectives.

               

              Considering this, one might want to have both cleaning methods active simultaneously. I may have this 24 hours business requirement but I also have memory limitations. So I strongly agree with your comment (here) stating that:

               

              [...] Starting with Infinispan 4.2 and beyond, 5.0 all container entries regardless of their type are considered as eviction candidates.

               

              However, it doesn't seem to be active in 4.2.0-ALPHA2. When I look at the code of DefaultDataContainer's constructor, I see

               

                    // translate eviction policy and strategy
                    switch (policy) {
                       case PIGGYBACK:
                       case DEFAULT:
                          evictionListener = new DefaultEvictionListener();
                          break;
                       default:
                          throw new IllegalArgumentException("No such eviction thread policy " + strategy);
                    }      // translate eviction policy and strategy
                    switch (policy) {
                       case PIGGYBACK:
                       case DEFAULT:
                          evictionListener = new DefaultEvictionListener();
                          break;
                       default:
                          throw new IllegalArgumentException("No such eviction thread policy " + strategy);
                    }
                    // translate eviction policy and strategy
                    switch (policy) {
                       case PIGGYBACK:
                       case DEFAULT:
                          evictionListener = new DefaultEvictionListener();
                          break;
                       default:
                          throw new IllegalArgumentException("No such eviction thread policy " + strategy);
                    }

               

              (btw, it should be policy, not strategy in the throw above)

               

              Which seems to indicate that PIGGYBACK and POLICY are the same for now.

               

              BTW, the same strategy as LRU also seem to be used for FIFO and UNORDERED.

               

                    Eviction eviction;

                    switch (strategy) {

                       case FIFO:

                       case UNORDERED:

                       case LRU:

                          eviction = Eviction.LRU;

                          break;

                       case LIRS:

                          eviction = Eviction.LIRS;

                          break;

                       default:

                          throw new IllegalArgumentException("No such eviction strategy " + strategy);

                    }

               

              So, concerning the PIGGYBACK behavior, is there a quick patch for this?

               

              Thanks for your support Vladimir, it is highly appreciated.

               

              - Edouard

              • 4. Re: No cache pruning when evicting if expiration is active
                Vladimir Blagojevic Master

                Hey,

                 

                The changes and fixes introduced by ISPN-670 are not released yet. They are in version control but not released. They will be in 4.2 Beta and beyond and 5.0 Beta and beyond. 4.2 Beta should be released soon, in matter of a week or two.

                 

                Yes, correct, FIFO and UNORDERED are now defaulting to LRU. This is intentional. All eviction is done piggyback style now. I will change the docs to reflect this just prior to release of 4.2. Thnx for the heads up at policy/strategy mixup.

                 

                I am not sure which patch are you referring to?

                 

                Regards,

                Vladimir

                • 5. Re: No cache pruning when evicting if expiration is active
                  Edouard Boily Newbie

                  OK, great!

                   

                  I'll wait for the beta release then,

                   

                  Thanks!

                   

                  - Edouard