コード例 #1
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
        private static void WhackCache()
        {
            WindowCacheConfig config = new WindowCacheConfig();

            config.SetPackedGitOpenFiles(1);
            WindowCache.Reconfigure(config);
        }
コード例 #2
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
        public override void TearDown()
        {
            base.TearDown();
            WindowCacheConfig windowCacheConfig = new WindowCacheConfig();

            WindowCache.Reconfigure(windowCacheConfig);
        }
コード例 #3
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
		public override void SetUp()
		{
			WindowCacheConfig windowCacheConfig = new WindowCacheConfig();
			windowCacheConfig.SetPackedGitOpenFiles(1);
			WindowCache.Reconfigure(windowCacheConfig);
			base.SetUp();
		}
コード例 #4
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
        public override void SetUp()
        {
            WindowCacheConfig windowCacheConfig = new WindowCacheConfig();

            windowCacheConfig.SetPackedGitOpenFiles(1);
            WindowCache.Reconfigure(windowCacheConfig);
            base.SetUp();
        }
コード例 #5
0
ファイル: UnpackedObjectTest.cs プロジェクト: shoff/ngit
		public override void SetUp()
		{
			base.SetUp();
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetStreamFileThreshold(streamThreshold);
			WindowCache.Reconfigure(cfg);
			repo = CreateBareRepository();
			wc = (WindowCursor)repo.NewObjectReader();
		}
コード例 #6
0
        public virtual void TestCache_TooFewFiles()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitOpenFiles(2);
            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
コード例 #7
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
        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);
            }
        }
コード例 #8
0
        public override void SetUp()
        {
            base.SetUp();
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetStreamFileThreshold(streamThreshold);
            WindowCache.Reconfigure(cfg);
            repo = CreateBareRepository();
            wc   = (WindowCursor)repo.NewObjectReader();
        }
コード例 #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());
        }
コード例 #10
0
        public virtual void TestCache_TooSmallLimit()
        {
            WindowCacheConfig cfg = new WindowCacheConfig();

            cfg.SetPackedGitWindowSize(4096);
            cfg.SetPackedGitLimit(4096);
            WindowCache.Reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
コード例 #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();
			}
		}
コード例 #12
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
        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);
        }
コード例 #13
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
 /// <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);
 }
コード例 #14
0
ファイル: DeltaBaseCache.cs プロジェクト: ashmind/ngit
 internal static void Reconfigure(WindowCacheConfig cfg)
 {
     lock (typeof(DeltaBaseCache))
     {
         int dbLimit = cfg.GetDeltaBaseCacheLimit();
         if (maxByteCount != dbLimit)
         {
             maxByteCount = dbLimit;
             ReleaseMemory();
         }
     }
 }
コード例 #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());
        }
コード例 #16
0
		internal static void Reconfigure(WindowCacheConfig cfg)
		{
			lock (typeof(DeltaBaseCache))
			{
				int dbLimit = cfg.GetDeltaBaseCacheLimit();
				if (maxByteCount != dbLimit)
				{
					maxByteCount = dbLimit;
					ReleaseMemory();
				}
			}
		}
コード例 #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);
        }
コード例 #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)
     {
     }
 }
コード例 #19
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)
			{
			}
		}
コード例 #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);
     }
 }
コード例 #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);
     }
 }
コード例 #22
0
		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);
			}
		}
コード例 #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);
     }
 }
コード例 #24
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
        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));
        }
コード例 #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);
     }
 }
コード例 #26
0
ファイル: DeltaBaseCache.cs プロジェクト: LunarLanding/ngit
		internal static void Reconfigure(WindowCacheConfig cfg)
		{
			defaultMaxByteCount = cfg.GetDeltaBaseCacheLimit();
		}
コード例 #27
0
		public virtual void TestCache_TooFewFiles()
		{
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetPackedGitOpenFiles(2);
			WindowCache.Reconfigure(cfg);
			DoCacheTests();
			CheckLimits(cfg);
		}
コード例 #28
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
		public override void TearDown()
		{
			base.TearDown();
			WindowCacheConfig windowCacheConfig = new WindowCacheConfig();
			WindowCache.Reconfigure(windowCacheConfig);
		}
コード例 #29
0
		public virtual void TestCache_TooSmallLimit()
		{
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetPackedGitWindowSize(4096);
			cfg.SetPackedGitLimit(4096);
			WindowCache.Reconfigure(cfg);
			DoCacheTests();
			CheckLimits(cfg);
		}
コード例 #30
0
ファイル: ConcurrentRepackTest.cs プロジェクト: shoff/ngit
		private static void WhackCache()
		{
			WindowCacheConfig config = new WindowCacheConfig();
			config.SetPackedGitOpenFiles(1);
			WindowCache.Reconfigure(config);
		}
コード例 #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());
		}
コード例 #32
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);
		}
コード例 #33
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);
			}
		}
コード例 #34
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);
			}
		}
コード例 #35
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);
			}
		}
コード例 #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());
		}
コード例 #37
0
ファイル: WindowCache.cs プロジェクト: TetradogOther/NGit
 private static int LockCount(WindowCacheConfig cfg)
 {
     return(Math.Max(cfg.GetPackedGitOpenFiles(), 32));
 }
コード例 #38
0
 internal static void Reconfigure(WindowCacheConfig cfg)
 {
     defaultMaxByteCount = cfg.GetDeltaBaseCacheLimit();
 }