public void CanReportMetricsInParallel() { var currentBuffer = 2048; var historicalBuffer = 20000; var metrics = new IoMetrics(currentBuffer, historicalBuffer); var forIterations = 1000 * 1000; Parallel.For(0, forIterations, RavenTestHelper.DefaultParallelOptions, i => { using (metrics.MeterIoRate("file1.txt", IoMetrics.MeterType.JournalWrite, 1)) { // empty } }); foreach (var file in metrics.Files) { var currentItems = new List <IoMeterBuffer.MeterItem>(file.JournalWrite.GetCurrentItems()); var historyItems = new List <IoMeterBuffer.SummerizedItem>(file.JournalWrite.GetSummerizedItems()); var totalItems = historyItems.Sum(x => x.Count) + currentItems.Count; Assert.Equal(forIterations, totalItems); } }
protected StorageEnvironmentOptions(string tempPath) { TempPath = tempPath; PageSize = Constants.Storage.PageSize; ShouldUseKeyPrefix = name => false; MaxLogFileSize = 256 * Constants.Size.Megabyte; InitialLogFileSize = 64 * Constants.Size.Kilobyte; MaxScratchBufferSize = 256 * Constants.Size.Megabyte; MaxNumberOfPagesInJournalBeforeFlush = 8192; // 32 MB when 4Kb IdleFlushTimeout = 5000; // 5 seconds OwnsPagers = true; IncrementalBackupEnabled = false; IoMetrics = new IoMetrics(256, 256); _log = LoggingSource.Instance.GetLogger <StorageEnvironment>(tempPath); }
public void CanProperlyReportIoMetrics() { var metrics = new IoMetrics(4, 4); for (var i = 0; i < 6; i++) { var now = DateTime.UtcNow; metrics.MeterIoRate("file1.txt", IoMetrics.MeterType.JournalWrite, i + 1) .Parent.Mark(i + 1, now, now.AddMilliseconds(2), IoMetrics.MeterType.JournalWrite); } int filesCount = 0; foreach (var file in metrics.Files) { filesCount++; var currentItems = new List <IoMeterBuffer.MeterItem>(file.JournalWrite.GetCurrentItems()); var historyItems = new List <IoMeterBuffer.SummerizedItem>(file.JournalWrite.GetSummerizedItems()); foreach (var currentItem in currentItems) { var durationInMs = currentItem.Duration.TotalMilliseconds; Assert.InRange(durationInMs, 0, 2); } Assert.Equal(1, historyItems.Count); Assert.Equal(1, currentItems.Count); Assert.Equal(1 + 2 + 3 + 4 + 5, historyItems[0].TotalSize); Assert.Equal(6L, currentItems[0].Size); } Assert.Equal(1, filesCount); }
public ServerStore(RavenConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } IoMetrics = new IoMetrics(8, 8); // TODO:: increase this to 256,256 ? Configuration = configuration; _logger = LoggingSource.Instance.GetLogger <ServerStore>("ServerStore"); DatabasesLandlord = new DatabasesLandlord(this); Alerts = new AlertsStorage("Raven/Server", this); DatabaseInfoCache = new DatabaseInfoCache(); }
protected StorageEnvironmentOptions(VoronPathSetting tempPath, IoChangesNotifications ioChangesNotifications, CatastrophicFailureNotification catastrophicFailureNotification) { SafePosixOpenFlags = SafePosixOpenFlags | DefaultPosixFlags; DisposeWaitTime = TimeSpan.FromSeconds(15); TempPath = tempPath; ShouldUseKeyPrefix = name => false; MaxLogFileSize = ((sizeof(int) == IntPtr.Size ? 32 : 256) * Constants.Size.Megabyte); InitialLogFileSize = 64 * Constants.Size.Kilobyte; MaxScratchBufferSize = ((sizeof(int) == IntPtr.Size ? 32 : 256) * Constants.Size.Megabyte); MaxNumberOfPagesInJournalBeforeFlush = ((sizeof(int) == IntPtr.Size ? 4 : 32) * Constants.Size.Megabyte) / Constants.Storage.PageSize; IdleFlushTimeout = 5000; // 5 seconds OwnsPagers = true; IncrementalBackupEnabled = false; IoMetrics = new IoMetrics(256, 256, ioChangesNotifications); _log = LoggingSource.Instance.GetLogger <StorageEnvironment>(tempPath.FullPath); _catastrophicFailureNotification = catastrophicFailureNotification ?? new CatastrophicFailureNotification((e) => { if (_log.IsOperationsEnabled) { _log.Operations($"Catastrophic failure in {this}", e); } }); var shouldForceEnvVar = Environment.GetEnvironmentVariable("VORON_INTERNAL_ForceUsing32BitsPager"); bool result; if (bool.TryParse(shouldForceEnvVar, out result)) { ForceUsing32BitsPager = result; } }