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(); }
/// <summary>Close the resources utilized by this repository</summary> public virtual void Close() { WindowCache.Purge(this); lock (this) { loadedIdx = null; reverseIdx = null; } }
public virtual void TestCache_TooFewFiles() { WindowCacheConfig cfg = new WindowCacheConfig(); cfg.SetPackedGitOpenFiles(2); WindowCache.Reconfigure(cfg); DoCacheTests(); CheckLimits(cfg); }
public override void TearDown() { if (wc != null) { wc.Release(); } WindowCache.Reconfigure(new WindowCacheConfig()); base.TearDown(); }
public virtual void TestCache_TooSmallLimit() { WindowCacheConfig cfg = new WindowCacheConfig(); cfg.SetPackedGitWindowSize(4096); cfg.SetPackedGitLimit(4096); WindowCache.Reconfigure(cfg); DoCacheTests(); CheckLimits(cfg); }
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 override void SetUp() { base.SetUp(); WindowCacheConfig cfg = new WindowCacheConfig(); cfg.SetStreamFileThreshold(streamThreshold); WindowCache.Reconfigure(cfg); repo = CreateBareRepository(); wc = (WindowCursor)repo.NewObjectReader(); }
/// <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); }
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_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_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_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); } }
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); } }
/// <exception cref="System.IO.IOException"></exception> internal void Pin(PackFile pack, long position) { ByteWindow w = window; if (w == null || !w.Contains(pack, position)) { // If memory is low, we may need what is in our window field to // be cleaned up by the GC during the get for the next window. // So we always clear it, even though we are just going to set // it again. // window = null; window = WindowCache.Get(pack, position); } }
/// <exception cref="System.IO.IOException"></exception> internal static ByteWindow Get(PackFile pack, long offset) { NGit.Storage.File.WindowCache c = cache; ByteWindow r = c.GetOrLoad(pack, c.ToStart(offset)); if (c != cache) { // The cache was reconfigured while we were using the old one // to load this window. The window is still valid, but our // cache may think its still live. Ensure the window is removed // from the old cache so resources can be released. // c.RemoveAll(); } return(r); }
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 int GetStreamFileThreshold() { return(WindowCache.GetStreamFileThreshold()); }