Пример #1
0
        public CPUPerformancePart(string partID, CPUPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new CPUPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            Log.SetDefaultNamedValueSetForEmitter(Logging.MesgType.All, new NamedValueSet()
            {
                { "noMDRF" }
            });

            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = config.SampleInterval, AutoReset = true
            }.Start();
            aggregationIntervalTimer = new QpcTimer()
            {
                TriggerInterval = config.AggregationInterval, AutoReset = true
            }.Start();

            h1Grp  = new MDRFHistogramGroupSource("{0}.h1".CheckedFormat(partID), h1, Config.SampleGroupsFileIndexUserRowFlagBits);
            h10Grp = new MDRFHistogramGroupSource("{0}.h10".CheckedFormat(partID), h10, Config.SampleGroupsFileIndexUserRowFlagBits);
            h30Grp = new MDRFHistogramGroupSource("{0}.h30".CheckedFormat(partID), h30, Config.SampleGroupsFileIndexUserRowFlagBits);

            ah1  = new Histogram(h1);
            ah10 = new Histogram(h10);
            ah30 = new Histogram(h30);

            ah1Grp  = new MDRFHistogramGroupSource("{0}.ah1".CheckedFormat(partID), ah1, Config.AggregateGroupsFileIndexUserRowFlagBits);
            ah10Grp = new MDRFHistogramGroupSource("{0}.ah10".CheckedFormat(partID), ah10, Config.AggregateGroupsFileIndexUserRowFlagBits);
            ah30Grp = new MDRFHistogramGroupSource("{0}.ah30".CheckedFormat(partID), ah30, Config.AggregateGroupsFileIndexUserRowFlagBits);

            mdrfWriter.Add(h1Grp.GroupInfo, h10Grp.GroupInfo, h30Grp.GroupInfo, ah1Grp.GroupInfo, ah10Grp.GroupInfo, ah30Grp.GroupInfo);
        }
Пример #2
0
        public ProcessPerformancePart(string partID, ProcessPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.1).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new ProcessPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = config.SampleInterval, AutoReset = true
            }.Start();

            Log.SetDefaultNamedValueSetForEmitter(Logging.MesgType.All, new NamedValueSet()
            {
                { "noMDRF" }
            });

            ProcessDeltaOccurrenceInfo = new MDRF.Writer.OccurrenceInfo()
            {
                Name    = "{0}.ProcessDelta".CheckedFormat(PartID),
                Comment = "Used to record all process additions, removals, and migrations to/from the active set",
                FileIndexUserRowFlagBits = config.ProcessDeltaOccurrenceFileIndexUserRowFlagBits,
            };

            activeSetItemTrackerArray       = Enumerable.Range(1, Math.Max(config.ActiveSetSize, 1)).Select(groupNum => new ActiveSetItemTracker("{0}.ActSet{1:d2}".CheckedFormat(PartID, groupNum), Config.ActiveSetGroupsFileIndexUserRowFlagBits)).ToArray();
            activeSetItemTrackerArrayLength = activeSetItemTrackerArray.Length;

            activeSetMapGroup = new ActiveSetMapGroupTracker(config.ActiveSetSize, "{0}.ActSetMap".CheckedFormat(PartID), Config.ActiveSetMapGroupFileIndexUserRowFlagBits);

            GroupInfoArray = activeSetItemTrackerArray.Select(ast => ast.GroupInfo).ToArray();

            mdrfWriter.Add(ProcessDeltaOccurrenceInfo);
            mdrfWriter.Add(activeSetMapGroup.GroupInfo);
            mdrfWriter.AddRange(GroupInfoArray);
        }
Пример #3
0
        public PerformanceCountersPart(PerformanceCountersPartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(config.PartID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new PerformanceCountersPartConfig(config);
            this.mdrfWriter = mdrfWriter;

            // we trigger acquiring a new sample two times a second
            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.SampleInterval, AutoReset = true
            }.Start();

            performanceCounterTrackerArray = Config.PerformanceCounterSpecArray.Select(pcs => new PerformanceCounterTracker(Log, pcs)).ToArray();

            pccTupleArray = performanceCounterTrackerArray.GroupBy(pct => pct.pcc, (pcc, pctSet) => Tuple.Create(pcc, pctSet.ToArray())).ToArray();

            groupInfo = new MDRF.Writer.GroupInfo()
            {
                Name = "{0}.Grp".CheckedFormat(PartID),
                GroupBehaviorOptions     = MDRF.Writer.GroupBehaviorOptions.UseVCHasBeenSetForTouched | MDRF.Writer.GroupBehaviorOptions.IncrSeqNumOnTouched,
                FileIndexUserRowFlagBits = (ulong)Config.PerformanceCounterGroupsFileIndexUserRowFlagBits,
                GroupPointInfoArray      = performanceCounterTrackerArray.Select(pct => pct.gpInfo).ToArray(),
            };

            mdrfWriter.Add(groupInfo);

            noMDRFLogger = new Logging.Logger(PartID).SetDefaultNamedValueSetForEmitter(Logging.LogGate.All, new NamedValueSet()
            {
                { "noMDRF" }
            });
        }
Пример #4
0
        public PingPerformancePart(string partID, PingPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new PingPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.SampleInterval, AutoReset = true
            }.Start();
            aggregationIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.AggregationInterval, AutoReset = true
            }.Start();

            AddExplicitDisposeAction(() => Release());

            pingTrackerArray = Config.PingTargetArray.Select(hostNameOrAddress => new PingTracker(hostNameOrAddress, binBoundariesArray, Config, this)).ToArray();

            pingTrackerArray.DoForEach(pt => mdrfWriter.Add(pt.hGrp.GroupInfo));

            noMDRFLogger = new Logging.Logger(PartID).SetDefaultNamedValueSetForEmitter(Logging.LogGate.All, new NamedValueSet()
            {
                { "noMDRF" }
            });
        }
Пример #5
0
        public SerialEchoPerformancePart(string partID, SerialEchoPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new SerialEchoPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.SampleInterval, AutoReset = true
            }.Start();
            aggregationIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.AggregationInterval, AutoReset = true
            }.Start();

            AddExplicitDisposeAction(() => Release());

            int targetCount = 1;

            serialEchoTrackerArray = Config.PortTargetSpecArray.Select(portTargetSpec => new SerialEchoTracker("SerialEchoPort_{0:d2}".CheckedFormat(targetCount++), portTargetSpec, binBoundariesArray, Config, this, Log)).ToArray();

            serialEchoTrackerArray.DoForEach(pt => mdrfWriter.Add(pt.hGrp.GroupInfo));

            noMDRFLogger = new Logging.Logger(PartID).SetDefaultNamedValueSetForEmitter(Logging.LogGate.All, new NamedValueSet()
            {
                { "noMDRF" }
            });
        }
Пример #6
0
        /// <summary>Constructor</summary>
        public MovingAverageTool(TimeSpan?nominalUpdateInterval = null, int maxAveragingHistoryLength = 5, QpcTimeStamp qpcTimeStamp = default(QpcTimeStamp))
        {
            rateIntervalTimer = new QpcTimer()
            {
                TriggerInterval  = nominalUpdateInterval ?? (0.5).FromSeconds(),
                SelectedBehavior = QpcTimer.Behavior.NewAutoReset,
            };

            this.maxAveragingHistoryLength = maxAveragingHistoryLength.Clip(1, 1000);
            historyList = new List <HistoryItem>(maxAveragingHistoryLength);

            Reset(qpcTimeStamp, clearTotalizer: true);

            AutoService = true;
        }
Пример #7
0
                /// <summary>
                /// This method attempts to setup the <see cref="MosaicLib.File.DirectoryFileRotationManager"/> to manage the ring of log files.  This must be comleted successfully
                /// before this LMH can be used to write to any log file.
                /// </summary>
                /// <returns>True if the setup operation was successfull</returns>
                protected bool Setup()
                {
                    lastSetupAttemptTime.SetToNow();

                    bool success = false;

                    try
                    {
                        success = dirPruneMgr.Setup(config);
                        dirPruneIntervalTimer = new QpcTimer()
                        {
                            TriggerInterval = config.PruneInterval, AutoReset = true, Started = true
                        };

                        if (!success)
                        {
                            setupFaultCode = "{0} setup for path '{1}' failed:'{2}'".CheckedFormat(dirPruneMgr.ObjID, config.DirPath, dirPruneMgr.SetupFaultCode);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        setupFaultCode = "{0} setup for path '{1}' threw exception:'{2}'".CheckedFormat(dirPruneMgr.ObjID, config.DirPath, ex.Message);
                    }

                    if (!ActivateFile(true) && setupFaultCode.IsNullOrEmpty())
                    {
                        if (!IsActiveFileDefined)
                        {
                            setupFaultCode = "path '{0}' gave empty active file path".CheckedFormat(config.DirPath);
                        }
                        else
                        {
                            setupFaultCode = "path '{0}' failed: failed to open active file '{1}'".CheckedFormat(config.DirPath, PathToActiveFile);
                        }
                    }

                    setupPerformed = true;

                    if (setupFaultCode.IsNullOrEmpty())
                    {
                        return(true);
                    }
                    else
                    {
                        logger.Error.Emit("{0} failed: {1}", Fcns.CurrentMethodName, setupFaultCode);
                        return(false);
                    }
                }
        private static Win32.Hooks.ConsoleCtrlHandlerHook.ClientProvidedDelegateResult CtrlHandlerDelegate(Win32.Hooks.ConsoleCtrlHandlerHook sender, Win32.Hooks.CtrlType ctrlType, List <IActivePartBase> partsList)
        {
            IClientFacet [] goOfflineActionArray = partsList.Select(part => part.CreateGoOfflineAction().StartInline()).ToArray();

            QpcTimer waitTimeLimitTimer = new QpcTimer()
            {
                TriggerIntervalInSec = 0.5
            }.Start();

            goOfflineActionArray.WaitUntilSetComplete(() => waitTimeLimitTimer.IsTriggered);

            sender.ExitCode = (goOfflineActionArray.Any(a => a.ActionState.Failed) ? 1 : 0);

            partsList.TakeAndDisposeOfGivenObjects();

            return(Win32.Hooks.ConsoleCtrlHandlerHook.ClientProvidedDelegateResult.Exit);
        }
Пример #9
0
        /// <summary>
        /// Run the given action to completion.  Returns the given action to support call chaining.
        /// Optional parameters support constrained total wait timeLimit, use provided spinPeriod, parentAction (to monitor for cancel requests) and spinDelegate
        /// spinPeriod will use 0.10 seconds if a non-default (zero) value is not provided.
        /// </summary>
        /// <remarks>
        /// Currently this method uses a spin timer and repeatedly calls the given action's time limit based WaitUntilComplete method.
        /// This means that the method will have settable latency (based on the provided spinPeriod) in reacting to a cancelation request and reflecting it into the action being run here.
        /// </remarks>
        public static TClientFacetType RunInline <TClientFacetType>(this TClientFacetType action, TimeSpan timeLimit = default(TimeSpan), TimeSpan spinPeriod = default(TimeSpan), IProviderFacet parentAction = null, System.Action spinDelegate = null)
            where TClientFacetType : IClientFacet
        {
            spinPeriod = spinPeriod.MapDefaultTo(TimeSpan.FromSeconds(0.10));
            bool haveSpinDelegate = spinDelegate != null;
            bool haveTimeLimit    = (timeLimit != default(TimeSpan));
            bool haveParentAction = (parentAction != null);

            QpcTimer waitTimeLimitTimer = default(QpcTimer);

            if (haveTimeLimit)
            {
                waitTimeLimitTimer = new QpcTimer()
                {
                    TriggerInterval = timeLimit, Started = true
                }
            }
            ;

            for (; ;)
            {
                if (action.WaitUntilComplete(spinPeriod))
                {
                    break;
                }

                if (haveSpinDelegate)
                {
                    spinDelegate();
                }

                if (haveParentAction && parentAction.IsCancelRequestActive && !action.IsCancelRequestActive)
                {
                    action.RequestCancel();
                }

                if (haveTimeLimit && waitTimeLimitTimer.IsTriggered)
                {
                    break;
                }
            }

            return(action);
        }
    }
Пример #10
0
        public NetIfacePerformancePart(string partID, NetIfacePerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new NetIfacePerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            Log.SetDefaultNamedValueSetForEmitter(Logging.MesgType.All, new NamedValueSet()
            {
                { "noMDRF" }
            });

            sampleRecordingIntervalTimer = new QpcTimer()
            {
                TriggerInterval = config.SampleRecordingInterval, AutoReset = true
            }.Start();
            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = config.SampleRecordingInterval.Min((0.5).FromSeconds()), AutoReset = true
            }.Start();

            netIfaceSettingChangeOccurrence = new MDRF.Writer.OccurrenceInfo()
            {
                Name    = "{0}.SettingChange".CheckedFormat(PartID),
                Comment = "Used to record all network adapter setting changes",
                FileIndexUserRowFlagBits = Config.ChangeOccurrenceFileIndexUserRowFlagBits
            };

            netIfaceStatusChangeOccurrence = new MDRF.Writer.OccurrenceInfo()
            {
                Name    = "{0}.StatusChange".CheckedFormat(PartID),
                Comment = "Used to record all network adapter state changes",
                FileIndexUserRowFlagBits = Config.ChangeOccurrenceFileIndexUserRowFlagBits
            };

            mdrfWriter.Add(netIfaceSettingChangeOccurrence, netIfaceStatusChangeOccurrence);

            NetworkInterface[] netInterfacesArray = NetworkInterface.GetAllNetworkInterfaces().Where(ni => ni.NetworkInterfaceType != NetworkInterfaceType.Tunnel && ni.NetworkInterfaceType != NetworkInterfaceType.Loopback).ToArray();

            netIfaceTrackerArray = netInterfacesArray.Select((netIface, idx) => new NetIfaceTracker(PartID, netIface, idx + 1, config.StatisticsGroupsFileIndexUserRowFlagBits)).ToArray();

            netIfaceTrackerArray.DoForEach(nit => netIfaceTrackerDictionary[nit.name] = nit);
            netIfaceTrackerArray.DoForEach(nit => mdrfWriter.Add(nit.groupInfo));
        }
Пример #11
0
        bool Spin(TimeSpan spinTime)
        {
            Time.QpcTimer timer = new QpcTimer();

            timer.Start(spinTime);

            for (; ;)
            {
                if (!Spin())
                {
                    return(false);
                }

                if (timer.IsTriggered)
                {
                    return(true);
                }
            }
        }
Пример #12
0
        public FileRWPerformancePart(string partID, FileRWPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new FileRWPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            // we trigger acquiring a new sample two times a second
            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.SampleInterval, AutoReset = true
            }.Start();
            aggregationIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.AggregationInterval, AutoReset = true
            }.Start();

            AddExplicitDisposeAction(() => Release());

            ahReadNormal   = new Histogram(hReadNormal);
            ahReadThrough  = new Histogram(hReadThrough);
            ahWriteThrough = new Histogram(hWriteThrough);

            avgRatesGroup = new MDRF.Writer.GroupInfo()
            {
                Name = "{0}.avgRates".CheckedFormat(PartID),
                GroupBehaviorOptions     = MDRF.Writer.GroupBehaviorOptions.UseVCHasBeenSetForTouched | MDRF.Writer.GroupBehaviorOptions.IncrSeqNumOnTouched,
                FileIndexUserRowFlagBits = (ulong)Config.AggregateGroupsFileIndexUserRowFlagBits,
                GroupPointInfoArray      = new MDRF.Writer.GroupPointInfo[]
                {
                    peakReadNormalRateGPI = new MDRF.Writer.GroupPointInfo()
                    {
                        Name = "peakReadRate", ValueCST = ContainerStorageType.Double, VC = new ValueContainer(0.0)
                    },
                    peakReadThroughRateGPI = new MDRF.Writer.GroupPointInfo()
                    {
                        Name = "peakReadThroughRate", ValueCST = ContainerStorageType.Double, VC = new ValueContainer(0.0)
                    },
                    peakWriteThroughRateGPI = new MDRF.Writer.GroupPointInfo()
                    {
                        Name = "peakWriteThroughRate", ValueCST = ContainerStorageType.Double, VC = new ValueContainer(0.0)
                    },
                },
                Touched = true,
            };

            accumTupleArray = new Tuple <MDRFHistogramGroupSource, MDRFHistogramGroupSource> []
            {
                Tuple.Create(new MDRFHistogramGroupSource("{0}.hReadNormal".CheckedFormat(PartID), hReadNormal, Config.SampleGroupsFileIndexUserRowFlagBits),
                             new MDRFHistogramGroupSource("{0}.ahReadNormal".CheckedFormat(PartID), ahReadNormal, Config.AggregateGroupsFileIndexUserRowFlagBits)),
                Tuple.Create(new MDRFHistogramGroupSource("{0}.hReadThrough".CheckedFormat(PartID), hReadThrough, Config.SampleGroupsFileIndexUserRowFlagBits),
                             new MDRFHistogramGroupSource("{0}.ahReadThrough".CheckedFormat(PartID), ahReadThrough, Config.AggregateGroupsFileIndexUserRowFlagBits)),
                Tuple.Create(new MDRFHistogramGroupSource("{0}.hWriteThrough".CheckedFormat(PartID), hWriteThrough, Config.SampleGroupsFileIndexUserRowFlagBits),
                             new MDRFHistogramGroupSource("{0}.ahWriteThrough".CheckedFormat(PartID), ahWriteThrough, Config.AggregateGroupsFileIndexUserRowFlagBits)),
            };

            IEnumerable <Tuple <MDRFHistogramGroupSource, MDRFHistogramGroupSource> > registerGroupsSet = ((Config.UseFileFlagNoBuffering) ? accumTupleArray : new [] { accumTupleArray[0], accumTupleArray[2] });

            mdrfWriter.Add(avgRatesGroup);
            mdrfWriter.AddRange(registerGroupsSet.Select(t => t.Item1.GroupInfo).Concat(registerGroupsSet.Select(t => t.Item2.GroupInfo)));

            noMDRFLogger = new Logging.Logger(PartID).SetDefaultNamedValueSetForEmitter(Logging.LogGate.All, new NamedValueSet()
            {
                { "noMDRF" }
            });
        }
        bool Spin(TimeSpan spinTime)
        {
            Time.QpcTimer timer = new QpcTimer();

            timer.Start(spinTime);

            for (; ; )
            {
                if (!Spin())
                    return false;

                if (timer.IsTriggered)
                    return true;
            }
        }