public void testConfigureCache_Limits1()
 {
     // This test is just to force coverage over some lower bounds for
     // the table. We don't want the table to wind up with too small
     // of a size. This is highly dependent upon the table allocation
     // algorithm actually implemented in WindowCache.
     //
     var cfg = new WindowCacheConfig { PackedGitLimit = 6 * 4096 / 5, PackedGitWindowSize = 4096 };
     WindowCache.reconfigure(cfg);
 }
Ejemplo n.º 2
0
        static UnpackedObjectCache()
        {
            Dead = new WeakReference<Entry>(null);
            _maxByteCount = new WindowCacheConfig().DeltaBaseCacheLimit;

            Cache = new Slot[CacheSize];
            for (int i = 0; i < CacheSize; i++)
            {
                Cache[i] = new Slot();
            }
        }
Ejemplo n.º 3
0
		public void testCache_Defaults()
		{
			var cfg = new WindowCacheConfig();
			WindowCache.reconfigure(cfg);
			DoCacheTests();
			CheckLimits(cfg);

			WindowCache cache = WindowCache.Instance;
			Assert.AreEqual(6, cache.getOpenFiles());
			Assert.AreEqual(17346, cache.getOpenBytes());
		}
Ejemplo n.º 4
0
 public static void Reconfigure(WindowCacheConfig cfg)
 {
     lock (locker)
     {
         int dbLimit = cfg.DeltaBaseCacheLimit;
         if (_maxByteCount != dbLimit)
         {
             _maxByteCount = dbLimit;
             ReleaseMemory();
         }
     }
 }
Ejemplo n.º 5
0
        public static void reconfigure(int packedGitLimit, int packedGitWindowSize, bool packedGitMMAP, int deltaBaseCacheLimit)
        {
            var c = new WindowCacheConfig
            {
                PackedGitLimit      = packedGitLimit,
                PackedGitWindowSize = packedGitWindowSize,
                PackedGitMMAP       = packedGitMMAP,
                DeltaBaseCacheLimit = deltaBaseCacheLimit
            };

            reconfigure(c);
        }
Ejemplo n.º 6
0
 public void testConfigureCache_PackedGitWindowSize_512()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitWindowSize = 512 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize = 512");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Invalid window size", e.Message);
     }
 }
 public void testConfigureCache_PackedGitOpenFiles_0()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitOpenFiles = 0 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitOpenFiles = 0");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Open files must be >= 1", e.Message);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Modify the configuration of the window cache.
        /// <para />
        /// The new configuration is applied immediately. If the new limits are
        /// smaller than what what is currently cached, older entries will be purged
        /// as soon as possible to allow the cache to meet the new limit.
        /// </summary>
        /// <param name="cfg">
        /// The new window cache configuration.
        /// </param>
        public static void reconfigure(WindowCacheConfig cfg)
        {
            var         newCache = new WindowCache(cfg);
            WindowCache oldCache = _cache;

            if (oldCache != null)
            {
                oldCache.removeAll();
            }

            _cache = newCache;

            UnpackedObjectCache.Reconfigure(cfg);
        }
Ejemplo n.º 9
0
        public static void Reconfigure(WindowCacheConfig cfg)
        {
			if (cfg == null)
				throw new ArgumentNullException ("cfg");
			lock(locker)
			{
	            int dbLimit = cfg.DeltaBaseCacheLimit;
	            if (_maxByteCount != dbLimit)
	            {
	                _maxByteCount = dbLimit;
	                ReleaseMemory();
	            }
			}
        }
Ejemplo n.º 10
0
 public static void Reconfigure(WindowCacheConfig cfg)
 {
     if (cfg == null)
     {
         throw new ArgumentNullException("cfg");
     }
     lock (locker)
     {
         int dbLimit = cfg.DeltaBaseCacheLimit;
         if (_maxByteCount != dbLimit)
         {
             _maxByteCount = dbLimit;
             ReleaseMemory();
         }
     }
 }
Ejemplo n.º 11
0
        private static int TableSize(WindowCacheConfig cfg)
        {
            int  wsz   = cfg.PackedGitWindowSize;
            long limit = cfg.PackedGitLimit;

            if (wsz <= 0)
            {
                throw new ArgumentException("Invalid window size");
            }

            if (limit < wsz)
            {
                throw new ArgumentException("Window size must be < limit");
            }

            return((int)Math.Min(5 * (limit / wsz) / 2, 2000000000));
        }
Ejemplo n.º 12
0
        private WindowCache(WindowCacheConfig cfg)
            : base(TableSize(cfg), LockCount(cfg))
        {
            _maxFiles        = cfg.PackedGitOpenFiles;
            _maxBytes        = cfg.PackedGitLimit;
            _memoryMap       = cfg.PackedGitMMAP;
            _windowSizeShift = Bits(cfg.PackedGitWindowSize);
            _windowSize      = 1 << _windowSizeShift;

            _openFiles = new AtomicInteger();
            _openBytes = new AtomicLong();

            if (_maxFiles < 1)
            {
                throw new ArgumentException("Open files must be >= 1");
            }

            if (_maxBytes < _windowSize)
            {
                throw new ArgumentException("Window size must be < limit");
            }
        }
Ejemplo n.º 13
0
 public void testCache_TooFewFiles()
 {
     var cfg = new WindowCacheConfig { PackedGitOpenFiles = 2 };
     WindowCache.reconfigure(cfg);
     DoCacheTests();
     CheckLimits(cfg);
 }
Ejemplo n.º 14
0
 public override void tearDown()
 {
     base.tearDown();
     var windowCacheConfig = new WindowCacheConfig();
     WindowCache.reconfigure(windowCacheConfig);
 }
Ejemplo n.º 15
0
 public override void setUp()
 {
     var windowCacheConfig = new WindowCacheConfig { PackedGitOpenFiles = 1 };
     WindowCache.reconfigure(windowCacheConfig);
     base.setUp();
 }
Ejemplo n.º 16
0
 private static void WhackCache()
 {
     var config = new WindowCacheConfig { PackedGitOpenFiles = 1 };
     WindowCache.reconfigure(config);
 }
Ejemplo n.º 17
0
 public void testConfigureCache_PackedGitWindowSize_4097()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitWindowSize = 4097 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize = 4097");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Window size must be power of 2", e.Message);
     }
 }
Ejemplo n.º 18
0
 public void testConfigureCache_PackedGitLimit_0()
 {
     var cfg = new WindowCacheConfig { PackedGitLimit = 0 };
     AssertHelper.Throws<ArgumentException>(() => WindowCache.reconfigure(cfg));
 }
Ejemplo n.º 19
0
 public void testConfigureCache_PackedGitWindowSizeAbovePackedGitLimit()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitLimit = 1024, PackedGitWindowSize = 8192 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Window size must be < limit", e.Message);
     }
 }
Ejemplo n.º 20
0
 private static void CheckLimits(WindowCacheConfig cfg)
 {
     WindowCache cache = WindowCache.Instance;
     Assert.IsTrue(cache.getOpenFiles() <= cfg.PackedGitOpenFiles);
     Assert.IsTrue(cache.getOpenBytes() <= cfg.PackedGitLimit);
     Assert.IsTrue(0 < cache.getOpenFiles());
     Assert.IsTrue(0 < cache.getOpenBytes());
 }
Ejemplo n.º 21
0
 private static int LockCount(WindowCacheConfig cfg)
 {
     return(Math.Max(cfg.PackedGitOpenFiles, 32));
 }
        public virtual void setUp(){
            recursiveDelete(testName() + " (SetUp)", trash, false, true);

            mockSystemReader = new MockSystemReader();
            mockSystemReader.userGitConfig = new FileBasedConfig(new FileInfo(Path.Combine(trash.FullName, "usergitconfig")));
            SystemReader.setInstance(mockSystemReader);

            long now = mockSystemReader.getCurrentTime();
            int tz = mockSystemReader.getTimezone(now);
            author = new PersonIdent("J. Author", "*****@*****.**");
            author = new PersonIdent(author, now, tz);

            committer = new PersonIdent("J. Committer", "*****@*****.**");
            committer = new PersonIdent(committer, now, tz);

            WindowCacheConfig c = new WindowCacheConfig();
            c.PackedGitLimit = (128 * WindowCacheConfig.Kb);
            c.PackedGitWindowSize = (8 * WindowCacheConfig.Kb);
            c.PackedGitMMAP = (useMMAP);
            c.DeltaBaseCacheLimit = (8 * WindowCacheConfig.Kb);
            WindowCache.reconfigure(c);
        }
Ejemplo n.º 23
0
 public static void Reconfigure(WindowCacheConfig cfg)
 {
     lock(locker)
     {
         int dbLimit = cfg.DeltaBaseCacheLimit;
         if (_maxByteCount != dbLimit)
         {
             _maxByteCount = dbLimit;
             ReleaseMemory();
         }
     }
 }
Ejemplo n.º 24
0
 public void testCache_TooSmallLimit()
 {
     var cfg = new WindowCacheConfig { PackedGitWindowSize = 4096, PackedGitLimit = 4096 };
     WindowCache.reconfigure(cfg);
     DoCacheTests();
     CheckLimits(cfg);
 }
Ejemplo n.º 25
0
        public void test029_mapObject_using_memory_mapped_file()
        {
            WindowCacheConfig c = new WindowCacheConfig();
            c.PackedGitLimit = (128 * WindowCacheConfig.Kb);
            c.PackedGitWindowSize = (8 * WindowCacheConfig.Kb);
            c.PackedGitMMAP = (true);
            c.DeltaBaseCacheLimit = (8 * WindowCacheConfig.Kb);
            WindowCache.reconfigure(c);

            var repo = createWorkRepository();

            Assert.AreEqual((new byte[0].GetType()), repo.MapObject(ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"), null).GetType());
            Assert.AreEqual(typeof(global::GitSharp.Core.Commit), repo.MapObject(ObjectId.FromString("540a36d136cf413e4b064c2b0e0a4db60f77feab"), null).GetType());
            Assert.AreEqual(typeof(global::GitSharp.Core.Tree), repo.MapObject(ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035"), null).GetType());
            Assert.AreEqual(typeof(global::GitSharp.Core.Tag), repo.MapObject(ObjectId.FromString("17768080a2318cd89bba4c8b87834401e2095703"), null).GetType());
        }