private static void WhackCache() { WindowCacheConfig config = new WindowCacheConfig(); config.SetPackedGitOpenFiles(1); WindowCache.Reconfigure(config); }
public override void TearDown() { base.TearDown(); WindowCacheConfig windowCacheConfig = new WindowCacheConfig(); WindowCache.Reconfigure(windowCacheConfig); }
public override void SetUp() { WindowCacheConfig windowCacheConfig = new WindowCacheConfig(); windowCacheConfig.SetPackedGitOpenFiles(1); WindowCache.Reconfigure(windowCacheConfig); base.SetUp(); }
public override void SetUp() { base.SetUp(); WindowCacheConfig cfg = new WindowCacheConfig(); cfg.SetStreamFileThreshold(streamThreshold); WindowCache.Reconfigure(cfg); repo = CreateBareRepository(); wc = (WindowCursor)repo.NewObjectReader(); }
public virtual void TestCache_TooFewFiles() { WindowCacheConfig cfg = new WindowCacheConfig(); cfg.SetPackedGitOpenFiles(2); WindowCache.Reconfigure(cfg); DoCacheTests(); CheckLimits(cfg); }
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); } }
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 TestCache_TooSmallLimit() { WindowCacheConfig cfg = new WindowCacheConfig(); cfg.SetPackedGitWindowSize(4096); cfg.SetPackedGitLimit(4096); WindowCache.Reconfigure(cfg); DoCacheTests(); CheckLimits(cfg); }
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(); } }
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); }
/// <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); }
internal static void Reconfigure(WindowCacheConfig cfg) { lock (typeof(DeltaBaseCache)) { int dbLimit = cfg.GetDeltaBaseCacheLimit(); if (maxByteCount != dbLimit) { maxByteCount = dbLimit; ReleaseMemory(); } } }
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()); }
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_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_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); } }
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); } }
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); } }
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)); }
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); } }
internal static void Reconfigure(WindowCacheConfig cfg) { defaultMaxByteCount = cfg.GetDeltaBaseCacheLimit(); }
private static int LockCount(WindowCacheConfig cfg) { return(Math.Max(cfg.GetPackedGitOpenFiles(), 32)); }