Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-1300

Reduce number of locks and buckets generated by BucketBasedCacheStore

    XMLWordPrintable

Details

    Description

      The current implementation of FileCacheStore creates one bucket and lock for each hash key - which results in up to 4.2 billion files (2^32).

      It should limit the number of files to
      a) improve performance of purge
      b) reduce number of open file handles (system resources)
      c) reduce number of Java objects/heap (JVM resources)
      d) improve performance

      The implementation allows us to do so.

      Only 4 lines of code are necessary in BucketBasedCacheStore implementation:

         private int hashKeyMask = 0xfffffc00; // TODO should get a configuration entry
      
         @Override
         protected Integer getLockFromKey(Object key) {
            return Integer.valueOf(key.hashCode() & hashKeyMask);
         }
      

      This reduces the number of files to 2^22 = 4,194,304 files. Since each application and each cache store has different semantics the hasKeyMask value should be configurable - best would be to configure the number of bits.

      Side effect: If someone changes the FileCacheStore hasKeyMask, the whole cache store becomes unuseable. So I opened another enhancement ...

      Note: This implementation should be used in a different class (e.g. extend FileCacheStore) because it makes existing file cache stores unusable.

      Attachments

        Issue Links

          Activity

            People

              manik_jira Manik Surtani (Inactive)
              snazy0 Robert Stupp (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: