diff --git a/Performance1.psess b/Performance1.psess new file mode 100644 index 0000000..7dc9d39 --- /dev/null +++ b/Performance1.psess @@ -0,0 +1,21 @@ + + + Sampling + None + true + Timestamp + Cycles + 10000000 + 10 + 10 + + false + + + + false + + + false + + diff --git a/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs b/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs index 4032b8e..2f86057 100644 --- a/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs +++ b/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.12.0")] -[assembly: AssemblyFileVersion("1.3.12.0")] +[assembly: AssemblyVersion("1.3.13.0")] +[assembly: AssemblyFileVersion("1.3.13.0")] diff --git a/TimberWinR.sln b/TimberWinR.sln index 5bcf14f..30b9a40 100644 --- a/TimberWinR.sln +++ b/TimberWinR.sln @@ -22,6 +22,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution chocolateyUninstall.ps1.guid = chocolateyUninstall.ps1.guid chocolateyUninstall.ps1.template = chocolateyUninstall.ps1.template LICENSE.txt = LICENSE.txt + Performance1.psess = Performance1.psess README.md = README.md timberwinr.nuspec.template = timberwinr.nuspec.template EndProjectSection @@ -99,4 +100,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection EndGlobal diff --git a/TimberWinR/Inputs/IISW3CInputListener.cs b/TimberWinR/Inputs/IISW3CInputListener.cs index 4ea48eb..675854d 100644 --- a/TimberWinR/Inputs/IISW3CInputListener.cs +++ b/TimberWinR/Inputs/IISW3CInputListener.cs @@ -150,6 +150,7 @@ namespace TimberWinR.Inputs } // Close the recordset rs.close(); + GC.Collect(); } } catch (Exception ex) diff --git a/TimberWinR/Inputs/LogsListener.cs b/TimberWinR/Inputs/LogsListener.cs index 99ae321..60db154 100644 --- a/TimberWinR/Inputs/LogsListener.cs +++ b/TimberWinR/Inputs/LogsListener.cs @@ -32,7 +32,7 @@ namespace TimberWinR.Inputs private Dictionary _logFileSizes; - public LogsListener(TimberWinR.Parser.Log arguments, CancellationToken cancelToken, int pollingIntervalInSeconds = 3) + public LogsListener(TimberWinR.Parser.Log arguments, CancellationToken cancelToken) : base(cancelToken, "Win32-FileLog") { _logFileMaxRecords = new Dictionary(); @@ -42,7 +42,7 @@ namespace TimberWinR.Inputs _receivedMessages = 0; _arguments = arguments; - _pollingIntervalInSeconds = pollingIntervalInSeconds; + _pollingIntervalInSeconds = arguments.Interval; foreach (string srcFile in _arguments.Location.Split(',')) { @@ -146,8 +146,9 @@ namespace TimberWinR.Inputs _logFileSizes[logName] = fi.Length; } + rsfiles.close(); foreach (string fileName in _logFileMaxRecords.Keys.ToList()) - { + { var lastRecordNumber = _logFileMaxRecords[fileName]; var query = string.Format("SELECT * FROM {0} where Index > {1}", fileName, lastRecordNumber); @@ -163,6 +164,7 @@ namespace TimberWinR.Inputs for (; !rs.atEnd(); rs.moveNext()) { var record = rs.getRecord(); + var json = new JObject(); foreach (var field in _arguments.Fields) { @@ -182,16 +184,19 @@ namespace TimberWinR.Inputs if (!string.IsNullOrEmpty(msg)) { ProcessJson(json); - _receivedMessages++; + _receivedMessages++; } var lrn = (Int64)record.getValueEx("Index"); _logFileMaxRecords[fileName] = lrn; + GC.Collect(); } + colMap.Clear(); // Close the recordset - rs.close(); + rs.close(); rs = null; + GC.Collect(); } } catch (Exception ex) diff --git a/TimberWinR/Inputs/WindowsEvtInputListener.cs b/TimberWinR/Inputs/WindowsEvtInputListener.cs index c4be9b5..07e3dde 100644 --- a/TimberWinR/Inputs/WindowsEvtInputListener.cs +++ b/TimberWinR/Inputs/WindowsEvtInputListener.cs @@ -157,6 +157,7 @@ namespace TimberWinR.Inputs // Close the recordset rs.close(); rs = null; + GC.Collect(); } } catch (System.Threading.ThreadAbortException tex) diff --git a/TimberWinR/Outputs/Elasticsearch.cs b/TimberWinR/Outputs/Elasticsearch.cs index 302885e..13c9849 100644 --- a/TimberWinR/Outputs/Elasticsearch.cs +++ b/TimberWinR/Outputs/Elasticsearch.cs @@ -133,6 +133,7 @@ namespace TimberWinR.Outputs else { _sentMessages++; + GC.Collect(); } }); } @@ -140,8 +141,9 @@ namespace TimberWinR.Outputs { LogManager.GetCurrentClassLogger().Error(error); Interlocked.Increment(ref _errorCount); - } + } } + GC.Collect(); } else { @@ -159,6 +161,7 @@ namespace TimberWinR.Outputs } } } + GC.Collect(); System.Threading.Thread.Sleep(_interval); } } diff --git a/TimberWinR/Outputs/Redis.cs b/TimberWinR/Outputs/Redis.cs index 85a3181..0217c84 100644 --- a/TimberWinR/Outputs/Redis.cs +++ b/TimberWinR/Outputs/Redis.cs @@ -198,6 +198,7 @@ namespace TimberWinR.Outputs } } client.EndPipe(); + GC.Collect(); break; } else @@ -216,6 +217,7 @@ namespace TimberWinR.Outputs } } } + GC.Collect(); System.Threading.Thread.Sleep(_interval); } } diff --git a/TimberWinR/Outputs/Stdout.cs b/TimberWinR/Outputs/Stdout.cs index c604ba2..2fbf352 100644 --- a/TimberWinR/Outputs/Stdout.cs +++ b/TimberWinR/Outputs/Stdout.cs @@ -48,7 +48,7 @@ namespace TimberWinR.Outputs JObject[] messages; lock (_locker) { - messages = _jsonQueue.Take(1).ToArray(); + messages = _jsonQueue.Take(_jsonQueue.Count).ToArray(); _jsonQueue.RemoveRange(0, messages.Length); } diff --git a/TimberWinR/Parser.cs b/TimberWinR/Parser.cs index 34b04cb..2d48de4 100644 --- a/TimberWinR/Parser.cs +++ b/TimberWinR/Parser.cs @@ -262,6 +262,8 @@ namespace TimberWinR.Parser public bool SplitLongLines { get; set; } [JsonProperty(PropertyName = "fields")] public List Fields { get; set; } + [JsonProperty(PropertyName = "interval")] + public int Interval { get; set; } public Log() { @@ -269,6 +271,7 @@ namespace TimberWinR.Parser Fields.Add(new Field("LogFilename", "string")); Fields.Add(new Field("Index", "integer")); Fields.Add(new Field("Text", "string")); + Interval = 30; } public void Validate() diff --git a/chocolateyUninstall.ps1.template b/chocolateyUninstall.ps1.template index 726a813..301d058 100644 --- a/chocolateyUninstall.ps1.template +++ b/chocolateyUninstall.ps1.template @@ -1,7 +1,7 @@ $packageName = 'TimberWinR-${version}' # arbitrary name for the package, used in messages $installerType = 'msi' #only one of these: exe, msi, msu $url = 'http://www.ericfontana.com/TimberWinR/TimberWinR-${version}.0.msi' # download url -$silentArgs = '{ABD20B9E-8628-40AD-AB11-5BD4356F9D94} /quiet' +$silentArgs = '{B60FDD3E-615F-42C1-B587-6B46D262EF15} /quiet' $validExitCodes = @(0) #please insert other valid exit codes here, exit codes for ms http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx UnInstall-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" -validExitCodes $validExitCodes