Esempio n. 1
0
        private static void WhackCache()
        {
            WindowCacheConfig config = new WindowCacheConfig();

            config.SetPackedGitOpenFiles(1);
            WindowCache.Reconfigure(config);
        }
Esempio n. 2
0
        public override void TearDown()
        {
            base.TearDown();
            WindowCacheConfig windowCacheConfig = new WindowCacheConfig();

            WindowCache.Reconfigure(windowCacheConfig);
        }
Esempio n. 3
0
		public override void SetUp()
		{
			WindowCacheConfig windowCacheConfig = new WindowCacheConfig();
			windowCacheConfig.SetPackedGitOpenFiles(1);
			WindowCache.Reconfigure(windowCacheConfig);
			base.SetUp();
		}
Esempio n. 4
0
        public override void SetUp()
        {
            WindowCacheConfig windowCacheConfig = new WindowCacheConfig();

            windowCacheConfig.SetPackedGitOpenFiles(1);
            WindowCache.Reconfigure(windowCacheConfig);
            base.SetUp();
        }
Esempio n. 5
0
		public override void SetUp()
		{
			base.SetUp();
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetStreamFileThreshold(streamThreshold);
			WindowCache.Reconfigure(cfg);
			repo = CreateBareRepository();
			wc = (WindowCursor)repo.NewObjectReader();
		}
Esempio n. 6
0
        public virtual void TestCache_TooFewFiles()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitOpenFiles(2);
            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
Esempio n. 7
0
        private WindowCache(WindowCacheConfig cfg)
        {
            tableSize = TableSize(cfg);
            int lockCount = LockCount(cfg);

            if (tableSize < 1)
            {
                throw new ArgumentException(JGitText.Get().tSizeMustBeGreaterOrEqual1);
            }
            if (lockCount < 1)
            {
                throw new ArgumentException(JGitText.Get().lockCountMustBeGreaterOrEqual1);
            }
            queue = new ReferenceQueue <ByteWindow>();
            clock = new AtomicLong(1);
            table = new AtomicReferenceArray <WindowCache.Entry>(tableSize);
            locks = new WindowCache.Lock[lockCount];
            for (int i = 0; i < locks.Length; i++)
            {
                locks[i] = new WindowCache.Lock();
            }
            evictLock = new ReentrantLock();
            int eb = (int)(tableSize * .1);

            if (64 < eb)
            {
                eb = 64;
            }
            else
            {
                if (eb < 4)
                {
                    eb = 4;
                }
            }
            if (tableSize < eb)
            {
                eb = tableSize;
            }
            evictBatch      = eb;
            maxFiles        = cfg.GetPackedGitOpenFiles();
            maxBytes        = cfg.GetPackedGitLimit();
            mmap            = cfg.IsPackedGitMMAP();
            windowSizeShift = Bits(cfg.GetPackedGitWindowSize());
            windowSize      = 1 << windowSizeShift;
            openFiles       = new AtomicInteger();
            openBytes       = new AtomicLong();
            if (maxFiles < 1)
            {
                throw new ArgumentException(JGitText.Get().openFilesMustBeAtLeast1);
            }
            if (maxBytes < windowSize)
            {
                throw new ArgumentException(JGitText.Get().windowSizeMustBeLesserThanLimit);
            }
        }
Esempio n. 8
0
        public override void SetUp()
        {
            base.SetUp();
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetStreamFileThreshold(streamThreshold);
            WindowCache.Reconfigure(cfg);
            repo = CreateBareRepository();
            wc   = (WindowCursor)repo.NewObjectReader();
        }
Esempio n. 9
0
        private void CheckLimits(WindowCacheConfig cfg)
        {
            WindowCache cache = WindowCache.GetInstance();

            NUnit.Framework.Assert.IsTrue(cache.GetOpenFiles() <= cfg.GetPackedGitOpenFiles()
                                          );
            NUnit.Framework.Assert.IsTrue(cache.GetOpenBytes() <= cfg.GetPackedGitLimit());
            NUnit.Framework.Assert.IsTrue(0 < cache.GetOpenFiles());
            NUnit.Framework.Assert.IsTrue(0 < cache.GetOpenBytes());
        }
Esempio n. 10
0
        public virtual void TestCache_TooSmallLimit()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitWindowSize(4096);
            cfg.SetPackedGitLimit(4096);
            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
Esempio n. 11
0
		static DeltaBaseCache()
		{
			DEAD = new SoftReference<DeltaBaseCache.Entry>(null);
			maxByteCount = new WindowCacheConfig().GetDeltaBaseCacheLimit();
			cache = new DeltaBaseCache.Slot[CACHE_SZ];
			for (int i = 0; i < CACHE_SZ; i++)
			{
				cache[i] = new DeltaBaseCache.Slot();
			}
		}
Esempio n. 12
0
        public static void Reconfigure(int packedGitLimit, int packedGitWindowSize, bool
                                       packedGitMMAP, int deltaBaseCacheLimit)
        {
            WindowCacheConfig c = new WindowCacheConfig();

            c.SetPackedGitLimit(packedGitLimit);
            c.SetPackedGitWindowSize(packedGitWindowSize);
            c.SetPackedGitMMAP(packedGitMMAP);
            c.SetDeltaBaseCacheLimit(deltaBaseCacheLimit);
            Reconfigure(c);
        }
Esempio n. 13
0
 /// <summary>Modify the configuration of the window cache.</summary>
 /// <remarks>
 /// Modify the configuration of the window cache.
 /// <p>
 /// 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.
 /// </remarks>
 /// <param name="cfg">the new window cache configuration.</param>
 /// <exception cref="System.ArgumentException">
 /// the cache configuration contains one or more invalid
 /// settings, usually too low of a limit.
 /// </exception>
 public static void Reconfigure(WindowCacheConfig cfg)
 {
     NGit.Storage.File.WindowCache nc = new NGit.Storage.File.WindowCache(cfg);
     NGit.Storage.File.WindowCache oc = cache;
     if (oc != null)
     {
         oc.RemoveAll();
     }
     cache = nc;
     streamFileThreshold = cfg.GetStreamFileThreshold();
     DeltaBaseCache.Reconfigure(cfg);
 }
Esempio n. 14
0
 internal static void Reconfigure(WindowCacheConfig cfg)
 {
     lock (typeof(DeltaBaseCache))
     {
         int dbLimit = cfg.GetDeltaBaseCacheLimit();
         if (maxByteCount != dbLimit)
         {
             maxByteCount = dbLimit;
             ReleaseMemory();
         }
     }
 }
Esempio n. 15
0
        public virtual void TestCache_Defaults()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
            WindowCache cache = WindowCache.GetInstance();

            NUnit.Framework.Assert.AreEqual(6, cache.GetOpenFiles());
            NUnit.Framework.Assert.AreEqual(17346, cache.GetOpenBytes());
        }
Esempio n. 16
0
		internal static void Reconfigure(WindowCacheConfig cfg)
		{
			lock (typeof(DeltaBaseCache))
			{
				int dbLimit = cfg.GetDeltaBaseCacheLimit();
				if (maxByteCount != dbLimit)
				{
					maxByteCount = dbLimit;
					ReleaseMemory();
				}
			}
		}
Esempio n. 17
0
        public virtual 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.
            //
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitLimit(6 * 4096 / 5);
            cfg.SetPackedGitWindowSize(4096);
            WindowCache.Reconfigure(cfg);
        }
Esempio n. 18
0
 public virtual void TestConfigureCache_PackedGitLimit_0()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitLimit(0);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitLimit = 0");
     }
     catch (ArgumentException)
     {
     }
 }
		public virtual void TestConfigureCache_PackedGitLimit_0()
		{
			try
			{
				WindowCacheConfig cfg = new WindowCacheConfig();
				cfg.SetPackedGitLimit(0);
				WindowCache.Reconfigure(cfg);
				NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitLimit = 0");
			}
			catch (ArgumentException)
			{
			}
		}
Esempio n. 20
0
 public virtual void TestConfigureCache_PackedGitWindowSize_4097()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitWindowSize(4097);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize = 4097");
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Window size must be power of 2", e.Message);
     }
 }
Esempio n. 21
0
 public virtual void TestConfigureCache_PackedGitOpenFiles_0()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitOpenFiles(0);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitOpenFiles = 0");
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Open files must be >= 1", e.Message);
     }
 }
		public virtual void TestConfigureCache_PackedGitWindowSize_0()
		{
			try
			{
				WindowCacheConfig cfg = new WindowCacheConfig();
				cfg.SetPackedGitWindowSize(0);
				WindowCache.Reconfigure(cfg);
				NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize = 0");
			}
			catch (ArgumentException e)
			{
				NUnit.Framework.Assert.AreEqual("Invalid window size", e.Message);
			}
		}
Esempio n. 23
0
 public virtual void TestConfigureCache_PackedGitWindowSize_512()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitWindowSize(512);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize = 512");
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Invalid window size", e.Message);
     }
 }
Esempio n. 24
0
        private static int TableSize(WindowCacheConfig cfg)
        {
            int  wsz   = cfg.GetPackedGitWindowSize();
            long limit = cfg.GetPackedGitLimit();

            if (wsz <= 0)
            {
                throw new ArgumentException(JGitText.Get().invalidWindowSize);
            }
            if (limit < wsz)
            {
                throw new ArgumentException(JGitText.Get().windowSizeMustBeLesserThanLimit);
            }
            return((int)Math.Min(5 * (limit / wsz) / 2, 2000000000));
        }
Esempio n. 25
0
 public virtual void TestConfigureCache_PackedGitWindowSizeAbovePackedGitLimit()
 {
     try
     {
         WindowCacheConfig cfg = new WindowCacheConfig();
         cfg.SetPackedGitLimit(1024);
         cfg.SetPackedGitWindowSize(8192);
         WindowCache.Reconfigure(cfg);
         NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit"
                                     );
     }
     catch (ArgumentException e)
     {
         NUnit.Framework.Assert.AreEqual("Window size must be < limit", e.Message);
     }
 }
Esempio n. 26
0
		internal static void Reconfigure(WindowCacheConfig cfg)
		{
			defaultMaxByteCount = cfg.GetDeltaBaseCacheLimit();
		}
Esempio n. 27
0
		public virtual void TestCache_TooFewFiles()
		{
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetPackedGitOpenFiles(2);
			WindowCache.Reconfigure(cfg);
			DoCacheTests();
			CheckLimits(cfg);
		}
Esempio n. 28
0
		public override void TearDown()
		{
			base.TearDown();
			WindowCacheConfig windowCacheConfig = new WindowCacheConfig();
			WindowCache.Reconfigure(windowCacheConfig);
		}
Esempio n. 29
0
		public virtual void TestCache_TooSmallLimit()
		{
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetPackedGitWindowSize(4096);
			cfg.SetPackedGitLimit(4096);
			WindowCache.Reconfigure(cfg);
			DoCacheTests();
			CheckLimits(cfg);
		}
Esempio n. 30
0
		private static void WhackCache()
		{
			WindowCacheConfig config = new WindowCacheConfig();
			config.SetPackedGitOpenFiles(1);
			WindowCache.Reconfigure(config);
		}
Esempio n. 31
0
		private void CheckLimits(WindowCacheConfig cfg)
		{
			WindowCache cache = WindowCache.GetInstance();
			NUnit.Framework.Assert.IsTrue(cache.GetOpenFiles() <= cfg.GetPackedGitOpenFiles()
				);
			NUnit.Framework.Assert.IsTrue(cache.GetOpenBytes() <= cfg.GetPackedGitLimit());
			NUnit.Framework.Assert.IsTrue(0 < cache.GetOpenFiles());
			NUnit.Framework.Assert.IsTrue(0 < cache.GetOpenBytes());
		}
		public virtual 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.
			//
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetPackedGitLimit(6 * 4096 / 5);
			cfg.SetPackedGitWindowSize(4096);
			WindowCache.Reconfigure(cfg);
		}
		public virtual void TestConfigureCache_PackedGitWindowSizeAbovePackedGitLimit()
		{
			try
			{
				WindowCacheConfig cfg = new WindowCacheConfig();
				cfg.SetPackedGitLimit(1024);
				cfg.SetPackedGitWindowSize(8192);
				WindowCache.Reconfigure(cfg);
				NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit"
					);
			}
			catch (ArgumentException e)
			{
				NUnit.Framework.Assert.AreEqual("Window size must be < limit", e.Message);
			}
		}
		public virtual void TestConfigureCache_PackedGitOpenFiles_0()
		{
			try
			{
				WindowCacheConfig cfg = new WindowCacheConfig();
				cfg.SetPackedGitOpenFiles(0);
				WindowCache.Reconfigure(cfg);
				NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitOpenFiles = 0");
			}
			catch (ArgumentException e)
			{
				NUnit.Framework.Assert.AreEqual("Open files must be >= 1", e.Message);
			}
		}
		public virtual void TestConfigureCache_PackedGitWindowSize_4097()
		{
			try
			{
				WindowCacheConfig cfg = new WindowCacheConfig();
				cfg.SetPackedGitWindowSize(4097);
				WindowCache.Reconfigure(cfg);
				NUnit.Framework.Assert.Fail("incorrectly permitted PackedGitWindowSize = 4097");
			}
			catch (ArgumentException e)
			{
				NUnit.Framework.Assert.AreEqual("Window size must be power of 2", e.Message);
			}
		}
Esempio n. 36
0
		public virtual void TestCache_Defaults()
		{
			WindowCacheConfig cfg = new WindowCacheConfig();
			WindowCache.Reconfigure(cfg);
			DoCacheTests();
			CheckLimits(cfg);
			WindowCache cache = WindowCache.GetInstance();
			NUnit.Framework.Assert.AreEqual(6, cache.GetOpenFiles());
			NUnit.Framework.Assert.AreEqual(17346, cache.GetOpenBytes());
		}
Esempio n. 37
0
 private static int LockCount(WindowCacheConfig cfg)
 {
     return(Math.Max(cfg.GetPackedGitOpenFiles(), 32));
 }
 internal static void Reconfigure(WindowCacheConfig cfg)
 {
     defaultMaxByteCount = cfg.GetDeltaBaseCacheLimit();
 }