<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>SQL Server According to Bob</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/bobsql/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/bobsql/feed.xml</link>
    <description>Come here for knowledge about SQL Server uniquely provided by the two Bobs at Microsoft</description>
    <lastBuildDate>Tue, 12 Feb 2019 00:37:33 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SQL Server Log Writer Workers</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-log-writer-workers</link>
      <pubDate>Mon, 11 Feb 2019 19:37:32 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3625</guid>
      <description><![CDATA[SQL Server 2017 leverages up to 4 log writer workers, on hidden schedulers, to assist in transaction...]]></description>
      <content:encoded><![CDATA[<p>SQL Server 2017 leverages up to 4 log writer workers, on hidden schedulers, to assist in transaction log processing activities.&nbsp;&nbsp; You may find the number of log write workers has been increased to 8 when running <a href="https://www.microsoft.com/en-us/sql-server/sql-server-2019?&amp;OCID=AID739534_SEM_aPYxsJhV&amp;MarinID=aPYxsJhV_79508514929538_sql%20server%202019%20ctp_be_c__1272135298083179_kwd-79508677900128:loc-190_" target="_blank">newer releases</a> of SQL Server to accommodate larger systems.&nbsp; (Caution: Pre-release software may change before final release.)</p> <p>During SQL Server startup the number of log writer workers is determined.&nbsp; </p> <p>If multiple log write workers are not allowed use a single log writer</p> <p>Otherwise</p> <ul> <li>Total number NUMA nodes * 2</li> <li>Count the number of available CPUs on the NUMA node (affinity mask can impact this count)</li></ul> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Take the smaller of the above calculations and cap by the MAX_LOG_WRITERS allowed (4 or 8 depending on version)</p> <p><font color="#a5a5a5">Bob Dorr</font></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Mysteries: SQL Server Login Timeouts – A Debugging Story</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-mysteries-sql-server-login-timeouts-a-debugging-story</link>
      <pubDate>Sun, 10 Feb 2019 18:49:21 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3615</guid>
      <description><![CDATA[This blog takes you through the debugging journey, refreshing us on old concepts and introducing...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">This blog takes you through the debugging journey, refreshing us on old concepts and introducing some new ones.</font></font></p> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">Reported Symptoms</font></font></h2> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Random connection failures from both SQL Authentication and AD based logins</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Failures occur from remote clients or sqlcmd executed directory on the server (/opt/mssql-tools/bin)</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Unpredictable when failures occur</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Non-yielding scheduler reports</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">SQL Server 2017 CU10 does not show behavior</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">SQL Server 2017 CU12 exhibits the behavior</font></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Server is a Superdome with lots of CPUs and RAM</font></font></font></p> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">Health Session Information</font></font></h2> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">One of the first stops in debugging this issue is the SQL Server health session traces located in the /var/opt/mssql/log/system_health*.xel files. You may view and adjust the XEvent health session from SQL Server Management Studio (SSMS). </font></font></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Watch live data</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Right mouse | Properties to adjust the session</font></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Right mouse | Script Session as …</font></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Several event types are included in the health session, some of which include predicates to remove noise from the system health session.</font></font></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlclr</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">clr_allocation_failure</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlclr</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">clr_virtual_alloc_failure</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">memory_broker_ring_buffer_recorded</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">memory_node_oom_ring_buffer_recorded</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">process_killed</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">scheduler_monitor_deadlock_ring_buffer_recorded</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">scheduler_monitor_non_yielding_iocp_ring_buffer_recorded</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">scheduler_monitor_non_yielding_ring_buffer_recorded</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">scheduler_monitor_non_yielding_rm_ring_buffer_recorded</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">scheduler_monitor_stalled_dispatcher_ring_buffer_recorded</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">scheduler_monitor_system_health_ring_buffer_recorded</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">wait_info</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlos</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">wait_info_external</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlserver</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">connectivity_ring_buffer_recorded</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font style="background-color: #00ffff"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlserver</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">error_reported</font></span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlserver</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">security_error_ring_buffer_recorded</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlserver</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">sp_server_diagnostics_component_result</font></span></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlserver</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">sql_exit_invoked</font></span></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><span style="color:"><span><font face="Calibri"><font style="font-size: 9.5pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><span style="font-family:;color:"><font face="Consolas"><font style="font-size: 9.5pt">sqlserver</font></font></span></font><font face="Consolas"><font style="font-size: 9.5pt"><span style="font-family:;color:"><font color="#808080">.</font></span></font><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#000000">xml_deadlock_report</font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><br><font face="Calibri"><font style="font-size: 11pt" color="#000000">The non-yielding, wait_info* and connectivity events provide the required information for this issue.<span>&nbsp; </span>Looking at the health records the following pattern repeatedly appeared.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><a href="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image0022.jpg"><img title="clip_image002" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;margin: 0px;padding-right: 0px" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image002_thumb2.jpg" width="624" height="48"></a></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">The events logged in the system health show a non-yield beginning, then a login timeout occurring and the non-yield ending.</font></font></p> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><a><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">connectivity_ring_buffer_record</font></font></a></h2> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">Drilling into the connectivity ring buffer record details emerge.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><span><a href="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image0031.png"><img title="clip_image003" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;margin: 0px;padding-right: 0px" border="0" alt="clip_image003" src="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image003_thumb1.png" width="537" height="728"></a></span></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">When a connection attempt fails the <i>type=LoginTimers</i> record is recorded, providing timings for the login activity.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">Starting with the total_login_time_ms = 23390 the events point the failed login attempt of 23.3 seconds.<span>&nbsp; </span>The SSL exchange time was low but the login_trigger_and_resource_governor_ms value consumed the majority of the time.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">The find_login_ms event was another consumer and is child of the login_trigger_and_resource_governor_ms.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font face="Calibri"><font color="#000000"><i><font style="font-size: 11pt">How would one know which timings are parent or child values?</font></i><font style="font-size: 11pt"><span>&nbsp; </span>Looking at the LoginTimer ring buffer entry you uncover the relationships.</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font face="Consolas"><span><span style="font-family:;color:"><font color="#0000ff"><font style="font-size: 9.5pt">select</font></font></span></span><font style="font-size: 9.5pt"><span><span style="font-family:;color:"><font color="#000000"> </font></span></span><span><span style="font-family:;color:"><font color="#808080">*</font></span></span><span><span style="font-family:;color:"><font color="#000000"> </font></span></span><span><span style="font-family:;color:"><font color="#0000ff">from</font></span></span><span><span style="font-family:;color:"><font color="#000000"> </font></span></span></font><span><span style="font-family:;color:"><font style="font-size: 9.5pt" color="#538135">sys.dm_os_ring_buffers</font></span></span></font><span><span style="font-family:;color:"></span></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Consolas"><span><span style="font-family:;color:;line-height: 10pt"><span><font color="#000000"><font style="font-size: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font style="font-size: 9.5pt"><span><span style="font-family:;color:;line-height: 10pt"><font color="#0000ff">where</font></span></span><span><span style="font-family:;color:;line-height: 10pt"><font color="#000000"> ring_buffer_type </font></span></span><span><span style="font-family:;color:;line-height: 10pt"><font color="#808080">=</font></span></span><span><span style="font-family:;color:;line-height: 10pt"><font color="#000000"> </font></span></span></font><span><span style="font-family:;color:;line-height: 10pt"><font style="font-size: 9.5pt" color="#ff0000">'RING_BUFFER_CONNECTIVITY'</font></span></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span><font face="Times New Roman"><font style="font-size: 12pt" color="#000000">The ring buffer, XML format outputs the parent and child relationships.<span>&nbsp;&nbsp; </span>This LoginTimes snippet shows the timing information (full record contains additional information for SSL, SSPI, reads, writes, etc.)</font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><font face="Times New Roman"><font style="font-size: 12pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">&lt;Record id="2" type="RING_BUFFER_CONNECTIVITY" time="591262106"&gt;</font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">&lt;ConnectivityTraceRecord&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;RecordType&gt;<span><font style="background-color: #00ffff">LoginTimers</font></span>&lt;/RecordType&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;<span><font style="background-color: #00ffff">LoginTimersInMilliseconds</font></span>&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;TotalTime&gt;<span><font style="background-color: #00ffff">23309</font></span>&lt;/TotalTime&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;EnqueueTime&gt;0&lt;/EnqueueTime&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;NetWritesTime&gt;0&lt;/NetWritesTime&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;NetReadsTime&gt;0&lt;/NetReadsTime&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;<span><font style="background-color: #00ffff">TriggerAndResGovTime</font></span>&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;TotalTime&gt;<span><font style="background-color: #00ffff">23266</font></span>&lt;/TotalTime&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span><font style="font-size: 9pt;background-color: #00ffff">&lt;FindLogin&gt;23265&lt;/FindLogin&gt;</font></span></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;LogonTriggers&gt;0&lt;/LogonTriggers&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;ExecClassifier&gt;0&lt;/ExecClassifier&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;SessionRecover&gt;0&lt;/SessionRecover&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;/TriggerAndResGovTime&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">&lt;/LoginTimersInMilliseconds&gt;</font></font></font></span></span></p> <p class="MsoNormalCxSpLast" style="margin-left: 0.5in;line-height: normal"><span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">&lt;/ConnectivityTraceRecord&gt;</font></font></font></span></span></p><span style="line-height: normal"></span> <p class="MsoNoSpacing" style="margin: 0in 0in 0pt;line-height: normal"><font face="Calibri"><font style="font-size: 11pt" color="#000000">This information quickly rules out a login trigger or classifier function as the cause of the problem.<span>&nbsp; </span>As you might imagine from the name SQL Server is looking up the login information and contacting the AD if necessary, as part of the login validation.<span>&nbsp; </span>This means we are reading database pages from the master, acquiring locks, and making calls to the domain controller (DC/KDC.)</font></font><br><br></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">wait_info*</font></font></h3> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><span><font face="Calibri"><font color="#000000"><font style="font-size: 11pt">Another observation is that the system health session did not conatain wait_info* events longer than 5-seconds.<span>&nbsp; </span>The lack of wait_info* events is revealing because if we are waiting for a database read, lock or preemptive, external call for more than 5 seconds an event would have been logged.<span>&nbsp;&nbsp; </span>This means that we are unlikely encountering issues with database reads, locking or a preemptive, external call.</font><span><font style="font-size: 11pt">&nbsp; </font></span></font></font><br><br></span></h2> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">Network Trace</font></font></h2> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">Looking at network traces helps build our understanding of the problem.</font></font><br><br></span><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">Normal SQL Login, execute select @@VERSION and logout</font></font></h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Here is an example of a valid SQL Server login.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">SYN</font></font><a href="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image005.jpg"><img title="clip_image005" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;margin: 0px;padding-right: 0px" border="0" alt="clip_image005" src="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image005_thumb.jpg" width="624" height="433"></a></span></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">1.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">TCP connection establishment from the ODBC CLIENT to the LINUX SQL SERVER (SYN)</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">2.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">TDS pre-login exchange</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">3.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">512 byte response (use database context xxxxxx, default language xxxxxxx, test size xxxxx)</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">4.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">SQLBatch (select @@VERSION)</font></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">5.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">FIN – Close of TCP connection | Disconnect</font></font></font></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">Failing Login</font></font></h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Here is an example of a failed SQL Server login.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><a href="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image007.jpg"><img title="clip_image007" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;margin: 0px;padding-right: 0px" border="0" alt="clip_image007" src="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image007_thumb.jpg" width="624" height="224"></a></span></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">1.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">TCP connection establishment from the ODBC CLIENT to the LINUX SQL SERVER (SYN)</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">2.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">TDS pre-login exchange</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">3.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Login response</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">4.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Keep alive kicks in and time begins to elapse without other activity</font></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">5.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">RST – TCP connection is reset by client (OS Error: 10054)</font></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">There were several failure variations but the most common waits occurred handling the login response.</font></font></p> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">Network Layer Overloaded</font></font></h2> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">In contrast to the failing SQL Server login, this is what a network trace looks like when the network layer becomes overloaded and is not completing requests to the SQL Server.<span>&nbsp; </span>Usually, you start seeing retransmission of the SYN.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><a href="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image009.jpg"><img title="clip_image009" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;margin: 0px;padding-right: 0px" border="0" alt="clip_image009" src="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image009_thumb.jpg" width="624" height="40"></a></span></p> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">Attempting A Reproduction</font></font></h2> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font color="#000000" face="Calibri"><font style="font-size: 11pt">Now we have an idea about the pattern, a reproduction would be helpful to track the problem and make sure it is properly resolved.<span>&nbsp; </span>This is where my old friend (</font></font><font style="font-size: 11pt"><a><font color="#0563c1" face="Calibri"><u>ostress</u></font></a></font><font face="Calibri"><font style="font-size: 11pt" color="#000000">) came in handy.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">"C:\Program Files\Microsoft Corporation\RMLUtils\ostress" -Usa -Pxxxxxxx <span>&nbsp;</span>-Q"--" -Stcp:10.193.17.114 -q -n64 -r99999999 -cc:\temp\sample.ini -T146 -oc:\temp\output</font></font></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Use -U and -P for SQL authentication</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Use -E for AD authentication</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-q ignores query results</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-S target server name forcing tcp protocol</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-Q with a query of --<span>&nbsp; </span>(comment only to do nothing)</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-n controls the number of threads</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-r controls the number of loops for each thread</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-c the control file</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-T146 disable encrypted TDS</font></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">-</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">-o output location</font></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.25in;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">In the control file set DisconnectPct=100.0.<span>&nbsp; </span>This directs ostress to connect, execute the query --, disconnect 100% of the time and then repeat -r times for each of the -n threads.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.25in;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Tracing XEvent login and logout events you can see the connect and disconnect activities.<span>&nbsp; </span>The following is a simple query for looking at the rate of login and logouts the test is accomplishing.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">drop table #before<br>go<br>drop table #after<br>go</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">select * into #before <br>from sys.dm_os_performance_counters where counter_name in ('Logins/sec', 'Logouts/sec')</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">waitfor delay '00:00:10'</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">select * into #after<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>from sys.dm_os_performance_counters where counter_name in ('Logins/sec', 'Logouts/sec')</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">select b.object_name, a.cntr_value - b.cntr_value as [diff], (a.cntr_value - b.cntr_value) / 10.0 as [Rate/sec]<br><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>from #before b<br><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>inner join #after a on a.counter_name = b.counter_name</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">I started with a cmd file script exercising the connection path.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">start "ostress" "C:\Program Files\Microsoft Corporation\RMLUtils\ostress" -E -Q"--" -Stcp:xxxxxxx -q -n32 -r99999999 -cc:\temp\sample.ini -T146 -oc:\temp\output</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">start "ostress" "C:\Program Files\Microsoft Corporation\RMLUtils\ostress" -E -Q"--" -Stcp:xxxxxxx -q -n32 -r99999999 -cc:\temp\sample.ini -T146 -oc:\temp\output2</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">:top</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">sqlcmd -E -Stcp:xxxxxxx -Q"select @@VERSION"</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">ping -n 10 xxxxxxxx</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">goto top</font></font></span></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">Windows TCP Settings</font></font></h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">As I cranked up the stress level on a 2TB, 144CPU system I hit some TCP issues.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Running along and all the sudden no traffic occurring at the SQL Server for a few seconds, then stress kicked back in.<span>&nbsp;&nbsp; </span>During the downturn in activity a local /opt/mssql-tools/bin/sqlcmd connection continued to work.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">I started using the following bash script running locally on the Linux SQL Server system to see successful connections while the remote connections were failing.</font></font></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">while [ 1 -gt 0 ]</font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">do</font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">echo</font></font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">echo $(date)</font></font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">./sqlcmd -Usa -Pxxxxxxx -Q"select @@VERSION" -Stcp:.</font></font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">sleep 2</font></font></font></span></p> <p class="MsoNormalCxSpMiddle" style="margin-left: 0.5in;line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">done</font></font><br><br></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">The stall and go behavior occurred because I was running out of Windows client TCP ports.<span>&nbsp; </span>Using netsh we adjusted the client port range and the stop and go behavior went away.</font><span></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt"><span><font face="Courier New"><font style="font-size: 9pt" color="#000000">netsh int ipv4 show dynamicport tcp<br>netsh int ipv6 show dynamicport tcp</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 0.5in;line-height: normal"><span><font face="Courier New"><font style="font-size: 9pt" color="#000000">netsh int ipv4 set dynamicport tcp start=10000 num=50000<br>netsh int ipv6 set dynamicport tcp start=10000 num=50000</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Now I began driving high levels of connect and disconnect operations until I started seeing network saturation (SYN with retransmits) but I was not seeing the non-yield pattern.</font></font></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">Disrupt The Domain Controller (keytab)</font></font></h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Knowing the find login path was doing domain controller calls the next thing I did was <b>pause the domain controller VM and poof – non-yielding occurred with connection timeouts, high times recorded in find login</b>.<span>&nbsp; </span>My collogue was able to add entries to the keytab file (invalid DC targets) that exhibited long KDC/DC query behavior as well.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">We then found a few code paths in find login that did not switch to preemptive before making a call to SSSD or LDAP for Linux, AD activities.<span>&nbsp;&nbsp; </span>Since SQL Server did not switch preemptive there is no wait_type* records in the system health log.</font></font></p> <h2 style="margin: 2pt 0in 0pt;line-height: 14pt"><font face="Calibri Light"><font style="font-size: 13pt" color="#2f5496">Non-Yielding Scheduler</font></font></h2> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Non-yielding is the key to the issue and the associated behaviors.<span>&nbsp; </span>The following diagram help highlight the problems experienced.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt" align="center"><span><a href="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image0111.png"><img title="clip_image011" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="clip_image011" src="https://msdnshared.blob.core.windows.net/media/2019/02/clip_image011_thumb1.png" width="364" height="299"></a></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">&nbsp;</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">The owning worker made a call to the domain controller without switching off the SQL Server scheduler (preemptive.)<span>&nbsp; </span>You have a SQL authentication and AD authentication workers part of the way through the pre-login sequence and yielded.<span>&nbsp; </span>When the owning worker yields the runnable list is used to determine the next worker to execute.<span>&nbsp; </span>When the runnable list has reached max workers for the scheduler new requests are queued.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">The KDC/DC query is taking more than 5 seconds and SchedulerMonitor (one per NUMA node) reports a non-yielding condition (BEGIN).<span>&nbsp;&nbsp; </span>Every 5 seconds the SchedulerMonitor checks progress, incrementing a pass count.<span>&nbsp; </span>When that pass count has reached the limit (12 == 60 seconds) a non-yielding situation is reported.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">In the customer’s case the non-yield generally lasted 5 to 15 seconds, reported in the system health session with non-yielding BEGIN and END events bracketing connection timeout events.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Various login timeouts are then triggered.<span>&nbsp; </span>When the client detects the connection, timeout is reached the FIN is sent to close the TCP connection, usually bubbling up to SQL Server as error 10054 – connection closed.</font></font></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">If the login was in the middle of processing pre-login the ring buffer entry may show time spent in SSL, reads, etc and the disconnect. </font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">If the login was stuck on the DC call the time generally accumulates in find login.</font><span><font style="font-size: 11pt">&nbsp; </font></span></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">If the login was queued to the scheduler you see 1 or 0ms elapsed times for login failure events. By the time the a worker was allowed to pick up the new task the client has already sent the 10054 and as soon as SQL Server attempts to process the login the connection is detected as closed and fails.</font></font></font></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">SQL Authentication Impact</font></font></h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Now you can see how an AD authentication could lead to SQL authentication, login timeouts.<span>&nbsp; </span>If the SQL authentication request was on the same scheduler as the stalled KDC/DC query the quest is impacted.</font></font></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><font face="Calibri Light"><font style="font-size: 12pt" color="#1f3763">Other Schedulers Impacted</font></font></h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">This code path does not engage in much SQL locking so a stalled user running the KDC/DC query usually does not impact other schedulers and the logins associated with those schedulers.<span>&nbsp;&nbsp; </span>Other schedulers are impacted by the KDC/DC query in two ways.</font></font></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">1.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">If other schedulers are trying to process AD logins and the KDC/DC queries are slow the queries are likely to encounter the same behavior.</font></font></font><br><br></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span><span><font face="Calibri"><font style="font-size: 11pt">2.</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">If a non-yield is detected a dump is invoked.<span>&nbsp; </span>The dump suspends the SQL Server process.<span>&nbsp; </span>If the dump time exceeded the login timeout the client closes the connection and you commonly see a burst of 10054 TCP errors across the SQL Server schedulers.</font></font></font></p> <h1 style="margin: 12pt 0in 0pt;line-height: 17pt"><font face="Calibri Light"><font style="font-size: 16pt" color="#2f5496">Recap</font></font></h1> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font color="#000000"><font style="font-size: 11pt">The bug is in the find login code not going preemptive before querying the domain controller, leading to delays and login timeouts.</font><span><font style="font-size: 11pt">&nbsp; </font></span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">When fixed, individual AD login attempts still encounter login timeouts when experiencing delays from the KDC/DC query, but other logins and queries are no longer impacted.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">&nbsp;</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span style="color:;line-height: 10pt"><font face="Calibri"><font style="font-size: 9pt" color="#808080">Bob Dorr</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span style="color:;line-height: 10pt"><font face="Calibri"><font color="#808080" size="3">Thank to test folks for helping track down and correct this issue.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span style="color:;line-height: 10pt"><font face="Calibri"><font color="#808080" size="3">Dylan Gray, Mike Habben, Mitchell Sternke, Val Menn, Kapil Thacker, Ben Ko, Madeline MacDonald, and Ethan Moffat</font></font></span></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Worker Thread Default Calculation</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-worker-thread-default-calculation</link>
      <pubDate>Sun, 10 Feb 2019 14:05:13 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3485</guid>
      <description><![CDATA[SQL Server 2017 introduced a small change to SQL Server’s default worker thread calculation,...]]></description>
      <content:encoded><![CDATA[<p>SQL Server 2017 introduced a small change to SQL Server’s default worker thread calculation, accounting for smaller environments.&nbsp;&nbsp; When running on smaller environments SQL Server reduces the worker target. <p>For an X64 installation, using the sp_configure ‘max worker threads’ value of 0 SQL Server uses the following calculation. <p><a href="https://msdnshared.blob.core.windows.net/media/2019/02/defaults.jpg"><img title="defaults" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="defaults" src="https://msdnshared.blob.core.windows.net/media/2019/02/defaults_thumb.jpg" width="405" height="109"></a> <p>On small environments SQL Server always uses 256 as the target. <p>Running on a larger environment 512 workers are the default and are adjusted based on CPUs count. <p><a href="https://msdnshared.blob.core.windows.net/media/2019/02/1632.jpg"><img title="1632" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="1632" src="https://msdnshared.blob.core.windows.net/media/2019/02/1632_thumb.jpg" width="455" height="134"></a> <p>When more than 4 CPUs are present additional the worker limit is increased from the 512 worker level to 512 plus the remaining CPUs times 32 or 16.&nbsp; The additional worker level is increased by 32 workers per CPU when the system presents 64 or more CPUs. <p>The design takes into account smaller environments which few CPU and Memory resources as well as larger CPU and Memory systems. <p>The worker calculation only applies to visible schedulers.&nbsp; Hidden schedulers and the Dedicated Admin Connection (DAC) schedulers are not impacted by the calculation. <p><font color="#cccccc" size="1">Bob Dorr</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Viewing and Sorting XEvents Efficiently (Code Samples) - XEProfiler</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/viewing-and-sorting-xevents-efficiently-code-samples-xeprofiler</link>
      <pubDate>Mon, 31 Dec 2018 16:47:03 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3435</guid>
      <description><![CDATA[I was doing backups and clean-ups and ran across a couple of sample projects for XEvent and...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">I was doing backups and clean-ups and ran across a couple of sample projects for XEvent and event_sequence processing I thought others might find helpful. – Enjoy!</font></font></p> <table class="MsoTableGrid" style="border-top: medium none;border-right: medium none;background: #ffe599;border-collapse: collapse;border-bottom: medium none;border-left: medium none;line-height: normal" cellspacing="0" cellpadding="0" border="1"> <tbody> <tr style="height: 3.5pt"> <td style="border-top: windowtext 1pt solid;border-right: windowtext 1pt solid;border-bottom: windowtext 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: windowtext 1pt solid;padding-right: 5.4pt" height="4" valign="top" width="623"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><i><font face="Calibri"><font style="font-size: 11pt" color="#000000">The sample <span>code</span> is provided "as is" and any express or implied warranties, including the implied warranties of merchantability and fitness for a particular <span>purpose,</span> are disclaimed.</font></font></i></b></p></td></tr></tbody></table> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><br><font face="Calibri"><font style="font-size: 11pt" color="#000000">In my previous <span>blog posts,</span> I highlighted the importance of <b>using Event Sequence </b>as the <span>sort</span> key.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><font color="#0563c1"><font style="font-weight: bold" size="2" face="Calibri"><u><a href="https://blogs.msdn.microsoft.com/psssql/2014/07/25/how-it-works-xevent-output-and-visualization/" target="_blank">How It Works: XEvent Output and Visualization</a></u></font></font><br></span><span><a href="https://blogs.msdn.microsoft.com/bobsql/2017/12/26/sql-server-management-studio-provides-xe-profiler/" target="_blank"><font size="2" face="Calibri"><strong>SQL Server Management Studio Provides–“XE Profiler”</strong></font></a><font color="#0563c1"><font style="font-weight: bold"><u></u></font></font><br></span><span><a href="https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/use-the-ssms-xe-profiler?view=sql-server-2017" target="_blank"><font size="2" face="Calibri"><strong>Use the SSMS XEvent Profiler</strong></font></a><font face="Times New Roman"><font color="#0563c1"><u></u></font></font></span><span></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Some of the feedback has been that sorting can be a cumbersome operation because:</font></font></p> <ul> <li> <div class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font color="#000000"><font face="Calibri"><font style="font-size: 11pt">Using <a href="https://docs.microsoft.com/en-us/sql/relational-databases/system-functions/sys-fn-xe-file-target-read-file-transact-sql?view=sql-server-2017" target="_blank">sys.fn_xe_file_target_read_file</a></font></font></font><font style="font-size: 11pt"><font color="#0563c1" face="Calibri"><u></u></font></font><font face="Calibri"><font style="font-size: 11pt" color="#000000"> the XML has to be queried and indexed which can take time and space, followed by the order by event sequence query</font></font></div> <li> <div class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font color="#000000"><font face="Calibri"><font style="font-size: 11pt">Using SQL Server Management Studio (SSMS) and storing the events in a table requires reading the events, streaming to table storage followed by an order by event sequence </font><span><font style="font-size: 11pt">query</font></span></font></font></div> <li> <div class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font color="#000000"><font face="Calibri"><span></span></font></font><font color="#000000"><font face="Calibri"><font style="font-size: 11pt">Large traces can encounter the 32-bit SSMS memory limitations</font></font></font></div></li></ul> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Several years ago, I created <span>a XEProfiler</span> based loosely on the SSMS implementation, built as a <span>64-bit</span> application to avoid the <span>32-bit</span> memory limitations and <span>using</span> parallel activities to speed up the processing.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image107.png"><img title="image" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb93.png" width="155" height="91"></a></p> <h5><font style="font-weight: bold">The XEProfiler Sample</font></h5> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Creates <span>an</span> empty DataGrid control</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Makes a pass over the files to obtain the Event Locators</font></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Sorts the <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.sqlserver.xevent.linq.eventlocator?view=sqlserver-2016" target="_blank">EventLocators</a></font></font></font><font face="Calibri"><font style="font-size: 11pt" color="#0563c1"><u></u></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><span style="font-family:"><span><font face="Symbol"><font style="font-size: 11pt">·</font></font><span style="font-family:;line-height: normal"><font face="Times New Roman"><font style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></span><font face="Calibri"><font style="font-size: 11pt">Leverages the display location to paint the information on the screen</font></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000">Note: By tracking and using Event<span>Locators,</span> the overall memory is reduced, and the 64-bit address space allows for a larger set of trace data.</font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><a href="https://msdnshared.blob.core.windows.net/media/2018/12/clip_image0029.jpg"><img title="clip_image002" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2018/12/clip_image002_thumb5.jpg" width="628" height="193"></a></span></p> <h5><font style="font-weight: bold">TSQL Sample Session</font></h5> <blockquote> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font size="2"><span style="font-family:;color:"><font color="#0000ff"><font face="Courier New">CREATE</font></font></span><font face="Courier New"><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">EVENT</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">SESSION</font></span><span style="font-family:;color:"><font color="#000000"> [EventSequence] </font></span><span style="font-family:;color:"><font color="#0000ff">ON</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font></font><font size="2"><span style="font-family:;color:"><font color="#0000ff" face="Courier New">SERVER<br></font></span><font face="Courier New"><span style="font-family:;color:"><font color="#0000ff">ADD</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">EVENT</font></span><span style="font-family:;color:"><font color="#000000"> sqlserver</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">sql_batch_completed</font></span></font></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#808080">(<br></font></span><span style="font-family:;color:"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span></span><span style="font-family:;color:"><font color="#0000ff">ACTION</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">package0</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">event_sequence</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">sqlserver</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">client_app_name</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">sqlserver</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">session_id</font></span></font></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#808080">)),<br></font></span><span style="font-family:;color:"><font color="#0000ff">ADD</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">EVENT</font></span><span style="font-family:;color:"><font color="#000000"> sqlserver</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">sql_batch_starting</font></span></font></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#808080">(<br></font></span><span style="font-family:;color:"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span></span><span style="font-family:;color:"><font color="#0000ff">ACTION</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">package0</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">event_sequence</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">sqlserver</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">client_app_name</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">sqlserver</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">session_id</font></span></font></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#808080">))<br></font></span><span style="font-family:;color:"><font color="#0000ff">ADD</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">TARGET</font></span><span style="font-family:;color:"><font color="#000000"> package0</font></span><span style="font-family:;color:"><font color="#808080">.</font></span><span style="font-family:;color:"><font color="#000000">event_file</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#0000ff">SET</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">filename</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#ff0000">N'c:\temp\EventSequence'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">max_file_size</font></span><span style="font-family:;color:"><font color="#808080">=(</font></span><span style="font-family:;color:"><font color="#000000">1024</font></span><span style="font-family:;color:"><font color="#808080">),</font></span><span style="font-family:;color:"><font color="#000000">max_rollover_files</font></span><span style="font-family:;color:"><font color="#808080">=(</font></span><span style="font-family:;color:"><font color="#000000">100</font></span></font></font><font size="2"><font face="Courier New"><span style="font-family:;color:"><font color="#808080">))<br></font></span><span style="font-family:;color:"><font color="#0000ff">WITH </font></span></font><font face="Courier New"><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">MAX_MEMORY</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000">1024 MB</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">EVENT_RETENTION_MODE</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000">ALLOW_SINGLE_EVENT_LOSS</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">MAX_DISPATCH_LATENCY</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000">30 SECONDS</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">MAX_EVENT_SIZE</font></span><span style="font-family:;color:"><font color="#808080">=</font></span></font></font><font size="2"><font face="Courier New"><span style="font-family:;color:"><font color="#000000">0<br>KB</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">MEMORY_PARTITION_MODE</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000">PER_CPU</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">TRACK_CAUSALITY</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#0000ff">ON</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">STARTUP_STATE</font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#0000ff">OFF</font></span></font><span style="font-family:;color:"><font color="#808080" face="Courier New">)</font></span></font></p></blockquote> <h5><font style="font-weight: bold">Form1.cs</font></h5> <blockquote> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System.Collections.Generic;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System.Drawing;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System.IO;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System.Linq;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System.Threading;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">using System.Threading.Tasks;<br></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">using System.Windows.Forms;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">using Microsoft.SqlServer.XEvent.Linq;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">namespace XEProfiler<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000" size="2">{<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp; </span>public partial class xeProfilerForm : Form<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Event locator index needs<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private class LocationInfo<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public QueryableXEventData Stream<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>get;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private set;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public EventLocator Location<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>get;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private set;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public <span>ulong</span> Sequence<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>get;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private set;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// File can consume memory - for sample purposes only<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public string File<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>get;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private set;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public LocationInfo(string file, ulong sequence, EventLocator location, QueryableXEventData stream)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>File = file;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Sequence = sequence;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Location = location;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Stream = stream;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private SolidBrush textBrush;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private Font textFont;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private StringFormat stringFormat = new StringFormat();<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private LocationInfo[] sortedLocators = null;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Constructor to make display loop a bit like SQL Profiler<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>public xeProfilerForm()<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>InitializeComponent();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>stringFormat.Alignment = StringAlignment.Near;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>stringFormat.LineAlignment = StringAlignment.Near;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>stringFormat.FormatFlags = StringFormatFlags.NoWrap;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>textBrush = new SolidBrush(Color.Black);<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>textFont = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.RowHeadersWidth = 10;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.AllowUserToAddRows = false;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.CellPainting += DataGrid_CellPainting;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// TODO: Make this meta data driven with targets for fields vs actions to remove need for switch statement<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>string[] ColIndexNames = { "timestamp", "event_sequence", "name", "batch_text", "event_file" };</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Draw the proper text for the current display region<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private void DataGrid_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (e.ColumnIndex &gt; -1 &amp;&amp; e.RowIndex &gt; -1)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>e.PaintBackground(e.ClipBounds, false);<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>LocationInfo info = sortedLocators[e.RowIndex];<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>PublishedEvent pubEvent = info.Stream.EventProvider.RetrieveEvent(info.Location);<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>PublishedAction action;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>PublishedEventField field;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>string strText = string.Empty;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>switch (e.ColumnIndex)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>case 0:<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>strText = pubEvent.Timestamp.UtcDateTime.ToString();<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>break;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>case 1:<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (pubEvent.Actions.TryGetValue(ColIndexNames[e.ColumnIndex], out action))<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>strText = action.Value.ToString();<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>break;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>case 2:<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>strText = pubEvent.Name;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>break;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>case 3:<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (pubEvent.Fields.TryGetValue(ColIndexNames[e.ColumnIndex], out field))<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>strText = field.Value.ToString();<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>break;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>case 4:<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>strText = info.File;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>break;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><span><font face="Courier New"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font></span></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>e.Graphics.DrawString(strText, textFont, textBrush, e.CellBounds, stringFormat);<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>e.Handled = true;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Load the event locators and activate the display<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private void Form1_Load(object sender, EventArgs e)<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Enabled = false;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>string[] files = Directory.GetFiles(@"c:\temp", @"EventSequence*", SearchOption.TopDirectoryOnly);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>object locationLock = new object();<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>int rows = 0;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>List&lt;LocationInfo&gt; eventLocators = new List&lt;LocationInfo&gt;();</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Load the EventLocators in parallel<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Parallel.ForEach (files, file<span>&nbsp; </span>=&gt;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>LoadEvents(ref rows, ref locationLock, ref eventLocators, file);<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>});</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Get array sorted by sequence values, allowing parallel Linq activities<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>sortedLocators = (from locator in eventLocators select locator)<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>.OrderBy(x =&gt; x.Sequence)<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>.ToArray();</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>SetRowCount(rows, true);<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Load the events into the list to be sorted and used as index for display<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private void LoadEvents(ref int rows, ref object locationLock, ref List&lt;LocationInfo&gt; eventLocators, string file)<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>string fileName = Path.GetFileNameWithoutExtension(file);</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Open and track the stream so we can use later to access event data<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>QueryableXEventData stream = new QueryableXEventData(file);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>foreach</span> (PublishedEvent <span>pubEvent</span> in <span>stream</span>)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;</span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Sequence may have holes due to options such as Event Loss<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// All events must be read before final sort can be closed.<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ulong sequence = (ulong)pubEvent.Actions["event_sequence"].Value;<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>EventLocator locator = pubEvent.Location;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>LocationInfo info = new LocationInfo(fileName, sequence, locator, stream);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>lock (locationLock)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>eventLocators.Add(info);<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Simple progress<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>int rowCount = Interlocked.Increment(ref rows);<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (rowCount % 128 == 0)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp; </span>SetRowCount(rowCount, false);<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Once row count is complete display headers (TODO: based on metadata)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// and update the rowcount in status bar<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private void SetRowCount(int rows, bool finished)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>toolStripRowCount.Text = String.Format("{0}", rows);<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>toolStripRowCount.Invalidate();</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (finished)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>textBoxDisplay.Text = String.Empty;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Columns.Clear();</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>DataGridViewColumn newColumn = new DataGridViewTextBoxColumn();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Name = "timestamp";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.HeaderText = "timestamp";<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.ToolTipText = "Timestamp of the captured event";<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Columns.Add(newColumn);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn = new DataGridViewTextBoxColumn();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Name = "sequence";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.HeaderText = "sequence";<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.ToolTipText = "Event sequence of the captured event";<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Columns.Add(newColumn);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn = new DataGridViewTextBoxColumn();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Name = "name";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.HeaderText = "name";<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.ToolTipText = "Name of the captured event";<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Columns.Add(newColumn);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn = new DataGridViewTextBoxColumn();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Name = "batch_text";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.HeaderText = "batch_text";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.ToolTipText = "Batch text";<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Width = 200;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Columns.Add(newColumn);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn = new DataGridViewTextBoxColumn();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Name = "file";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.HeaderText = "file";<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.ToolTipText = "Event source file";<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>newColumn.Width = 200;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Columns.Add(newColumn);</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<span>&nbsp; </span>Change the <span>dataGrid</span> to an OwnerDraw (OnPaint) so we only have to<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<span>&nbsp; </span>draw the data and not really load it into the data grid rows<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.RowCount = rows;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (rows &gt; 0)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Rows[1].Selected = true;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Enabled = true;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>dataGrid.Invalidate();<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp; </span>dataGrid.Refresh();<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Batch text display<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>//<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>private void dataGrid_SelectionChanged(object sender, EventArgs e)<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>textBoxDisplay.Text = String.Empty;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (0 != dataGrid.SelectedRows.Count)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>List&lt;DataGridViewRow&gt; orderedSelection = (from DataGridViewRow row in dataGrid.SelectedRows select row)<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>.OrderBy(x=&gt;x.Index)<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>.ToList();</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>foreach (DataGridViewRow selectedRow in orderedSelection)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (textBoxDisplay.Text != String.Empty)<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>textBoxDisplay.Text += "\r\ngo\r\n";<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>LocationInfo info = sortedLocators[selectedRow.Index];<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>PublishedEvent pubEvent = info.Stream.EventProvider.RetrieveEvent(info.Location);<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>PublishedEventField field;<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>string strText = string.Empty;</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if (pubEvent.Fields.TryGetValue("batch_text", out field))<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<br></font></font></font></span><font size="2"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>strText = field.Value.ToString();<br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000">&nbsp;</font></font></span></font></p> <p class="MsoNormalCxSpMiddle" style="line-height: normal"><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>textBoxDisplay.Text += strText;<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp; </span>}<br></font></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000"><font size="2">}</font><br></font></font></span><span style="font-family:;line-height: 10pt"><font face="Courier New"><font style="font-size: 9pt" color="#000000">&nbsp;</font></font></span></p></blockquote> <h5><font style="font-weight: bold">Form1.Designer.cs</font></h5> <blockquote> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><font size="2" face="Courier New">namespace XEProfiler<br>{<br>&nbsp;&nbsp;&nbsp; partial class xeProfilerForm<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Required designer variable.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.ComponentModel.IContainer components = null;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Clean up any resources being used.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override void Dispose(bool disposing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (disposing &amp;&amp; (components != null))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; components.Dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.Dispose(disposing);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #region Windows Form Designer generated code</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Required method for Designer support - do not modify<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// the contents of this method with the code editor.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void InitializeComponent()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(xeProfilerForm));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid = new System.Windows.Forms.DataGridView();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar = new System.Windows.Forms.StatusStrip();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.labelRowCount = new System.Windows.Forms.ToolStripStatusLabel();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolStripRowCount = new System.Windows.Forms.ToolStripStatusLabel();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1 = new System.Windows.Forms.MenuStrip();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.windowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay = new System.Windows.Forms.TextBox();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1 = new System.Windows.Forms.SplitContainer();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).BeginInit();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.SuspendLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.SuspendLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel1.SuspendLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel2.SuspendLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.SuspendLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.SuspendLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // dataGrid<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.AllowUserToAddRows = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.AllowUserToDeleteRows = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.AllowUserToOrderColumns = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.DefaultCellStyle = dataGridViewCellStyle1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.Location = new System.Drawing.Point(0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.Name = "dataGrid";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.ReadOnly = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.RowHeadersDefaultCellStyle = dataGridViewCellStyle2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.RowTemplate.Height = 18;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.Size = new System.Drawing.Size(1089, 277);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.TabIndex = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.dataGrid.SelectionChanged += new System.EventHandler(this.dataGrid_SelectionChanged);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // statusBar<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.labelRowCount,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolStripRowCount});<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.Location = new System.Drawing.Point(0, 479);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.Name = "statusBar";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.Size = new System.Drawing.Size(1089, 22);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.TabIndex = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.Text = "statusBar";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // labelRowCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.labelRowCount.Name = "labelRowCount";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.labelRowCount.Size = new System.Drawing.Size(41, 17);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.labelRowCount.Text = "Rows: ";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // toolStripRowCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolStripRowCount.Name = "toolStripRowCount";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolStripRowCount.Size = new System.Drawing.Size(108, 17);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolStripRowCount.Text = "toolStripRowCount";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // menuStrip1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.fileToolStripMenuItem,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.editToolStripMenuItem,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.viewToolStripMenuItem,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolsToolStripMenuItem,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.windowToolStripMenuItem,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.helpToolStripMenuItem});<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.Location = new System.Drawing.Point(0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.Name = "menuStrip1";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.Size = new System.Drawing.Size(1089, 24);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.TabIndex = 2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.Text = "menuStrip1";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // fileToolStripMenuItem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.fileToolStripMenuItem.Text = "File";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // editToolStripMenuItem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.editToolStripMenuItem.Name = "editToolStripMenuItem";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.editToolStripMenuItem.Text = "Edit";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // viewToolStripMenuItem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.viewToolStripMenuItem.Text = "View";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // toolsToolStripMenuItem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 20);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.toolsToolStripMenuItem.Text = "Tools";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // windowToolStripMenuItem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.windowToolStripMenuItem.Name = "windowToolStripMenuItem";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.windowToolStripMenuItem.Size = new System.Drawing.Size(63, 20);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.windowToolStripMenuItem.Text = "Window";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // helpToolStripMenuItem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.helpToolStripMenuItem.Text = "Help";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // textBoxDisplay<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.Dock = System.Windows.Forms.DockStyle.Fill;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.HideSelection = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.Location = new System.Drawing.Point(0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.Multiline = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.Name = "textBoxDisplay";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.ReadOnly = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.ScrollBars = System.Windows.Forms.ScrollBars.Both;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.Size = new System.Drawing.Size(1089, 174);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.textBoxDisplay.TabIndex = 3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // splitContainer1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Location = new System.Drawing.Point(0, 24);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Name = "splitContainer1";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // splitContainer1.Panel1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel1.Controls.Add(this.dataGrid);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel1MinSize = 150;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // splitContainer1.Panel2<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel2.Controls.Add(this.textBoxDisplay);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel2MinSize = 150;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Size = new System.Drawing.Size(1089, 455);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.SplitterDistance = 277;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.TabIndex = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // xeProfilerForm<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.ClientSize = new System.Drawing.Size(1089, 501);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Controls.Add(this.splitContainer1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Controls.Add(this.statusBar);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Controls.Add(this.menuStrip1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.MainMenuStrip = this.menuStrip1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Name = "xeProfilerForm";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Text = "XEProfiler";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.WindowState = System.Windows.Forms.FormWindowState.Maximized;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Load += new System.EventHandler(this.Form1_Load);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.ResumeLayout(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.statusBar.PerformLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.ResumeLayout(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.menuStrip1.PerformLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel1.ResumeLayout(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel2.ResumeLayout(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.Panel2.PerformLayout();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.splitContainer1.ResumeLayout(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.ResumeLayout(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.PerformLayout();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.DataGridView dataGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.StatusStrip statusBar;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripStatusLabel labelRowCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripStatusLabel toolStripRowCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.MenuStrip menuStrip1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripMenuItem windowToolStripMenuItem;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.TextBox textBoxDisplay;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.Windows.Forms.SplitContainer splitContainer1;<br>&nbsp;&nbsp;&nbsp; }<br>}</font></p></blockquote> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><b><u><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">MergeXEvents</font></font></span></u></b></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><font face="Calibri"><font style="font-size: 11pt" color="#000000">MergeXEvents consumes XEvent files, using optimized parallel sort algorithms and outputting events into the <span>physical</span> file in event_sequence order.<span>&nbsp; </span>This was a project I created in 2014 to help Microsoft SQL Server support process incoming XEvent files, including the ability to merge XEvent files from multiple servers such as <span>replication</span> or high availability XEvent capture.<span>&nbsp; </span>The project uses parallel threads to perform scatter/gather activities as well as tournament sorting to optimize the sorting and merging activities.</font></font></span></p> <h5><font style="font-weight: bold">Program.cs</font></h5> <blockquote> <p><font size="2" face="Courier New">/*<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Designed to merge XEvents from multiple files into a single stream sorted by Event Sequence, Time and Server name<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This allows capture of large XEvent traces, using per CPU partitioning, and then post sorting in sequence order so the <br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream is in physical sequence order.<br>* <br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Arrays are owned by ## of partitions and dynamically expanded as events are read and added to them<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Once all data is read each array is sorted in ascending or decending order (by a a group of parallel workers)<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Once sorted the tournament sort is used by a single reader to gather the array streams and write to the output file<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Output File[n..] &lt;----- Parallel Task [Ordered Output Array Segment 1] |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;----- Array[1]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;---- FWriteEntry &lt;-- Gather Streams&nbsp; &lt;-- Parellel sorts&nbsp; | &lt;----- Array[2] &lt;----- Distribute streams | Reader<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Output File[n..] &lt;----- Parallel Task [Ordered Output Array Segment N] |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &lt;----- Array[3]<br>* <br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NOTE:&nbsp; Testing shows parallel Output files do not have performance gains.&nbsp; The original EventProvider, which is not thread safe,<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prevents you opening and using a second copy of the input stream and a second EventProvider and adding lock() activities between the<br>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RetreiveObject(EventLocator) and the Serialize causes more context swithing than just doing the work on a single thread.<br>* */</font></p> <p><font size="2" face="Courier New">#define SEPERATE_OUTPUT</font></p> <p><font size="2" face="Courier New">using System;<br>using System.Reflection;<br>using System.Collections;<br>using System.Collections.Generic;<br>using System.Text;<br>using System.Threading.Tasks;<br>using Microsoft.SqlServer.XEvent.Linq;<br>using System.IO;<br>using VersionInfo;<br>using System.Security.AccessControl;<br>using System.Runtime.InteropServices;<br>using ScatterGatherParallelNS;<br>using System.Threading;</font></p> <p><font size="2" face="Courier New">namespace SortManager<br>{<br>&nbsp;&nbsp;&nbsp; abstract class ISortLogOutput<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abstract public void LogOutputMessage(string strMsg);<br>&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">#region DynamicList<br>&nbsp;&nbsp;&nbsp; public sealed class TDynamicList&lt;_T&gt; : IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal TDynamicList()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items = new List&lt;_T&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_Items)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items.Clear();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void Add(_T newEntry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock (m_Items)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items.Add(newEntry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal bool FMoveNext()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m_Walker.MoveNext();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal _T GetCurrentEntry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.Debug.Assert(null != m_Walker.Current);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m_Walker.Current;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal bool FHasData<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null != m_Walker.Current;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal Int32 StoredItems<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_Items.Count; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void Sort(IComparer&lt;_T&gt; comparer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_Items &amp;&amp; m_Items.Count &gt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items.Sort(comparer);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Walker = m_Items.GetEnumerator();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;_T&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;_T&gt;.Enumerator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Walker;<br>&nbsp;&nbsp;&nbsp; }<br>#endregion</font></p> <p><font size="2" face="Courier New">#region DynamicArray<br>&nbsp;&nbsp;&nbsp; public sealed class TDynamicArray&lt;_T&gt; : IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal TDynamicArray()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items = ArrayList.Synchronized(new ArrayList());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCurrentReadPos = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_Items)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items.Clear();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCurrentReadPos = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void Add(_T newEntry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items.Add(newEntry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal bool FMoveNext()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCurrentReadPos++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m_iCurrentReadPos &lt; m_Items.Count;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal _T GetCurrentEntry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (_T) m_Items[m_iCurrentReadPos];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public _T Item(int iItem)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (_T) m_Items[iItem];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal Int32 StoredItems<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_Items.Count;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal int Count<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_Items.Count;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ArrayList&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Items;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Int32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCurrentReadPos;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; Current reader position&nbsp; <br>&nbsp;&nbsp;&nbsp; }<br>#endregion</font></p> <p><font size="2" face="Courier New">#region SortMatchTree<br>&nbsp;&nbsp;&nbsp; internal class TSortMatchingTree&lt;_T&gt; : IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal TSortMatchingTree(TDynamicList&lt;_T&gt;[] partitions, bool bAscending = true)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bAscending = bAscending;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Partitions = partitions;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners = new Int16[MAX_LEVELS+1, MAX_PARTITIONS];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lowest level is always self<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(Int16 iPartition = 0; iPartition &lt; MAX_PARTITIONS; iPartition++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[MAX_LEVELS, iPartition] = iPartition;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void PrimeEntries(IComparer&lt;_T&gt; comparer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Comparer = comparer;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Int16 iSlot = 0; iSlot &lt; MAX_PARTITIONS; iSlot++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FTreeInsert(iSlot);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*=========================================================<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parents<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; 1&nbsp; 2&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 01 23 45 56 ...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pairs<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =========================================================*/&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; Given an index who are we playing this match agianst<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal Int16 GetMatchTargetIndex(Int16 iPartition) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iMatchIndex = iPartition;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iMatchIndex += (0 == iPartition % 2) ? (Int16)1 : (Int16)(-1);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return iMatchIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal Int16 GetParentIndex(Int16 iPartition)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iParent;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iParent = (Int16) (iPartition / 2);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return iParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal bool FTreeInsert(Int16 iPartitionIn)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool&nbsp;&nbsp;&nbsp; bRC = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //===========================================================================<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><a href="https://en.wikipedia.org/wiki/Tournament_sort"><font size="2" face="Courier New">https://en.wikipedia.org/wiki/Tournament_sort</font></a><br><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><a href="https://en.wikipedia.org/wiki/Heapsort"><font size="2" face="Courier New">https://en.wikipedia.org/wiki/Heapsort</font></a><br><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><a href="https://en.wikipedia.org/wiki/Merge_sort"><font size="2" face="Courier New">https://en.wikipedia.org/wiki/Merge_sort</font></a><br><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //===========================================================================&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iPartition = iPartitionIn;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Int16 iCurrentLevel = MAX_LEVELS; iCurrentLevel &gt; 0; iCurrentLevel--)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iPartnerPartition = GetMatchTargetIndex(iPartition);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iParent = GetParentIndex(iPartition);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iPartnerCompare = m_bWinners[iCurrentLevel, iPartnerPartition];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iCurrentCompare = m_bWinners[iCurrentLevel, iPartition];</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iPrevWinner = m_bWinners[iCurrentLevel - 1, iParent];</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (INVALID_PARTITION == iPartnerCompare || false == m_Partitions[iPartnerCompare].FHasData)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[iCurrentLevel - 1, iParent] = iCurrentCompare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (INVALID_PARTITION == iCurrentCompare || false == m_Partitions[iCurrentCompare].FHasData)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[iCurrentLevel - 1, iParent] = iPartnerCompare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == m_bAscending)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(m_Comparer.Compare(m_Partitions[iCurrentCompare].GetCurrentEntry,&nbsp; m_Partitions[iPartnerCompare].GetCurrentEntry) &lt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[iCurrentLevel - 1, iParent] = iCurrentCompare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[iCurrentLevel - 1, iParent] = iPartnerCompare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (m_Comparer.Compare(m_Partitions[iCurrentCompare].GetCurrentEntry, m_Partitions[iPartnerCompare].GetCurrentEntry) &gt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[iCurrentLevel - 1, iParent] = iCurrentCompare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners[iCurrentLevel - 1, iParent] = iPartnerCompare;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (iPrevWinner == m_bWinners[iCurrentLevel - 1, iParent] &amp;&amp; iPrevWinner != iPartitionIn)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; I changed so we have to recheck assumptions of previous matches<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iPartition = iParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal bool RemoveHead(out _T entry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool bRC = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16 iWinner = m_bWinners[0, 0];</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (INVALID_PARTITION == iWinner || false == m_Partitions[iWinner].FHasData)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry = m_Partitions[iWinner].GetCurrentEntry;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Partitions[iWinner].FMoveNext();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; FTreeInsert has to be called in true or false case<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FTreeInsert(iWinner);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bRC = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry = default(_T);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void ValidateAllProcessed()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int iPartition = 0; iPartition &lt; MAX_PARTITIONS; iPartition++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.Debug.Assert( false == m_Partitions[iPartition].FHasData);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members and Constants <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public const int MAX_PARTITIONS&nbsp;&nbsp;&nbsp;&nbsp; = 32;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; Has to be even number to allow matching to work properly - must be power of 2 to handle max levels<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public const int INVALID_PARTITION&nbsp; = 255;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; No further entries in the partition<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public const int MAX_LEVELS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TDynamicList&lt;_T&gt;[]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Partitions;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Reference to the partitions for actual values <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IComparer&lt;_T&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Comparer;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Reference to comparision<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int16[,]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bWinners;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Tournament tree storage <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bAscending;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Sort direction<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; public abstract class ISortReaderWriter&lt;_T&gt;<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abstract public bool FReadEntry(out _T entry, ref int iEnumerator, int iStepping);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abstract public bool FWriteEntry(_T entry);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abstract public void ClearReadAhead();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; abstract public void DoReadAhead(int iSourceFileSlot);<br>&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; public class TSortManager&lt;_T&gt; : ISortReaderWriter&lt;_T&gt;, IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const Int32 OUTPUT_CHIMB = 250000;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override void ClearReadAhead()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new NotImplementedException();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override void DoReadAhead(int iSourceFileSlot)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new NotImplementedException();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal TSortManager(ISortLogOutput oSortOutput)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_oSortOutput = oSortOutput;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_PartitionedItemStorage = new TDynamicList&lt;_T&gt;[TSortMatchingTree&lt;_T&gt;.MAX_PARTITIONS];</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int iSlot = 0; iSlot &lt; TSortMatchingTree&lt;_T&gt;.MAX_PARTITIONS; iSlot++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_PartitionedItemStorage[iSlot] = new TDynamicList&lt;_T&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_MatchingTree = new TSortMatchingTree&lt;_T&gt;(m_PartitionedItemStorage);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_i32ActivePartition = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64TotalReadEntries = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64TotalWriteEntries = 0;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_stopWatch = new System.Diagnostics.Stopwatch();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dispose(true);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.SuppressFinalize(this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected virtual void Dispose(bool bDisposing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == bDisposing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_MatchingTree.Dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_MatchingTree = null;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_PartitionedItemStorage)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Int32 iSlot = 0; iSlot &lt; TSortMatchingTree&lt;_T&gt;.MAX_PARTITIONS; iSlot++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_PartitionedItemStorage[iSlot] = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_PartitionedItemStorage = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_stopWatch = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void LogOutputMessage(string strMsg)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_oSortOutput.LogOutputMessage(strMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal int ReadCPS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Math.Min(Math.Max(2, Environment.ProcessorCount - 1), 4);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static int m_iReaderThreadId = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void ReaderThread()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iEnumerator = System.Threading.Interlocked.Increment(ref m_iReaderThreadId);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iCPUs = ReadCPS;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _T entry;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (true == FReadEntry(out entry, ref iEnumerator, iCPUs))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add(entry);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Int64 i64Read = System.Threading.Interlocked.Increment(ref m_ui64TotalReadEntries);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 == i64Read % OUTPUT_CHIMB)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage(String.Format("&nbsp;&nbsp;&nbsp;&nbsp; Entries read: {0} : {1} per sec", i64Read, (UInt64)((double)i64Read / Math.Max(1, m_stopWatch.ElapsedMilliseconds / 1000.0))));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void DoSort(IComparer&lt;_T&gt; comparer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _T entry;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_stopWatch.Start();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage("Loading partitions");</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iCPUs = ReadCPS;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Threading.Thread[] readThreads = new System.Threading.Thread[iCPUs];</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int iThread = 0; iThread &lt; iCPUs; iThread++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readThreads[iThread] = new System.Threading.Thread(ReaderThread);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readThreads[iThread].Start();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (System.Threading.Thread thread in readThreads)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thread.Join();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage("Reads complete, invoking parallel sort of partitions");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetupSortForExternalConsumption(comparer);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClearReadAhead();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage("Gathering partitions and spooling output");</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int64 ui64StartWriteMS = m_stopWatch.ElapsedMilliseconds;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(true == RemoveHead(out entry))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64TotalWriteEntries++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == FWriteEntry(entry))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 == m_ui64TotalWriteEntries % OUTPUT_CHIMB)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage(String.Format("&nbsp;&nbsp;&nbsp;&nbsp; Entries streamed: {0} : {1} per sec&nbsp; {2}%", m_ui64TotalWriteEntries,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (UInt64)((double)m_ui64TotalWriteEntries / Math.Max(1, (m_stopWatch.ElapsedMilliseconds-ui64StartWriteMS) / 1000.0)),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Int32) (((m_ui64TotalWriteEntries / (double) m_ui64TotalReadEntries) * 100.0))) ); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_stopWatch.Stop();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClearReadAhead();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.Debug.Assert(m_ui64TotalReadEntries == m_ui64TotalWriteEntries);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_MatchingTree.ValidateAllProcessed();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public bool FReadEntry(out _T entry, ref int iEnumerator, int iStepping)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new NotImplementedException();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //return false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public bool FWriteEntry(_T entry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new NotImplementedException();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void Add(_T newEntry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 iPartition = System.Threading.Interlocked.Increment(ref m_i32ActivePartition) % TSortMatchingTree&lt;_T&gt;.MAX_PARTITIONS;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_PartitionedItemStorage[iPartition].Add(newEntry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void SetupSortForExternalConsumption(IComparer&lt;_T&gt; comparer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parallel.ForEach(m_PartitionedItemStorage, (partitionList) =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; partitionList.Sort(comparer);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; partitionList.FMoveNext();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Position to first entry in list or EOF<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_MatchingTree.PrimeEntries(comparer);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal bool RemoveHead(out _T entry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m_MatchingTree.RemoveHead(out entry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal Int64 Write_Stats<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_ui64TotalWriteEntries;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal Int64 Read_Stats<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_ui64TotalReadEntries; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal System.Diagnostics.Stopwatch StopWatch<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_stopWatch;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TDynamicList&lt;_T&gt;[]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_PartitionedItemStorage;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_i32ActivePartition;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TSortMatchingTree&lt;_T&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_MatchingTree;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64TotalReadEntries;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64TotalWriteEntries;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.Stopwatch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_stopWatch;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SortManager.ISortLogOutput&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_oSortOutput;<br>&nbsp;&nbsp;&nbsp; }<br>#endregion<br>&nbsp;&nbsp;&nbsp; <br>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End if generic sort manager namespace </font></p> <p><br><font size="2" face="Courier New">namespace MergeXEvents<br>{<br>#region SortEntry<br>&nbsp;&nbsp;&nbsp; public class CXESortEntry<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal CXESortEntry()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_timestamp = default(DateTimeOffset);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64EventSequence = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 0 indicates NOT set<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64ServerNameHash = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCookie = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_EventLocator = null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&nbsp; This is only unique at a file level so the cookie used to get the proper file is important to making sure we get back to the proper offset </font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_uiUniqueIdentity = (UInt64) System.Threading.Interlocked.Increment(ref s_uiUniqueIdentity);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal CXESortEntry(DateTimeOffset timestamp, UInt64 ui64EventSeq, UInt64 uiServerNameHash)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_timestamp = timestamp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64EventSequence = ui64EventSeq;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64ServerNameHash = uiServerNameHash;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCookie = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_EventLocator = null;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Wanted to use memory address of the entry but with GC moving things we needed a stable value <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is added because the data could have duplicate entries.&nbsp; For example if you merge files from<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 different servers the event sequence could be repeated (1 from each trace)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_uiUniqueIdentity = (UInt64) System.Threading.Interlocked.Increment(ref s_uiUniqueIdentity);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal UInt64 EventSequence<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_ui64EventSequence; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_ui64EventSequence = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal UInt64 ServerNameHash<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_ui64ServerNameHash; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_ui64ServerNameHash = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal DateTimeOffset Timestamp<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_timestamp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_timestamp = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal UInt64 UniqueIdentity<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_uiUniqueIdentity;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public EventLocator EventLocator<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_EventLocator; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_EventLocator = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Cookie<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_iCookie;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_iCookie = value;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventLocator&nbsp;&nbsp;&nbsp; m_EventLocator;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; So we can use this to get the event later<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCookie;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; External cookie for sort reader and writer logic<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DateTimeOffset&nbsp; m_timestamp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; timestamp on the event<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UInt64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64EventSequence;&nbsp;&nbsp;&nbsp; //&nbsp; event_sequence action<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UInt64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64ServerNameHash;&nbsp;&nbsp; //&nbsp; GetHashCode of the server_principle_name action <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UInt64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_uiUniqueIdentity;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Used to make sure we have a final sort order if timestamps and server names match without event sequence </font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static long s_uiUniqueIdentity;<br>&nbsp;&nbsp;&nbsp; }<br>#endregion</font></p> <p><font size="2" face="Courier New">#region Comparision<br>&nbsp;&nbsp;&nbsp; class CXEComparerSeqTimeServer : IComparer&lt;CXESortEntry&gt;<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int IComparer&lt;CXESortEntry&gt;.Compare(CXESortEntry xeLeft, CXESortEntry xeRight)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 iRC = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Note we have UInt64s so we can't do simple match or it can overflow the Int32 return value </font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool bDoTimestamp = false;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Event sequence <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 != xeLeft.EventSequence &amp;&amp; 0 != xeRight.EventSequence)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xeLeft.EventSequence &lt; xeRight.EventSequence)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (xeLeft.EventSequence &gt; xeRight.EventSequence)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bDoTimestamp = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bDoTimestamp = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == bDoTimestamp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xeLeft.Timestamp &lt; xeRight.Timestamp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (xeLeft.Timestamp &gt; xeRight.Timestamp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 == iRC)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 != xeLeft.ServerNameHash &amp;&amp; 0 != xeRight.ServerNameHash)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xeLeft.ServerNameHash &lt; xeRight.ServerNameHash)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (xeLeft.ServerNameHash &gt; xeRight.ServerNameHash)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 == iRC)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xeLeft.UniqueIdentity &lt; xeRight.UniqueIdentity)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (xeLeft.UniqueIdentity &gt; xeRight.UniqueIdentity)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return iRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; }<br>#endregion</font></p> <p><font size="2" face="Courier New">#region StreamToFile<br>&nbsp;&nbsp;&nbsp; internal class CSourceFileEntry :&nbsp; IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CSourceFileEntry(String strFileName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strXELName = strFileName;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFile = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEEventEnumerator = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFileDuplicateForOutput = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_DuplicateOpenSemaphore = new Semaphore(0, 1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strXELName = String.Empty;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(null != m_XEventSourceFile)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFile.Dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFile = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(null != m_XEventSourceFileDuplicateForOutput)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFileDuplicateForOutput.Dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFileDuplicateForOutput = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_DuplicateOpenSemaphore)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_DuplicateOpenSemaphore.Close();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_DuplicateOpenSemaphore = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public String FileName<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_strXELName;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public QueryableXEventData XELFile<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_XEventSourceFile;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public IEnumerator&lt;PublishedEvent&gt; EventEnumerator<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_XEEventEnumerator;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public QueryableXEventData XELFileForOutput<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_XEventSourceFileDuplicateForOutput; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public IEnumerator&lt;PublishedEvent&gt; EventEnumeratorForOutput<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_XEEventEnumeratorDuplicateForOutput; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void WaitForOutputOpen()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == m_DuplicateOpenSemaphore.WaitOne())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_DuplicateOpenSemaphore.Release();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Open()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Found if we double read the file into another provider we can pass the published <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; event across these providers (same exact metadata and buffers) so we can seperate <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; the retreive from serialize and increase the output speed<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFileDuplicateForOutput = new QueryableXEventData(m_strXELName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEEventEnumeratorDuplicateForOutput = m_XEventSourceFileDuplicateForOutput.GetEnumerator();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; finally<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_DuplicateOpenSemaphore.Release();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFile = new QueryableXEventData(m_strXELName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEEventEnumerator = m_XEventSourceFile.GetEnumerator();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public bool FIsOpen()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null != m_XEEventEnumerator;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private QueryableXEventData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFile;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private IEnumerator&lt;PublishedEvent&gt; m_XEEventEnumerator;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private QueryableXEventData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFileDuplicateForOutput;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private IEnumerator&lt;PublishedEvent&gt; m_XEEventEnumeratorDuplicateForOutput;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Semaphore&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_DuplicateOpenSemaphore;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private String&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strXELName;<br>&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; public class CXEventSortStream : SortManager.TSortManager&lt;CXESortEntry&gt;<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal CXEventSortStream(SortManager.ISortLogOutput oLogOutput) :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base(oLogOutput)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFiles = new SortManager.TDynamicArray&lt;CSourceFileEntry&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void DoSort()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DoSort(new CXEComparerSeqTimeServer());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public bool FReadEntry(out CXESortEntry entry, ref int iEnumerator, int iStepping)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool bRC = false;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PublishedEvent publishedEvent = null;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (iEnumerator &lt; m_XEventSourceFiles.StoredItems)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(false == m_XEventSourceFiles.Item(iEnumerator).FIsOpen())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFiles.Item(iEnumerator).Open();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == m_XEventSourceFiles.Item(iEnumerator).EventEnumerator.MoveNext())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; publishedEvent = m_XEventSourceFiles.Item(iEnumerator).EventEnumerator.Current;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iEnumerator += iStepping;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } while (null == publishedEvent &amp;&amp; iEnumerator &lt; m_XEventSourceFiles.StoredItems);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != publishedEvent)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry = default(CXESortEntry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry = new CXESortEntry();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.EventLocator = publishedEvent.Location;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Cookie = iEnumerator;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp = publishedEvent.Timestamp;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PublishedAction eventSeq;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == publishedEvent.Actions.TryGetValue(@"event_sequence", out eventSeq))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.EventSequence = (UInt64) eventSeq.Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PublishedAction serverName;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == publishedEvent.Actions.TryGetValue(@"server_principal_name", out serverName))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.ServerNameHash = (UInt64)serverName.Value.GetHashCode();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bRC = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry = default(CXESortEntry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public bool FWriteEntry(CXESortEntry entry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void AddInputFile(string strXELFile)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSourceFileEntry se = new CSourceFileEntry(strXELFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock (m_XEventSourceFiles)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEventSourceFiles.Add(se);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal SortManager.TDynamicArray&lt;CSourceFileEntry&gt; SourceFiles<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_XEventSourceFiles; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private SortManager.TDynamicArray&lt;CSourceFileEntry&gt; m_XEventSourceFiles;<br>&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; class CParallelPayload<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CParallelPayload(CXEventFileToFileSortManager sortFileMgr, CXESortEntry sortEntry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_sortFileMgr = sortFileMgr;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_sortEntry = sortEntry;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_publishedEvent = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CXESortEntry SortEntry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_sortEntry; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CXEventFileToFileSortManager SortFileMgr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_sortFileMgr; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public PublishedEvent PublishedEvent<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_publishedEvent; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_publishedEvent = value;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private CXEventFileToFileSortManager m_sortFileMgr;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private CXESortEntry m_sortEntry;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private PublishedEvent m_publishedEvent;<br>&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; internal class CScatterGatherStream : ScatterGatherParallelMgr&lt;CParallelPayload&gt;<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CScatterGatherStream() :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base(2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public void DoUnOrderedWork(CParallelPayload pPayload)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pPayload.SortFileMgr.DoUnorderedWork(pPayload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public void DoOrderedWork(CParallelPayload pPayload)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pPayload.SortFileMgr.DoOrderedWork(pPayload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public void OrderedWorkerStalled(CParallelPayload pPayload)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public void OrderedWorkerNoStall()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; }</font></p> <p><br><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; internal class CXEventFileToFileSortManager : CXEventSortStream<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal CXEventFileToFileSortManager(SortManager.ISortLogOutput oLogOutput)&nbsp; :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base(oLogOutput)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCancelReadAhead = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ScatterGatherOutputStream = new CScatterGatherStream();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strLastOutputName = String.Empty;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_lFileCount = 1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strOutputFile = String.Empty;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strOutputDir = String.Empty;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEOutputStream = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64RolloverCount = 0;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_dictReadAhead = new Dictionary&lt;int, Thread&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ~CXEventFileToFileSortManager()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseFile();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new internal void DoSort()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.DoSort();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ScatterGatherOutputStream.CompleteAllWork();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseFile();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void CloseFile()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(String.Empty != m_strLastOutputName &amp;&amp; null != m_XEOutputStream)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEOutputStream.Dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEOutputStream = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strDirectory = System.IO.Path.GetDirectoryName(m_strLastOutputName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDirectory = System.IO.Path.GetFullPath(strDirectory);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strFileSpec = System.IO.Path.GetFileName(m_strLastOutputName);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Strip extention<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFileSpec = strFileSpec.Substring(0, strFileSpec.Length - 4);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFileSpec += "*.xel";</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IEnumerable&lt;string&gt; strFiles = System.IO.Directory.EnumerateFiles(strDirectory, strFileSpec);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iLoops = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string strFile in strFiles)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 != iLoops++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetNewOutputFileName();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iLoops++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileAttributes fa = File.GetAttributes(strFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (FileAttributes.Compressed == (FileAttributes.Compressed &amp; fa))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage(" WARN: Performance may be impacted as output file appears to be using compression.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.Directory.Move(strFile, m_strLastOutputName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strLastOutputName = String.Empty;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void SetNewOutputFileName(CXESortEntry entry = null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != entry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strLastOutputName = String.Format(@"{0}\{1}_0 ymd({2}-{3}-{4}) hms({5}-{6}-{7}.{8})_{9}.xel", m_strOutputDir, m_strOutputFile,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Year,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Month,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Day,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Hour,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Minute,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Second,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Timestamp.ToUniversalTime().Millisecond,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_lFileCount++);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else&nbsp;&nbsp; //&nbsp;&nbsp; Rollover path <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strCount = (m_lFileCount -1).ToString();&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; File count is incremented when the name was built<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strFile = m_strLastOutputName.Substring(0, m_strLastOutputName.Length - 4 - strCount.Length);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strLastOutputName = String.Format(@"{0}{1}.xel", strFile, m_lFileCount++);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == File.Exists(m_strLastOutputName))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileAttributes fa = File.GetAttributes(m_strLastOutputName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File.SetAttributes(m_strLastOutputName, fa &amp; ~FileAttributes.ReadOnly);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.File.Delete(m_strLastOutputName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void DoUnorderedWork(CParallelPayload payload)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock (SourceFiles.Item(payload.SortEntry.Cookie).XELFile.EventProvider)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; payload.PublishedEvent = SourceFiles.Item(payload.SortEntry.Cookie).XELFile.EventProvider.RetrieveEvent(payload.SortEntry.EventLocator);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><br><font size="2" face="Courier New">#if DEBUG<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UInt64 m_ui64SeqCheck = 0;<br>#endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void DoOrderedWork(CParallelPayload payload)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //========================================================================<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Generate file name for output based on the timestamp so it is easy to see which file you want to open.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Toggle close and open the output stream to force a numbered rollover <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; We use 1 millon because this is the current SSMS display limit<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1,000,000 approaches 1GB too often so shrink the number of entries per output file <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //========================================================================<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null == m_XEOutputStream || 0 == (m_ui64RolloverCount + 1) % 500000)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseFile();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetNewOutputFileName(payload.SortEntry);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Setup the file for output <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEOutputStream = new XEventFileSerializer(m_strLastOutputName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">#if DEBUG<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Safety check <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (m_ui64SeqCheck &lt; payload.SortEntry.EventSequence)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64SeqCheck = payload.SortEntry.EventSequence;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new Exception("UTILITY ERROR; Attempt to stream duplicate entry");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>#endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SourceFiles.Item(payload.SortEntry.Cookie).XELFileForOutput.EventProvider.SerializeEvent(m_XEOutputStream, payload.PublishedEvent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64RolloverCount++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock (SourceFiles.Item(payload.SortEntry.Cookie).XELFile.EventProvider)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SourceFiles.Item(payload.SortEntry.Cookie).XELFile.EventProvider.SerializeEvent(m_XEOutputStream, payload.PublishedEvent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64RolloverCount++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>#endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public bool FWriteEntry(CXESortEntry entry)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CParallelPayload payload = new CParallelPayload(this, entry);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do inline work <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ScatterGatherOutputStream.FQueueWorkItem(payload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ScatterGatherOutputStream.DoUnOrderedWork(payload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ScatterGatherOutputStream.DoOrderedWork(payload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override void ClearReadAhead()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Let everyone know they are done<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Interlocked.Increment(ref m_iCancelReadAhead);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock(m_dictReadAhead)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Make sure all active threads are done <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(KeyValuePair&lt;int, Thread&gt; oKV in m_dictReadAhead)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oKV.Value.Join();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_dictReadAhead.Clear();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Reset for next execution <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCancelReadAhead = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public override void DoReadAhead(int iFileEnumSlot)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iCookie = -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thread tReadAhead = new Thread(DoReadAheadInternal);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lock (m_dictReadAhead)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thread tReadAheadDummy;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == m_dictReadAhead.TryGetValue(iFileEnumSlot, out tReadAheadDummy))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iCookie = iFileEnumSlot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_dictReadAhead.Add(iFileEnumSlot, tReadAhead);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Do we need to start the read-ahead to suck data into file system cache <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (iCookie &gt; -1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tReadAhead.Start(iCookie);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void DoReadAheadInternal(object oParms)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iCookie = (int) oParms;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strName = SourceFiles.Item(iCookie).FileName;<br>#if DEBUG<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage(String.Format(" INFO: Starting file system cache read-ahead for {0}",&nbsp; strName));<br>#endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; We just open the file and read in chunks, allowing caching to fill file system cache quickly <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int c_iMaxReadSize = ((1024 * 1024) * 4);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (FileStream s = new FileStream(strName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Write | FileShare.Delete, c_iMaxReadSize, FileOptions.SequentialScan))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] bData = new byte[c_iMaxReadSize];</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulong ulLoops = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iBytesRead = s.Read(bData, 0, c_iMaxReadSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (0 == m_iCancelReadAhead &amp;&amp; iBytesRead &gt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iBytesRead = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulLoops++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(0 == ulLoops % 100)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thread.Sleep(10);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iBytesRead = s.Read(bData, 0, c_iMaxReadSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if SEPERATE_OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SourceFiles.Item(iCookie).WaitForOutputOpen();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != SourceFiles.Item(iCookie).EventEnumeratorForOutput)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (true == SourceFiles.Item(iCookie).EventEnumeratorForOutput.MoveNext()) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputMessage(String.Format(" INFO: read ahead encounted exection for {0} ignoring.", e.ToString()));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal void SetOutputFile(string strXELFile)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strOutputFile = System.IO.Path.GetFileNameWithoutExtension(strXELFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strOutputDir = System.IO.Path.GetDirectoryName(strXELFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Members <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dictionary&lt;int, Thread&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_dictReadAhead;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CScatterGatherStream&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ScatterGatherOutputStream;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strOutputFile;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strOutputDir;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XEventFileSerializer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_XEOutputStream;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_strLastOutputName;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_lFileCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iCancelReadAhead;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UInt64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ui64RolloverCount;<br>&nbsp;&nbsp;&nbsp; }<br>#endregion</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; class CSortOutput : SortManager.ISortLogOutput, IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CSortOutput(string strOutputPath)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OutputFile = null;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strDirectory = System.IO.Path.GetDirectoryName(strOutputPath);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Program.FCreateDirectoryWithACLs(strDirectory);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OutputFile = new System.IO.StreamWriter(String.Format(@"{0}\MergeEvents.log", strDirectory));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dispose(true);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.SuppressFinalize(this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected void Dispose(bool bDisposing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(true == bDisposing)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OutputFile.Close();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OutputFile = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; override public void LogOutputMessage(string strMsg)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Program.LogToConsole(strMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_OutputFile)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OutputFile.WriteLine("{0} {1} {2}", DateTime.Now, System.Threading.Thread.CurrentThread.ManagedThreadId, strMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OutputFile.Flush();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private System.IO.StreamWriter m_OutputFile;<br>&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; class Program<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static internal void LogToConsole(string strMsg)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("{0} {1} {2}", DateTime.Now, System.Threading.Thread.CurrentThread.ManagedThreadId, strMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static internal void ShowUsage()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("Usage");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("------------------------------------------------------------------------");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("/? Present this help information");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("EXAMPLE:&nbsp; MergeXEvents.exe &lt;input spec&gt; &lt;output spec&gt;");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MergeXEvents.exe \"C:\\temp\\XEvent_0_130494871596480000.xel\" \"C:\\temp\\Sorted.xel\" ");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("&lt;input spec&gt; any valid directory and wildcard.&nbsp;&nbsp; All files matching wildcard in the directory will be processed as input");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("&lt;output spec&gt; is any valid file name where output for the merge can be stored, including rollover files.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">#region AssemblyInformation<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static public string AssemblyTitle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (attributes.Length &gt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == String.IsNullOrEmpty(titleAttribute.Title))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return titleAttribute.Title;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static public string AssemblyVersion<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return VersionStrings.VERSION_MAJOR_STR + VersionStrings.VERSION_MINOR_STR + VersionStrings.VERSION_BUILD_STR;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static&nbsp; public string AssemblyDescription<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (attributes.Length == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "";</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ((AssemblyDescriptionAttribute)attributes[0]).Description;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static public string AssemblyProduct<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (attributes.Length == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ((AssemblyProductAttribute)attributes[0]).Product;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static public string AssemblyCopyright<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (attributes.Length == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "";</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static public string AssemblyCompany<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (attributes.Length == 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return "";</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ((AssemblyCompanyAttribute)attributes[0]).Company;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion</font></p> <p><font size="2" face="Courier New">#region DIR_ACLS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int FILE_PERSISTENT_ACLS = 0x00000008;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static extern bool GetVolumeInformation(string lpRootPathName,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuilder lpVolumeNameBuffer,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [MarshalAs(UnmanagedType.U4)] int nVolumeNameSize,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [MarshalAs(UnmanagedType.U4)] ref int lpVOlumeSerialNumber,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [MarshalAs(UnmanagedType.U4)] ref int lpMaxComponentLen,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [MarshalAs(UnmanagedType.U4)] ref int lpFileSytemFlags,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuilder lpFileSystemNameBuffer,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [MarshalAs(UnmanagedType.U4)] int nFileSystemNameSize);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static public bool FCreateDirectoryWithACLs(string strDirName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool bRC = false;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.Directory.CreateDirectory(strDirName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DirectorySecurity dss = new DirectorySecurity();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dss.AddAccessRule(new FileSystemAccessRule(@"NT AUTHORITY\ANONYMOUS LOGON",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileSystemRights.FullControl,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AccessControlType.Deny));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Exception encountered setting ANONYMOUS access rule {0}", e.ToString()));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dss.AddAccessRule(new FileSystemAccessRule(System.Security.Principal.WindowsBuiltInRole.Guest.ToString(),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileSystemRights.FullControl,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AccessControlType.Deny));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Exception encountered setting GUEST access rule {0}", e.ToString()));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dss.AddAccessRule(new FileSystemAccessRule(@"BuiltIn\Administrators",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileSystemRights.ReadExtendedAttributes | FileSystemRights.ReadAttributes | FileSystemRights.Synchronize,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AccessControlType.Allow));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Exception encountered setting Administrators access rule {0}", e.ToString()));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String strCurrentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dss.AddAccessRule(new FileSystemAccessRule(strCurrentUser,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileSystemRights.FullControl,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AccessControlType.Allow));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Exception encountered setting current user access rule for: " + strCurrentUser, e));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String strRoot = System.IO.Path.GetPathRoot(strDirName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == strRoot.EndsWith("\\", StringComparison.Ordinal))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strRoot += "\\";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iSerialNumber = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iMaxComponent = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iFlags = 0;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bRC = GetVolumeInformation(strRoot, null, 0, ref iSerialNumber, ref iMaxComponent, ref iFlags, null, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == bRC)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("Attempt to obtain volume information failed.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (FILE_PERSISTENT_ACLS != (iFlags &amp; FILE_PERSISTENT_ACLS))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("ERROR: Specified location does not support proper access controls.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bRC = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(true == bRC)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.Directory.SetAccessControl(strDirName, dss);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bRC = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>#endregion</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //==============================================================<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static int Main(string[] args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(AssemblyTitle);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Version {0}", AssemblyVersion));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(AssemblyCopyright);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("------------------------------------------------------------");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(args.Length != 2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShowUsage();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return DoWork(args[0], args[1]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static int DoWork(string strInput, string strOutput)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iRC = -100;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CXEventFileToFileSortManager xeSortMgr = new CXEventFileToFileSortManager(new CSortOutput(strOutput));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strDirectory = System.IO.Path.GetDirectoryName(strInput);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDirectory = System.IO.Path.GetFullPath(strDirectory);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strFileSpec = System.IO.Path.GetFileName(strInput);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string[] strParts = strFileSpec.Split('_');</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFileSpec = String.Empty;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int iLoop = 0; iLoop &lt; strParts.Length - 2; iLoop++ )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFileSpec += strParts[iLoop] + '_';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(String.Empty != strFileSpec)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFileSpec += "*.xel";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iFiles = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IEnumerable&lt;string&gt; strFiles = System.IO.Directory.EnumerateFiles(strDirectory, strFileSpec);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parallel.ForEach (strFiles, (strFile) =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("VALIDATING INPUT SOURCE: {0}", strFile));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xeSortMgr.AddInputFile(strFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Threading.Interlocked.Increment(ref iFiles);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Since the XE Linq reader uses file mapping compression defeats the alignment attempts on sector boundaries<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileAttributes fa = File.GetAttributes(strFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (FileAttributes.Compressed == (FileAttributes.Compressed &amp; fa))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(" WARN: Performance may be impacted as input file appears to be using compression.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xeSortMgr.ClearReadAhead();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(iFiles &gt; 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDirectory = System.IO.Path.GetDirectoryName(strOutput);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDirectory = System.IO.Path.GetFullPath(strDirectory);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == FCreateDirectoryWithACLs(strDirectory))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("ERROR: Unable to create or set ALCs on {0}", strDirectory));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -6;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFileSpec = System.IO.Path.GetFullPath(strOutput);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OUTPUT: {0}", strFileSpec));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("Removing files in output location with matching file name pattern.");</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strFileNameNoExt = System.IO.Path.GetFileNameWithoutExtension(strFileSpec);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strLastOutputNamePattern = String.Format(@"{0}_0 ymd(*) hms(*)_*.xel", strFileNameNoExt);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFiles = System.IO.Directory.EnumerateFiles(strDirectory, strLastOutputNamePattern);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(string strFile in strFiles)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileAttributes fa = File.GetAttributes(strFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File.SetAttributes(strFile, fa &amp; ~FileAttributes.ReadOnly);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.IO.File.Delete(strFile);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xeSortMgr.SetOutputFile(strFileSpec);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("Beginning sort action ...");</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xeSortMgr.DoSort();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Sort action has completed (Elapsed {0} sec)", xeSortMgr.StopWatch.ElapsedMilliseconds / 1000.0));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("&nbsp;&nbsp;&nbsp; Events read: {0}", xeSortMgr.Read_Stats));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(String.Format("Events streamed: {0}", xeSortMgr.Write_Stats));</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (xeSortMgr.Read_Stats != xeSortMgr.Write_Stats)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (0 == xeSortMgr.Read_Stats)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("ERROR: Could not locate any input files.");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("Error / Exception encountered");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole("==========================================================");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogToConsole(e.ToString());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRC = -99;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return iRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; }<br>}</font></p></blockquote> <h5><font style="font-weight: bold">ScatterGather.cs</font></h5> <blockquote> <p><font size="2" face="Courier New">using System;<br>using System.Collections.Concurrent;<br>using System.Collections;<br>using System.Threading;</font></p> <p><font size="2" face="Courier New">namespace ScatterGatherParallelNS<br>{<br>&nbsp;&nbsp;&nbsp; #region ScatterGatherParallelMgr_IMPL<br>&nbsp;&nbsp;&nbsp; public abstract class ScatterGatherParallelMgr&lt;_TPayload&gt; : IDisposable<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private BlockingCollection&lt;CMsg&lt;_TPayload&gt;&gt; m_FreeQueue;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Msg has been processed, it can handle other payload<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private BlockingCollection&lt;CMsg&lt;_TPayload&gt;&gt; m_UnOrderedQueue;&nbsp;&nbsp; //&nbsp; Msg is dirty and needs processed when on this queue<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private BlockingCollection&lt;CMsg&lt;_TPayload&gt;&gt; m_OrderedQueue;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Msg is ready for final processing when on this queue<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private ArrayList m_alUnOrderedThreads;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Thread m_OrderedThread;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private bool m_bInitialized;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Int32 m_TotalUnOrderedThreads;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Int32 m_TotalMessages;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private bool m_bOrderedIsCurrentlyStalled;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Int64 m_iTotalOrderStalls;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ScatterGatherParallelMgr(int iUnorderedLimit)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_TotalUnOrderedThreads = Math.Max(2, Environment.ProcessorCount-1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_TotalUnOrderedThreads = Math.Min(iUnorderedLimit, m_TotalUnOrderedThreads);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_TotalMessages = m_TotalUnOrderedThreads * 128;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; ## per CPU<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bInitialized = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_FreeQueue = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_UnOrderedQueue = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedQueue = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_alUnOrderedThreads = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedThread = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bOrderedIsCurrentlyStalled = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iTotalOrderStalls = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public bool FIsOrderedWorkerStalled<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_bOrderedIsCurrentlyStalled; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int64 TotalOrderedWorkerStalls<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_iTotalOrderStalls; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; virtual public void AbortAllWorkers()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_alUnOrderedThreads)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Thread t in m_alUnOrderedThreads)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.Abort();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_OrderedThread)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedThread.Abort();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void StartWorkersIfNecessary()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == m_bInitialized)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bOrderedIsCurrentlyStalled = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iTotalOrderStalls = 0;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_FreeQueue = new BlockingCollection&lt;CMsg&lt;_TPayload&gt;&gt;();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Order not required<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_UnOrderedQueue = new BlockingCollection&lt;CMsg&lt;_TPayload&gt;&gt;();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Order not required</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ConcurrentQueue&lt;CMsg&lt;_TPayload&gt;&gt; q = new ConcurrentQueue&lt;CMsg&lt;_TPayload&gt;&gt;();&nbsp; //&nbsp; Order required<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedQueue = new BlockingCollection&lt;CMsg&lt;_TPayload&gt;&gt;(q);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Int32 iMsg = 0; iMsg &lt; m_TotalMessages; iMsg++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_FreeQueue.Add(new CMsg&lt;_TPayload&gt;());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_alUnOrderedThreads = new ArrayList();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Int32 iUnOrdered = 0; iUnOrdered &lt; m_TotalUnOrderedThreads; iUnOrdered++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThreadStart ts = new ThreadStart(UnOrderedEntryPoint);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thread t = new Thread(ts);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_alUnOrderedThreads.Add(t);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.Start();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThreadStart ts = new ThreadStart(OrderedEntryPoint);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedThread = new Thread(ts);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedThread.Start();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bInitialized = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected virtual void Dispose(bool bDispose)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CompleteAllWork();&nbsp; //&nbsp; If not shutdown do so now<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063")]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public virtual void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dispose(true);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.SuppressFinalize(this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void CompleteAllWork()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(null != m_UnOrderedQueue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_UnOrderedQueue.CompleteAdding();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_alUnOrderedThreads)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Thread t in m_alUnOrderedThreads)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t.Join();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_alUnOrderedThreads = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_OrderedQueue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedQueue.CompleteAdding();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_OrderedThread &amp;&amp; null != m_OrderedQueue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedThread.Join();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedThread = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(null != m_FreeQueue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_FreeQueue = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(null != m_UnOrderedQueue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_UnOrderedQueue = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(null != m_OrderedQueue)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedQueue = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bInitialized = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public abstract void DoUnOrderedWork(_TPayload pPayload);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void UnOrderedEntryPoint()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CMsg&lt;_TPayload&gt; cMsg in m_UnOrderedQueue.GetConsumingEnumerable())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DoUnOrderedWork(cMsg.Payload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cMsg.MarkReadyForOrderedProcessing();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (ThreadAbortException)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Silent, main would have issued this<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (OperationCanceledException)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public abstract void DoOrderedWork(_TPayload pPayload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public abstract void OrderedWorkerStalled(_TPayload pPayload);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public abstract void OrderedWorkerNoStall();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void OrderedEntryPoint()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 iContigiousNoStalls&nbsp;&nbsp; =&nbsp;&nbsp; 0;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CMsg&lt;_TPayload&gt; cMsg in m_OrderedQueue.GetConsumingEnumerable())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool bAcquired = false;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bAcquired = cMsg.WaitForUnOrderedProcessing(0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == bAcquired)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Immediate grab attempt<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_iTotalOrderStalls++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iContigiousNoStalls = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bOrderedIsCurrentlyStalled = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OrderedWorkerStalled(cMsg.Payload); //&nbsp; Signal we are going to a wait state on the specific payload<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (0 == (++iContigiousNoStalls % (m_TotalMessages * 0.25)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OrderedWorkerNoStall(); //&nbsp; Signal that prediction could feed us more<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_bOrderedIsCurrentlyStalled = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (false == bAcquired)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cMsg.WaitForUnOrderedProcessing(-1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DoOrderedWork(cMsg.Payload);</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cMsg.MakeReadyForFreeQueue();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_FreeQueue.Add(cMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (ThreadAbortException)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Silent, main would have issued this<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (OperationCanceledException)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public bool FQueueWorkItem(_TPayload pPayload)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool bRC = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StartWorkersIfNecessary();</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (true == m_bInitialized)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CMsg&lt;_TPayload&gt; cMsg = m_FreeQueue.Take();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cMsg.Payload = pPayload;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; Place on both queues<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_UnOrderedQueue.Add(cMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedQueue.Add(cMsg);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bRC = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return bRC;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #region CMsg_IMPL<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public sealed class CMsg&lt;_TPayloadType&gt; : IDisposable<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CMsg()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Payload = default(_TPayloadType);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedReadyLock = new AutoResetEvent(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MakeReadyForFreeQueue();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null != m_OrderedReadyLock)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedReadyLock.Close();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedReadyLock.Dispose();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedReadyLock = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.SuppressFinalize(this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void MakeReadyForFreeQueue()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Payload = default(_TPayloadType);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private _TPayloadType m_Payload;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public _TPayloadType Payload<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get { return m_Payload; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set { m_Payload = value; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private AutoResetEvent m_OrderedReadyLock;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void MarkReadyForOrderedProcessing()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_OrderedReadyLock.Set();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public bool WaitForUnOrderedProcessing(Int32 iTimeout)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m_OrderedReadyLock.WaitOne(iTimeout);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; #endregion</font><br><font size="2" face="Courier New">}</font></p></blockquote> <h5><font style="font-weight: bold">Powershell Test Driver</font></h5> <blockquote> <p><font size="2" face="Courier New">$core =&nbsp;&nbsp; [Reflection.Assembly]::LoadFrom('Microsoft.SqlServer.XE.Core.dll');<br>$xelinq = [Reflection.Assembly]::LoadFrom('Microsoft.SqlServer.XEvent.Linq.dll');</font></p> <p><font size="2" face="Courier New">$MergeXeventAssembly = [Reflection.Assembly]::LoadFrom('.\bin\x64\Release\MergeXEvents.exe');<br>if($null -eq $MergeXeventAssembly)<br>{<br>&nbsp;&nbsp;&nbsp; throw 'ERROR: Unable to load assembly';<br>}</font></p> <p><font size="2" face="Courier New">$bDumpRaw = $true;</font></p> <p><font size="2" face="Courier New">if($true -eq $bDumpRaw)<br>{<br>&nbsp;&nbsp;&nbsp; [MergeXEvents.Exporter]::GetIList('C:\temp\NewTestTraces\BigXEL\Test_0_130494871596480000.xel', 'C:\temp\NewTestTraces\BigXEL'); <br>}<br>else<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $iRow = 0;</font></p> <p><font size="2" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $events = [MergeXEvents.Exporter]::GetIList('C:\temp\NewTestTraces\BigXEL\eEst_0_130494871596480000.xel', 'C:\temp\NewTestTraces\BigXEL');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach($event in $events)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $iRow.ToString() + ' Event: ' + $event.Event_name + '|Package: ' + $event.Event_package_name + '|Timestamp: ' + $event.Event_timestamp&nbsp; | format-table -auto;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $iRow++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}</font></p></blockquote> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span style="font-family:;color:;line-height: 8pt"><font style="font-size: 7.5pt" color="#a5a5a5">Bob Dorr - Principal Software Engineer SQL Server</font></span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Linux: Directory fsync Activities</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-linux-directory-fsync-activities</link>
      <pubDate>Tue, 18 Dec 2018 21:39:51 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3365</guid>
      <description><![CDATA[When Creating, Renaming or Deleting (remove/unlinking) a file, Linux requires the direct parent...]]></description>
      <content:encoded><![CDATA[<p>When Creating, Renaming or Deleting (remove/unlinking) a file, Linux requires the direct parent directory to be synchronized.&nbsp; As documented in the manpage for <a href="https://linux.die.net/man/2/fsync">fsync</a> core changes to the directory require the directory itself to be synchronized.&nbsp; </p> <blockquote> <p><em>“Calling <b>fsync</b> does not ensure that the entry in the directory containing the file has also reached disk. For that an explicit <b>fsync</b> on a file descriptor for the directory is also needed.”</em></p></blockquote> <p>The SQL Server Host Extension provides file level integrity.&nbsp; When a move (rename), create, delete (remove/unlink) occurs the Host Extension issues a fsync on the parent directory as required by Linux.&nbsp; <p><strong>Note: </strong>Activates such as changes in the file size do not require synchronization of the direct parent.  <p><font color="#a5a5a5" size="1">Bob Dorr - Principal Software Engineer SQL Server</font></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Linux: fsync and Buffered I/O</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-linux-fsync-and-buffered-i-o</link>
      <pubDate>Tue, 18 Dec 2018 21:39:22 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3355</guid>
      <description><![CDATA[I was asked to validate&nbsp; the SQL Server behavior in light of the error condition involving...]]></description>
      <content:encoded><![CDATA[<p><font size="2">I was asked to validate&nbsp; the SQL Server behavior in light of the error condition involving <a href="https://man7.org/linux/man-pages/man2/fdatasync.2.html" target="_blank">fsync/fdatasync</a> outlined in this </font><a href="https://www.postgresql.org/message-id/flat/CAMsr%2BYE5Gs9iPqw2mQ6OHt1aC5Qk5EuBFCyG%2BvzHun1EqMxyQg%40mail.gmail.com#CAMsr+YE5Gs9iPqw2mQ6OHt1aC5Qk5EuBFCyG+vzHun1EqMxyQg@mail.gmail.com" target="_blank"><font size="2">article</font></a><font size="2">.&nbsp; </font></p> <p><font size="2"><strong>An example of the error:</strong> The application does a buffered write and receives success. (<em>This means data can be stored in file system cache, non-stable media.</em>)&nbsp; </font><font size="2">An fsync/fdatasync is used to make sure the data is stored in stable media.&nbsp; The stable media write(s) occurs during the sync operation and can fail for any number of reasons (out of disk space, lost connectivity to SAN, etc.) reporting an EIO error. </font></p> <p><font size="2"></font>&nbsp;</p> <p><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image82.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb76.png" width="453" height="166"></a></p> <p><font size="2">The issue, as described in the link, is that the sync returns the error but <em><font color="#ff0000">may clear the state of the cached pages</font></em>.&nbsp; The next sync returns ESUCCESS, meaning the the write(s), which were in cache, do not flush to stable media but applications were told they did.</font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image83.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb77.png" width="457" height="168"></a></p> <p><font color="#000000" size="2">Assume the database application opens the backup file, allowing file system caching (~_O_DIRECT.) <em><font color="#008080">SQL Server does NOT do this, in fact I made sure SQL Server on Linux does not allow this to occur.</font></em></font>  <p><font size="2">· Backup is started using buffered I/O<br></font><font size="2">· Writes occur to file system cache as the backup is progressing <br></font><font size="2">· An external call to sync occurs causing file system cache writes to take place<br></font><font size="2">· The sync encounters a write error on a buffer belonging to the backup.&nbsp; <em>The sync was called by an application outside database application so the database application is unaware of the failure</em>. <br></font><font size="2">· At the end of backup the database application issues fdatasync and instead of returning EIO, ESUCCESS is returned.<br></font><font size="2">· A successful fdatasync indicates a hardened to stable media backup and the database application then truncates the inactive part of the transaction log. </font> <p><font size="2">The database no longer has the proper log records to perform transaction operations or recovery and the <font color="#c0504d">backup file</font>, once thought to be valid, is <font color="#c0504d">invalid</font>. </font></p> <blockquote> <p align="left"><strong><font color="#008080" size="4">This issue does NOT impact SQL Server database, log and backup files.&nbsp; SQL Server opens these file types using O_DIRECT to bypass file system cache. Even when SQL Server on Linux is running in Forced Flush mode the files are opened with O_DIRECT, avoiding the issue.&nbsp; </font></strong></p></blockquote> <p><font color="#a5a5a5" size="1">Bob Dorr - Principal Software Engineer SQL Server</font></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server On Linux: Forced Unit Access (Fua) Internals</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-on-linux-forced-unit-access-fua-internals</link>
      <pubDate>Tue, 18 Dec 2018 21:37:39 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3305</guid>
      <description><![CDATA[&nbsp; Overview SQL Server relies on Forced-Unit-Access (Fua) I/O subsystem capabilities to provide...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <h3><a name="_Toc512277871"><font color="#000000">Overview</font></a></h3> <p><font size="2">SQL Server relies on Forced-Unit-Access (Fua) I/O subsystem capabilities to provide data durability, detailed in the following documents: </font><a href="https://technet.microsoft.com/en-us/library/cc966500.aspx" target="_blank"><font size="2">SQL Server 2000 I/O Basic</font></a><font size="2"> and </font><a href="https://technet.microsoft.com/en-us/library/cc917726.aspx" target="_blank"><font size="2">SQL Server I/O Basics, Chapter 2</font></a>  <blockquote> <p><font size="2"><b>Durability:</b> “In </font><a href="https://en.wikipedia.org/wiki/Database_system"><font size="2">database systems</font></a><font size="2">, <b>durability</b> is the </font><a href="https://en.wikipedia.org/wiki/ACID"><font size="2">ACID</font></a><font size="2"> property which guarantees </font><a href="https://en.wikipedia.org/wiki/Database_transaction"><font size="2">transactions</font></a><font size="2"> that have committed will survive permanently. For example, if a flight booking reports that a seat has successfully been booked, then the seat will remain booked even if the system crashes.” - </font><a href="https://en.wikipedia.org/wiki/Durability_(database_systems)"><font size="2">https://en.wikipedia.org/wiki/Durability_(database_systems)</font></a><font size="2"> </font></p></blockquote> <p><font size="2">Durability is a cornerstone of any database system and starting with SQL Server 2017 on Linux Cumulative Update 6 (CU6), SQL Server on Linux enables “Forced Flush” behavior as described in this <u><a href="https://support.microsoft.com/en-us/help/4131496">article</a></u>, improving durability on non-Fua optimized systems. </font> <p align="center"><font size="3"><em><strong><font color="#9b00d3">“Be sure to deploy <a href="https://www.microsoft.com/en-us/download/details.aspx?id=56128" target="_blank">SQL Server 2017 CU6 or newer</a> for best data durability and performance results.</font></strong>“</em></font>  <h3><a href="https://support.microsoft.com/en-us/help/967576/microsoft-sql-server-database-engine-input-output-requirements" target="_blank"><font size="4"><u>Microsoft SQL Server Database Engine Input/Output Requirements</u></font></a></h3> <h3><a name="_Toc512277872"><font color="#000000">The Back Story</font></a></h3> <p><font size="2">My involvement began when looking at the Write-Ahead-Logging (WAL) and the write behaviors on a Linux SQL Server. The investigation revealed that some of the Linux file systems may not be <em>Fua optimized</em>. Instead of passing the Fua bit with the write request (like Windows) Linux generates a separate device level flush request. Device level flushing may have an impact on your I/O caching, read ahead or other behaviors of the storage system. The “forced flush” changes in SQL Server avoid flushes, when possible, in order to improve performance on non-optimized Fua file systems.</font> </p> <table cellspacing="5" cellpadding="5" width="1047" border="2"> <tbody> <tr> <td valign="top" width="1033"> <p align="center"><font style="background-color: #000000" color="#00ff00"></font><font color="#9b00d3" size="4"><strong><font size="3">Starting with the <u>Linux 4.18 kernel</u> additions to the Linux <em>XFS</em> file system can send the Fua bit along with the write request so “forced flush” behavior is not needed and the performance of writes is significantly improved. Testing shows that by using the Fua bit with the data, write request can reduce the I/O traffic by ~50% for a SQL Server, write-intensive workload.</font>&nbsp; </strong></font></p></td></tr></tbody></table> <p><font size="2"><b><br>Performance points of reference:</b> The following charts highlight the increase in performance.</font><br> <p> <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td valign="top" width="180"> <p><b>4 Socket, TPCC</b>  <p>9,108 – Old kernel  <p><font color="#008080">36,618 – Patched kernel</font></p></td> <td valign="top" width="132"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image71.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb65.png" width="71" height="176"></a></td> <td valign="top" width="156"> <p><b>2 Socket, TPCC</b>  <p>9,606 – Old kernel  <p><font color="#008080">18,840 – Patched kernel</font></p></td> <td valign="top" width="138"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image72.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;margin: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb66.png" width="104" height="181"></a></td></tr></tbody></table></p> <p><font size="2">During my investigation, I traced, tested, reviewed, and instrumented the Linux kernel to understand the SQL Server I/O durability needs and associated impacts. This effort resulted in: </font> <p><font size="2">· Changes to the SQL Server Engine<br>· Changes to the SQL Server Linux Host Extension <br>· Validation with the Windows Storage team <br>· Validation with Windows Hyper-V team <br>· Validation with Windows Azure Storage team <br>· Conversations with Red Hat, HP, SUSE and Intel <br>· Changes in the Linux file system</font></p> <p><font size="2">Before all was said and done, all of these people and more helped with various activities: </font> <p><font size="2">· Eugene, Mike, Slava, Scott, Peter, Steve and others doing code reviews on my SQL Server and Host Extension changes.<br>· Val and Dylan performing power outage durability testing and adding new tests. <br>· Mitch and Ben doing functionality testing with the matrix of trace flags, mssql.conf options, Red Hat, Centos, Ubuntu, SUSE, and Windows using xfs, xfs<sup> opt</sup>, ext4, refs and ntfs. <br>· Pat validating Docker functionality and updating SQLIOSim to allow forced flush patterns. <br>· Patrick and Purvi doing performance and regression analytics. <br>· Kapil building and validating behavior on the Linux kernel changes for xfs (<strong>Note</strong>: I have tagged it <strong>xfs<sup> opt</sup></strong> (xfs optimizations) in this document for reference.) <br>· Amit, Lee, Vaqar and Mike handling release activities and documentation. <br>· Neal, Matt, and others from Windows Storage, Windows Azure Storage, Windows Hyper-V, … validating Windows behaviors. <br>· Red Hat, SUSE, HPE, Intel helping and confirming Linux behaviors and making file system code changes. <br>· Pradeep, Venu and Suresh handling support issues.</font><font size="2">&nbsp; </font></p> <p><em><font size="2">Special thanks to Dave Chinner and the Red Hat team, Dan Williams, Hamesh Patel and their colleagues from Intel, Scott Norton and his colleagues, Josh Paulson and members of the Microsoft Linux teams, Jan Kara from SUSE and many others.</font></em></p> <h3><font color="#000000"><span><font face="Calibri Light"><font style="font-size: 16pt">Terms</font></font></span></a><span></span> </font></h3> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"><span>Bef</span>ore diving into details the terminology is important.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <table class="MsoTable15List4Accent1" style="border-top: medium none;border-right: medium none;border-collapse: collapse;border-bottom: medium none;border-left: medium none;line-height: normal" cellspacing="0" cellpadding="0" width="833" border="1"> <tbody> <tr> <td style="border-top: #4472c4 1pt solid;border-right: medium none;background: #4472c4;border-bottom: #4472c4 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #4472c4 1pt solid;padding-right: 5.4pt" valign="top" width="192"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:;color:"><font color="#ffffff" size="2">Term</font></span></b></p></td> <td style="border-top: #4472c4 1pt solid;border-right: medium none;background: #4472c4;border-bottom: #4472c4 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="72"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:;color:"><font color="#ffffff" size="2">Type</font></span></b></p></td> <td style="border-top: #4472c4 1pt solid;border-right: #4472c4 1pt solid;background: #4472c4;border-bottom: #4472c4 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="567"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:;color:"><font color="#ffffff" size="2">Description</font></span></b></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="202"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Stable Media</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="81"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Concept</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="557"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Any storage device that can survive a power outage.<span>&nbsp; I</span>n the 90’s we talked about saving data on spinning media.<span>&nbsp; </span>SSDs, persistent memory, battery-backed controllers broaden the range of devices surviving power outage from traditional, spinning media.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="207"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">WAL</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="86"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Concept</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="552"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Write-Ahead Logging or journaling.<span>&nbsp; </span>The log records, which can be used to recreate the data, are stored in stable media before the data buffers are written and data buffers are stored in stable media before the supporting log records can be deleted.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="209"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Fua</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="88"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Hardware</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="550"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">Fua = </font><span style="color:"><a><span style="color:"><font color="#0563c1"><u>Forced Unit Access</u></font></span></a></span><font color="#000000">.<span>&nbsp; </span>Fua is the standard used to issue an I/O write command in stable data storage</font></font></span><span style="font-family:"><font color="#000000" size="2">.<span>&nbsp; </span>Fua has been a long-standing part of the SCSI specifications.&nbsp; <br><br><font color="#c0504d"><strong>Caution</strong>:</font> Non-SCSI storage implementations often silently ignore the request.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="210"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Device Flush </font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="89"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Hardware</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="550"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">A device level flush forces any dirty buffer located in volatile storage onto stable </font><a><font color="#000000" size="2">media</font></a></span><span style="font-family:"><font color="#000000" size="2">.&nbsp; Flushing a non-battery backed disk or cache device can be performance impacting and repeated device flush commands reduce the optimized capabilities, such as, writes near current head placement, wear level reduction, caching mechanisms, etc.<br></font></span><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">FILE_FLAG_NO_BUFFERING</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Windows</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">FILE_FLAG_NO_BUFFERING is the Win32, </font><span style="color:"><a><span style="color:"><font color="#0563c1"><u>CreateFile</u></font></span></a></span><font color="#000000"> API flags and attributes setting to bypass file system cache.<span>&nbsp; </span>This flag does NOT imply flush behaviors, only the avoidance of the system file cache.<span>&nbsp; </span>FILE_FLAG_NO_BUFFERING maps to the O_DIRECT flag for the Linux </font><span><a><span style="color:"><u><font color="#0563c1">open</font></u></span></a><font color="#0563c1"> </font></span><font color="#000000">command.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span style="font-family:;color:"><font color="#c00000"><strong>Warning</strong>: </font></span><span style="font-family:"><font color="#000000">The flag causes the file system cache of a guest VM to be bypassed but the VM or container may not pass the option to the host.</font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">O_DIRECT</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux open command flag used to bypass file system cache.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span style="font-family:;color:"><font color="#c00000"><strong>Warning</strong>: </font></span><span style="font-family:"><font color="#000000">The flag causes the file system cache of a guest VM to be bypassed but the VM or container may not pass the option to the host.</font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">FILE_FLAG_WRITE_THROUGH</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Windows</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">FILE_FLAG_WRITE_THROUGH is the Win32, </font><span style="color:"><a><span style="color:"><font color="#0563c1"><u>CreateFile</u></font></span></a></span><font color="#000000"> API flags and attributes setting </font></font><font color="#000000" size="2">generating</font> </span><span style="font-family:"><font color="#000000" size="2">Forced Unit Access (Fua) writes.<span>&nbsp; </span>A write honoring Fua is issued with the Fua flag and does not return from the write command until transferred to stable media.<span>&nbsp; </span></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">FILE_FLAG_WRITE_THROUGH maps to the O_DSYNC flag option for the Linux open command.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">The FILE_FLAG_WRITE_THROUGH flag does NOT imply FILE_FLAG_NO_BUFFERING behavior. To achieve no buffering and Fua, both the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH flags must be specified.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">O_DSYNC | fdatasync | RWF_ODSYNC</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">The O_DSYNC | RWF_ODSYNC | fdatasync indicate to the Linux file systems that the ‘data integrity standard’ is to be upheld for I/O operations.<span>&nbsp; </span>The data integrity standard makes sure the data and supporting meta data, needed to retrieve the data, are stored in stable media.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">O_SYNC and fsync indicate to the Linux file system to uphold the ‘file integrity standard.’<span>&nbsp; </span>O_SYNC is a superset of the O_DSYNC as the standard indicates that all file metadata (access timestamps for example) are stored in stable media.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">RWF_ODSYNC is a newer variation of O_DSYNC.<span>&nbsp; </span>The RWF_ODSYNC can be set as a flag for each I/O request.<span>&nbsp; </span>Whereas, opening the file with O_DSYNC establishes flushing behavior for all writes to the file.&nbsp; SQL Server does NOT make use of RWF_ODSYNC.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">FILE_FLAG_OVERLAPPED</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Windows</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">FILE_FLAG_OVERLAPPED is the Win32, </font><span style="color:"><a><span style="color:"><font color="#0563c1"><u>CreateFile</u></font></span></a></span><font color="#000000"> API flags and attributes setting enabling asynchronous API behavior.<span>&nbsp; </span>Control from APIs such as WriteFile and ReadFile returns as soon as the I/O is queued.<span>&nbsp; </span>The operating system signals completion when the I/O stack finishes the request.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">AIO | io_submit | Kernel I/O (kio)</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000"><font size="2">Linux provides different system calls (syscall)/commands for asynchronous behavior.<br><span>&nbsp; </span></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><font size="2"><span style="font-family:"><span>·<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family:"><a href="https://man7.org/linux/man-pages/man2/write.2.html" target="_blank">write</a> command – synchronous syscall, does not return until the write completes.</span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><font size="2"><span style="font-family:"><span>·<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family:"><a href="https://man7.org/linux/man-pages/man3/aio_write.3.html" target="_blank">aio_write</a> | io_submit – asynchronous syscall, returning control as soon as the I/O request is queued. SQL Server uses aio* for asynchronous I/O operations.</span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><font size="2"><span style="font-family:"><span><span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family:">&nbsp;</span></font></font></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Synchronized</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Concept</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Not to be confused with the synchronous behavior of the API/ABI invocations.<span>&nbsp; </span>In the context of I/O, synchronized indicates that the storage and in-memory copies of the data are the same.<span>&nbsp; </span>O_DSYNC often uses this term to indicate that the in-memory buffer is in sync with the storage media.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Data Integrity Standard</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Concept</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">This data integrity standard is a subset of the file integrity standard.<span>&nbsp; </span>In summary, the data integrity standard is the ability of the file system to store and retrieve data over a power outage.<span>&nbsp; </span>This includes the data itself as well as the tracking structures for the </font><a><font color="#000000" size="2">storage</font></a></span><span style="font-family:"><font color="#000000" size="2">.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <table class="MsoTableGrid" style="border-top: medium none;border-right: medium none;border-collapse: collapse;border-bottom: medium none;border-left: medium none" cellspacing="0" cellpadding="0" width="500" border="1"> <tbody> <tr> <td style="border-top: windowtext 1pt solid;border-right: windowtext 1pt solid;border-bottom: windowtext 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: windowtext 1pt solid;padding-right: 5.4pt" valign="top" width="498"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">This diagram shows a high-level view of a File.<span>&nbsp; </span>The file holds the metadata, made up of attributes (time of last access, permissions, …) as well as mappings to actual storage (sectors on a disk, pages on an SSD, …)</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Flush to stable media occurs for the data and storage mappings to achieve the data integrity standard.<br></font></span></p></td></tr> <tr> <td style="border-top: windowtext 1pt solid;border-right: windowtext 1pt solid;border-bottom: windowtext 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: windowtext 1pt solid;padding-right: 5.4pt" valign="top" width="498"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image73.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb67.png" width="366" height="122"></a></td></tr></tbody></table> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">Refer to the ISO documentation on data integrity for complete details. </font><span style="color:"><font color="#003300">CSA ISO/IEC 9945-1:2005 (R2009) 3.375 Synchronized I/O Data Integrity Completion</font></span></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">File Integrity Standard</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Concept</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">This file integrity standard is a superset of the data integrity standard.<span>&nbsp; </span>The file integrity standard is the ability for the file system to store and retrieve data and metadata written over a power outage including attributes such as the time of last access and permissions.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">Refer to the ISO documentation on file integrity for complete details: </font><span style="color:"><font color="#003300">CSA ISO/IEC 9945-1:2005 (R2009) 3.376 Synchronized I/O File Integrity Completion</font></span></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">O_NONBLOCK</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux open command flag value to avoid blocking during an I/O call.<span>&nbsp; </span>This is not a FILE_FLAG_OVERLAPPED implementation for the Linux ABIs.<span>&nbsp; </span>Instead, the flag is used to decide if a wait will occur while attempting to issue the I/O request.<span>&nbsp; </span>If the thread would become blocked the attempt to issue the request is aborted and control is returned to the caller.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Overlapped will issue the I/O and return STATUS_PENDING, whereas the O_NONBLOCK returns EAGAIN and the caller must retry the entire I/O operation.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">O_NOATIME</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux open command flag to avoid updating the time of last access which can reduce metadata writes.<span>&nbsp; </span>The O_NOATIME flag does NOT disable MTIME or CTIME modifications.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">REQ_FUA</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Block device write request using the Fua capabilities when performing a write.<span>&nbsp; </span>The Fua bit is sent with the write signaling stable media storage is required.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">REQ_PREFLUSH<br>REQ_POSTFLUSH</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">A block device write request (0 bytes – write[10, 12 or 16 bytes] SCSI command) requesting a device flush.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2"></font></span>&nbsp;</p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">DpoFua</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Linux</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">DPO = Disable Page Out (for writes instructs I/O subsystem to avoid adding write data to the cache, for reads prevents replacing existing entries in cache.)</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font size="2"><font color="#000000">Fua and Dpo are separate bit values in the </font><span class="MsoHyperlink"><a><font color="#0563c1"><u>SCSI SCB</u></font></a></span><font color="#000000">.<span>&nbsp; </span>SQL Server only requires Fua and not DPO capabilities.</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #8eaadb 1pt solid;padding-right: 5.4pt" valign="top" width="211"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Forced Flush Behavior</font></span></b></p></td> <td style="border-top: medium none;border-right: medium none;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="90"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SQL Server</font></span></p></td> <td style="border-top: medium none;border-right: #8eaadb 1pt solid;background: #d9e2f3;border-bottom: #8eaadb 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="549"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">When enabled the Linux SQL Server opens the file with FILE_FLAG_NO_BUFFERING and <em>without</em> FILE_FLAG_WRITE_THROUGH (<em>no FUA.</em>)<span>&nbsp; SQL Server </span>log and checkpoint made durable with calls to FlushFileBuffers.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p></td></tr></tbody></table> <div> <div id="_com_1" class="msocomtxt"> <h3>Common File Systems Used For SQL Server Deployments</h3> <table cellspacing="2" cellpadding="2" width="830" border="0"> <tbody> <tr> <td valign="top" width="71"><a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc758691(v=ws.10)" target="_blank">ntfs</a></td> <td valign="top" width="751">Windows New Technology File System</td></tr> <tr> <td valign="top" width="71"><a href="https://msdn.microsoft.com/en-us/windows/compatibility/resilient-file-system" target="_blank">refs</a></td> <td valign="top" width="751">Windows Resilient File System</td></tr> <tr> <td valign="top" width="71"><a href="https://en.wikipedia.org/wiki/XFS" target="_blank">xfs</a></td> <td valign="top" width="751">High performance, 64-bit journaling file system for Linux</td></tr> <tr> <td valign="top" width="71"><a href="https://en.wikipedia.org/wiki/Ext4" target="_blank">ext4</a></td> <td valign="top" width="751">Fourth extended file system with journaling for Linux</td></tr></tbody></table> <h3><a href="https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-release-notes?view=sql-server-2017" target="_blank"><font size="3">Supported platforms and file systems for SQL Server on Linux</font></a></h3> <h3>Handling of Fua</h3> <p><font size="2">The <strong>Linux</strong> Host Extension(HE) and <a href="https://cloudblogs.microsoft.com/sqlserver/2016/12/16/sql-server-on-linux-how-introduction/" target="_blank">SQLPAL</a> work together to translate Win32 CreateFile, WriteFile, ReadFile and other I/O calls into Linux system calls. SQL Server opens data and log files using CreateFile with FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH. The flags are converted to the Linux <i>open</i> system call using the O_DIRECT and O_DSYNC flags, respectively.</font></p></div></div> <p><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image110.png"><font size="2"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image1_thumb.png" width="666" height="290"></font></a></p> <p><font size="2">When SQL Server performs a write, using a file opened with FILE_FLAG_WRITE_THROUGH(O_DSYNC), Linux performs the multi-step operation as a data write followed by the complete device flush request instead of adding the Fua bit to the data write request.</font><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image74.png"><font size="2"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb68.png" width="770" height="170"></font></a></p> <p><font size="2">&nbsp; </font> <ol> <li><font size="2">Issue write to block device for the data</font>  <li><font size="2">Receive the data write complete event in the block device’s write completion routine</font>  <li><font size="2">If O_DSYNC requested, issue block device flush </font> <li><font size="2">Wait for block device flush request completion</font>  <li><font size="2">Return control to write caller</font></li></ol> <p><font size="2">Every write, requiring O_DSYNC behavior, also invokes a block device flush on Linux.&nbsp; The repeated use of a <em>write request followed by a flush request</em> may be detrimental to performance and will increase traffic on the I/O bus.</font>  <p align="center"><font color="#9b00d3"><font size="3"><strong>Note: </strong>The 4.18 Linux Kernel updates allow the XFS file system and a device supporting Fua writes to avoid the additional block device flush request. </font></font></p> <p><font size="2">Prior to the Linux Kernel 4.18 updates, Linux could use Fua but only for the file system journaling writes and not data writes.&nbsp; Linux queries the device for the DpoFua support capabilities and when the device reports Fua support (DpoFua = 1) the journaling is optimized to use Fua writes.&nbsp; The data storage always uses the multi-step flush process.&nbsp; </font> <p><font size="2"><strong>Windows </strong>does NOT query the device for support, instead any file opened with FILE_FLAG_WRITE_THROUGH sends the Fua option with the write request where the target device is expected to honor the Fua option.&nbsp; <em>In some instances, the target silently ignores the request.</em> The Windows implementation places the responsibility of making sure the I/O subsystem is Fua compliant on the database and system administrator.</font>  <h3><a>Fua (Forced Unit Access)</a></h3> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Microsoft SQL Server requires Fua compliant storage (stable media) ensuring the data is stored in stable media before a write request returns to SQL Server.<span>&nbsp; </span>For example, if you run SQL Server on an IDE or SATA drive, you may need to disable the physical disk cache to accommodate WAL (durability), requirements. The SQL Server 2017 CU6, forced flush feature, provides durability assistance on Linux systems without Fua.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><font color="#000000"><font size="2"><b><span style="font-family:">Note:</span></b><span style="font-family:"><span>&nbsp; </span>Disabling the write cache using the Windows, properties dialog may not suffice.<span>&nbsp; </span>Some drives are not compliant with the dialog options and require special utilities to configure the drive cache.<span>&nbsp; </span>Linux may need similar utilities to control various hardware cache installations.</span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal" align="justify"><span style="font-family:"><font color="#000000" size="2">You can explore your system using the <em>df</em> and <em>lsblk</em> commands.<span>&nbsp; </span>When Linux mounts a block device, Linux queries the attributes and capabilities of the block device.<span>&nbsp; </span>One such capability is the ability to support DpoFua for write requests.<span>&nbsp; </span><strong>When <em><font style="background-color: #000000" color="#00ff00">DpoFua=1</font></em> is reported, the device is reporting support for </strong></font><a><font color="#000000" size="2"><strong>Fua</strong></font></a>.</span><span style="font-family:"><font color="#000000" size="2"></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal" align="justify"><font color="#000000"><font size="2"><span><br><strong>Note</strong>: These commands may require root permissions to execute.</span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><span style="font-family:"><font style="font-size: 8pt" color="#000000">&nbsp;</font></span></p> <h4 style="margin: 2pt 0in 0pt 0.5in;line-height: 12pt"><span><font face="Calibri Light"><font style="font-size: 11pt" color="#2f5496"><em>df -T</em></font></font></span></h4> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 8pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">Filesystem<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Type<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>1K-blocks<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>Used Available Use% Mounted on</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">devtmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>devtmpfs<span>&nbsp;&nbsp; </span>4062840<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp; </span>4062840<span>&nbsp;&nbsp; </span>0% /dev</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4078624<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp; </span>4078624<span>&nbsp;&nbsp; </span>0% /dev/shm</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4078624<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>8880<span>&nbsp;&nbsp; </span>4069744<span>&nbsp;&nbsp; </span>1% /run</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>4078624<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp; </span>4078624<span>&nbsp;&nbsp; </span>0% /sys/fs/cgroup</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">/dev/mapper/cl-root xfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>52403200 13010400<span>&nbsp; </span>39392800<span>&nbsp; </span>25% /</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:;color:"><font face="Courier New"><font style="font-size: 9pt;background-color: #000000" color="#ffd966">/dev/sda1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>xfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1038336<span>&nbsp;&nbsp; </span>431168<span>&nbsp;&nbsp;&nbsp; </span>607168<span>&nbsp; </span>42% /boot</font></font></span><span style="font-family:;color:"></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">/dev/mapper/cl-home xfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>114361796 22488816<span>&nbsp; </span>91872980<span>&nbsp; </span>20% /home</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>tmpfs<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>815728<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp;&nbsp; </span>815728<span>&nbsp;&nbsp; </span>0% /run/user/1000</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><span style="font-family:"><font style="font-size: 8pt" color="#000000">&nbsp;</font></span></p> <h4 style="margin: 2pt 0in 0pt 0.5in;line-height: 12pt"><span><font face="Calibri Light"><font style="font-size: 11pt" color="#2f5496"><em>lsblk</em></font></font></span></h4> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 8pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">NAME<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>MAJ:MIN RM<span>&nbsp;&nbsp; </span>SIZE RO TYPE MOUNTPOINT</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">fd0<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>2:0<span>&nbsp;&nbsp;&nbsp; </span>1<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>4K<span>&nbsp; </span>0 disk</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">sda<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>8:0<span>&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp; </span>168G<span>&nbsp; </span>0 disk</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:;color:"><font face="Courier New"><font style="font-size: 9pt;background-color: #000000" color="#ffd966">├─sda1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>8:1<span>&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>1G<span>&nbsp; </span>0 part /boot</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">└─sda2<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>8:2<span>&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp; </span>167G<span>&nbsp; </span>0 part</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">├─cl-root 253:0<span>&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp;&nbsp; </span>50G<span>&nbsp; </span>0 lvm<span>&nbsp; </span>/</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">├─cl-swap 253:1<span>&nbsp;&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp; </span>7.9G<span>&nbsp; </span>0 lvm<span>&nbsp; </span>[SWAP]</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">└─cl-home 253:2<span>&nbsp;&nbsp;&nbsp; </span>0 109.1G<span>&nbsp; </span>0 lvm<span>&nbsp; </span>/home</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">sdb<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>8:16<span>&nbsp;&nbsp; </span>0<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>1G<span>&nbsp; </span>0 disk</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">sr0<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>11:0<span>&nbsp;&nbsp;&nbsp; </span>1<span>&nbsp; </span>1024M<span>&nbsp; </span>0 rom</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span style="font-family:"><font color="#000000">The </font></span><span style="font-family:;color:"><font style="background-color: #000000" color="#ffd966">/dev/sda1</font></span><span style="font-family:"><font color="#000000"> entry reports an <b>xfs</b> file system and the device id of <b>8:1 (major:minor.)</b> <span>&nbsp;</span>The block device is sda (8:0.)<span>&nbsp; </span>The entries for sda1, sda2 are partitions on the same block </font><a><font color="#000000">device</font></a>.</span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">You may also use <em>lshw</em> to explore disk information such as sector size and vendor which are helpful in determining additional device details.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <h4 style="margin: 2pt 0in 0pt 0.5in;line-height: 12pt"><span><font face="Calibri Light"><font style="font-size: 11pt" color="#2f5496"><em>lshw -class disk</em></font></font></span></h4> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 8pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><font face="Courier New"><font color="#000000"><span style="font-family:"><span><font style="font-size: 8pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><span style="font-family:"><font style="font-size: 9pt">description: SCSI Disk</font></span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">product: Virtual Disk</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">vendor: Msft</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">physical id: 0.0.0</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">bus info: scsi@0:0.0.0</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">logical name: /dev/sda</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">version: 1.0</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">size: 168GiB (180GB)</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">capabilities: partitioned partitioned:dos</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><font style="font-size: 9pt">configuration: ansiversion=5 </font></font><font style="font-size: 9pt"><span style="color:"><font style="background-color: #000000" color="#ffd966">logicalsectorsize=512 sectorsize=4096</font></span><font color="#000000"> signature=000a0600</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Use <em>dmsg</em> or <em>sg_modes</em> to reveal the DpoFua state.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 8pt" color="#000000">&nbsp;</font></span></p> <h4 style="margin: 2pt 0in 0pt 0.5in;line-height: 12pt"><span><font face="Calibri Light"><font style="font-size: 11pt" color="#2f5496"><em>dmesg | grep sda</em></font></font></span></h4> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>1.266561] sd 0:0:0:0: [sda] 352321536 512-byte logical blocks: (180 GB/168 GiB)</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>1.266562] sd 0:0:0:0: [sda] 4096-byte physical blocks</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>1.266892] sd 0:0:0:0: [sda] Write Protect is off</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>1.266894] sd 0:0:0:0: [sda] Mode Sense: 0f 00 10 00</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><font style="font-size: 9pt">[<span>&nbsp;&nbsp;&nbsp; </span>1.266949] sd 0:0:0:0: <span><font style="background-color: #000000" color="#f79646">[</font></span></font></font><span style="color:"><font style="font-size: 9pt;background-color: #000000" color="#ffd966">sda] Write cache: enabled, read cache: enabled, supports DPO and Fua</font></span></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>1.271227]<span>&nbsp; </span>sda: sda1 sda2</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>1.274579] sd 0:0:0:0: [sda] Attached SCSI disk</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>4.637845] XFS (sda1): Mounting V5 Filesystem</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">[<span>&nbsp;&nbsp;&nbsp; </span>4.661270] XFS (sda1): Ending clean mount</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><font color="#000000"><b><span style="font-family:"><font style="font-size: 9pt">Note:</font></span></b><span style="font-family:"><font style="font-size: 9pt"><span>&nbsp; </span>/dev/sda is the block device and /dev/sda1, /dev/sda2 are partitions of the block device.</font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 8pt" color="#000000">&nbsp;</font></span></p> <h4 style="margin: 2pt 0in 0pt 0.5in;line-height: 12pt"><font face="Calibri Light"><font style="font-size: 11pt" color="#2f5496"><em>sg_modes /dev/sda1</em></font></font></h4> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 8pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><font face="Courier New"><font color="#000000"><span style="font-family:"><span><font style="font-size: 8pt">&nbsp;&nbsp;&nbsp; </font></span></span><span style="font-family:"><font style="font-size: 9pt">Msft<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Virtual Disk<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>1.0<span>&nbsp;&nbsp;&nbsp; </span>peripheral_type: disk [0x0]</font></span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">Mode parameter header from MODE SENSE(10):</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><font face="Courier New"><span style="font-family:"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">Mode data length=20, medium type=0x00, WP=0, </font></font></span><font style="font-size: 9pt"><span style="font-family:;color:"><font style="background-color: #000000" color="#ffd966">DpoFua=1,</font></span></font><span style="font-family:"><font style="font-size: 9pt" color="#000000"> longlba=0</font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><span><font style="font-size: 9pt">&nbsp; </font></span><font style="font-size: 9pt">Block descriptor length=0</font></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">&gt;&gt; Caching, page_control: current</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font style="font-size: 9pt" color="#000000">00<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>08 0a 04 00 00 00 00 00<span>&nbsp; </span>00 00 00 00</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 8pt" color="#000000">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">If your system supports Fua and you have the Linux Kernel 4.18 or newer updates, you can enable SQL Server trace flag -T3979 and use /opt/mssql/bin/mssql-conf set control.alternatewritethrough 0.<span>&nbsp; </span>SQL Server will use Fua write behavior patterns instead of Forced Flush.<span>&nbsp; </span>File systems supporting optimized Fua align SQL Server on Linux with SQL Server on Windows behavior and performance.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <blockquote> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"></span><font color="#000000"><font size="2"><b><span style="font-family:">Note:</span></b><span style="font-family:"> If DpoFua=0 is reported the Linux file systems revert to the write, flush behavior to support O_DSYNC.<span>&nbsp; </span>If you are unsure about the Fua support use forced flush behavior.</span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font color="#000000"><font size="2"><span style="font-family:"></span></font></font>&nbsp;</p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font color="#000000"><font size="2"><span style="font-family:"></span></font></font><font color="#000000"><font size="2"><span style="font-family:"><strong>Note:</strong> DpoFua optimizations may be ignored during the first data write to an offset in the file, as documented <a href="https://blogs.msdn.microsoft.com/bobsql/2018/12/10/sql-server-instant-file-initialization-setfilevaliddata-windows-vs-fallocate-linux/" target="_blank">here</a>.</span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font color="#000000"><b><span style="font-family:"><font size="2">Note:</font></span></b><span style="font-family:"><font size="2"> Some systems embellish the Fua support capabilities.<span>&nbsp; </span>You should always validate the Fua capabilities with your device and hardware vendor.</font></span></font></p></blockquote> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><a name="_Toc512277883">Beware The Cache</a></p> <div style="line-height: normal"> <p class="msocomtxt"><font size="2">Disk drives often employ non-battery backed caches, even SSD drives can contain volatile, staging caches. Make sure the entire I/O stack from the SQL Server to the stable media location honors the Fua intent properly. </font> <h3 class="msocomtxt">blktrace: <a name="_Toc512277884"><font color="#000000">Block Trace Shows All</font></a></h3> <p class="msocomtxt">A great place to start understanding how Linux is handling Fua requests is block trace (<em>blktrace</em>.) The block trace allows you to monitor I/O requests and the associated options being used.&nbsp; <p class="msocomtxt">The blktrace command and format options are documented <a href="https://man7.org/linux/man-pages/man8/blktrace.8.html" target="_blank">here</a>. The following example traces the block device (/dev/sda.)&nbsp; <font size="2">This sample outputs <i>the timestamp, pid, sector, device major:minor, command, sequence, action, flags, block count and worker information</i>. </font> <p class="msocomtxt"><b><i>blktrace -d /dev/sda -o - | blkparse -i - </i></b><b><i>-f "%5T.%9t %10p %-10S %D %2c %8s %2a %3d %10n %32C\n</i></b><b><i>"</i></b>  <div> <ol> <li> <div class="msocomtxt"><font size="2">The sample output shows an O_DIRECT | O_DSYNC write from the IOPerfTest </font><a><font color="#000000" size="2">application</font></a>&nbsp;<font size="2">(<em>source contained at end of this blog</em>) on a non-optimized, Linux file system.<br></font></div> <li> <div class="msocomtxt">The <b>WS</b> flags indicate (<strong>W</strong>)rite at sector 16518176 with (<strong>S</strong>)ynchronized behavior (buffer and storage match.) The (Act)ion column shows the I/O request being (I)nserted into the (Q)ueue and the system workers performing, (G)etting, the <b>FWS</b> request.</div></li></ol></div> <blockquote> <p class="msocomtxt"><font size="2" face="Courier New">Timestamp PID Sector Device Cmd Seq Act Flags Block Count </font> <p class="msocomtxt"><font size="2" face="Courier New">3.636934795&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 16518176&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 443&nbsp; 3348&nbsp; A&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest &lt;—I/O started<br></font><font size="2" face="Courier New">3.636935395&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 18617376&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 444&nbsp; 3348&nbsp; A&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font><font size="2" face="Courier New">3.636936095&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 18617376&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 445&nbsp; 3348&nbsp; Q&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font><font size="2" face="Courier New">3.636941795&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 18617376&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 446&nbsp; 3348&nbsp; G&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font><font size="2" face="Courier New">3.636942295&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 447&nbsp; 3348&nbsp; P&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font><font size="2" face="Courier New">3.636945195&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 18617376&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 448&nbsp; 3348&nbsp; I&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font><font size="2"><font face="Courier New">3.636946295&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 449&nbsp; 3348&nbsp; U&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font><font face="Courier New">3.636947795&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3348 18617376&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 450&nbsp; 3348&nbsp; </font></font><i><font size="2" face="Courier New">D&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest<br></font></i><font size="2" face="Courier New">3.638838077&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3054 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 452&nbsp; 3054&nbsp; A <font style="background-color: #ff0000" color="#ffffff">FWS</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/7:2<br></font><font size="2" face="Courier New">3.638838677&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3054 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 453&nbsp; 3054&nbsp; Q FWS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/7:2<br></font><font size="2" face="Courier New">3.638843177&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3054 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 454&nbsp; 3054&nbsp; G FWS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/7:2<br>3.638844377&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3054 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 455&nbsp; 3054&nbsp; I FWS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/7:2 &lt;-I/O completed</font></p></blockquote> <p class="msocomtxt"><b><i></i></b> <ul> <li> <div class="msocomtxt"><font color="#9b00d3" size="3">A <b>FWS</b> with block count of 0 is the block device flush command</font></div> <li> <div class="msocomtxt"><font color="#9b00d3" size="3">A <strong>WFS</strong> is a REQ_WRITE with the REQ_FUA request</font></div></li></ul> <p class="msocomtxt">When the ‘FW’ pattern is present it shows a REQ_PREFLUSH | REQ_WRITE being sent to the device<b>. What we are really looking for is a ‘WFS’ request showing a REQ_WRITE with REQ_FUA, <em>without</em> <em>the secondary FWS request</em>, using optimized Fua capabilities and avoiding the secondary flush</b><b>. </b> <p class="msocomtxt"><strong><font color="#9b00d3">Until Linux Kernel 4.18, XFS, the REQ_FUA is not honored for data requests, only journaling, and is always performed as an additional device flush request FWS.</font> </strong> <p class="msocomtxt">To achieve best performance and durability you want the <b>WFS</b> (Write, REQ_FUA, Synchronized) pattern without <b>FWS</b> for each write.&nbsp; The output below is the block trace output on an XFS file system using optimized Fua capabilities.  <blockquote> <p class="msocomtxt"><font size="2" face="Courier New">13.944683500 2948 25671928 8,0 0 120245 I <b>WFS</b> 8 IOPerfTest &lt;- D=<b>Issued</b>, WFS=Write,REQ_FUA &lt;—I/O started<br>13.944683500 2948 25671928 8,0 0 120246 D <b><font style="background-color: #000000" color="#00ff00">WFS</font></b> 8 IOPerfTest &lt;- D=<b>Completed</b>, WFS=Write,REQ_FUA &lt;-I/O completed</font></p></blockquote> <p><font size="2">The following diagram shows the shortened path to perform a Fua optimized write.</font></p> <h3><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image75.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb69.png" width="815" height="94"></a></h3> <h3><a><font color="#000000">Using O_DIRECT and O_DSYNC Properly</font></a></h3> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span style="font-family:"><font color="#000000">There are conditions in the Linux file system which require kernel ‘<em>fix-ups</em>’ in order to support the I/O request. <span style="font-family:"><font color="#000000">If the request does not meet the expected criteria a new, kernel buffer(s) </font><a><font color="#000000">is</font></a></span><span style="font-family:"><font color="#000000"> created, data copied, block device transfers completed using the temporary buffer(s) and then the temporary buffer is released.<span>&nbsp; Using </span></font></span></font></span><span style="font-family:"><font color="#000000">the Linux file system tracing you can confirm the direct I/O request is aligned on the proper memory boundary for DMA transfer, offset starts on a block device boundary, etc. to avoid temporary buffered activities.</font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 8pt" color="#000000">&nbsp;</font></span></p> <h4>Enabling Trace (xfs, ext4, block device tracing)</h4> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.75in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000" size="2">echo 1 &gt; /sys/kernel/debug/tracing/events/block/enable</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.75in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000" size="2">echo 1 &gt; /sys/kernel/debug/tracing/events/xfs/enable</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.75in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000" size="2">echo 1 &gt; /sys/kernel/debug/tracing/events/ext4/enable</font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.75in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000" size="2"><em>… run reproduction …</em></font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.75in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><font size="2">cat /sys/kernel/debug/tracing/trace</font> </font></font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span><font color="#000000">The trace output shows a direct write and the file </font></span><span style="font-family:"><font color="#000000">system performing a flush </font><font style="background-color: #000000" color="#ffff00">(</font><span style="color:"><font style="background-color: #000000" color="#ffd966">generic_write_sync-&gt;xfs_file_fsync.)</font></span></span><span><font color="#000000">.<span>&nbsp; </span><span>&nbsp;</span><em><font style="background-color: #809ec2"></font></em></font></span></font><span><em>Removing generic_write_sync from each write is key to how optimized Fua improves performance.</em></span><font size="2"><span><font color="#000000"><em><font style="background-color: #809ec2"></font></em></font></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font face="Calibri"><font style="font-size: 9pt" color="#000000">&nbsp;</font></font></span></p> <blockquote> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>_-----=&gt; irqs-off</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>/ _----=&gt; need-resched</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>| / _---=&gt; hardirq/softirq</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>|| / _--=&gt; preempt-depth</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>||| /<span>&nbsp;&nbsp;&nbsp;&nbsp; </span>delay</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>TASK-PID<span>&nbsp;&nbsp; </span>CPU#<span>&nbsp; </span>||||<span>&nbsp;&nbsp;&nbsp; </span>TIMESTAMP<span>&nbsp; </span>FUNCTION</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 27pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">#<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>| |<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>|<span>&nbsp;&nbsp; </span>||||<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>|<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>|</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest-2733&nbsp; [004] ....&nbsp;&nbsp; 264.566322: xfs_file_direct_write: dev 253:2 ino 0x69 size 0x100000 offset 0xae000 count 0x2000</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest-2733&nbsp; [004] ....&nbsp;&nbsp; 264.566324: xfs_ilock: dev 253:2 ino 0x69 flags ILOCK_EXCL caller xfs_file_iomap_begin [xfs]</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest-2733&nbsp; [004] ....&nbsp;&nbsp; 264.566325: xfs_iunlock: dev 253:2 ino 0x69 flags ILOCK_EXCL caller xfs_file_iomap_begin [xfs]</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest-2733&nbsp; [004] ....&nbsp;&nbsp; 264.566325: xfs_iomap_found: dev 253:2 ino 0x69 size 0x100000 offset 0xae000 count 8192 type invalid startoff 0xae startblock 272 blockcount 0x2</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000" face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IOPerfTest-2733&nbsp; [004] ....&nbsp;&nbsp; 264.566345: xfs_iunlock: dev 253:2 ino 0x69 flags IOLOCK_SHARED caller xfs_file_dio_aio_write [xfs]</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 1in;line-height: normal"><span style="font-family:"><font face="Courier New"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp; kworker/4:1-110&nbsp;&nbsp; [004] ....&nbsp;&nbsp; 264.566761: </font></font><font style="font-size: 9pt"><span style="color:"><font style="background-color: #000000" color="#ffd966">xfs_end_io_direct_write</font></span><font color="#000000">: dev 253:2 ino 0x69 isize 0x100000 disize 0x100000 offset 0xae000 count </font></font><span style="color:"><font style="font-size: 9pt;background-color: #000000" color="#ffd966">8192</font></span></font></span></p><span style="font-family:;line-height: 10pt"><font face="Courier New"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp; kworker/4:1-110&nbsp;&nbsp; [004] ....&nbsp;&nbsp; 264.566763: </font></font><font style="font-size: 9pt"><span style="color:"><font style="background-color: #000000" color="#ffd966">xfs_file_fsync</font></span><font color="#000000">: dev 253:2 ino 0x69</font></font></font></span><font face="Times New Roman"><font style="font-size: 12pt" color="#000000"> </font></font></blockquote> <h3>Forced Flush Behavior</h3> <p class="msocomtxt">From the first research I did, it would appear that you just have to do things differently on Linux than Windows to achieve durability.&nbsp; However, I have spent two decades working with Fua on Windows and the block traces were telling me a different story.&nbsp; The journaling was using Fua writes and that lead to the lengthy discussion and changes in the Linux 4.18 kernel to enable optimized Fua writes for data.&nbsp; However, that still left SQL Server with a requirement to run on Linux installations that are not Fua optimized, which became the source of forced flush settings.&nbsp; (For reference:&nbsp; As I studied the problem I found that other database vendors provide settings and adjustments to control fsync* calls or open file with and without O_DSYNC.)  <p class="msocomtxt">The forced flush behavior is a choreographed sequence between SQL Server, SQLPAL and the Host Extension (HE.)&nbsp; To accommodate a wide range of installations and hardware required four (4) options across SQL Server and the HE.&nbsp; Before we dive into the options, let’s first take a look at the forced flush behavior activities employed by SQL Server.  <p class="msocomtxt">When in forced flush mode, SQL Server assumes the system does NOT provide Fua capabilities and instead issues FlushFileBuffers (translated to <a href="https://linux.die.net/man/2/fsync" target="_blank">fdatasync</a> on Linux) at critical locations.&nbsp; The following shows the flow to harden the transaction log for a commit request.  <p class="msocomtxt">&nbsp; <p class="msocomtxt"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image76.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb70.png" width="402" height="206"></a>  <p class="msocomtxt">&nbsp; <ol> <li> <div class="msocomtxt">A commit requests that all Log Sequence Numbers (LSN) are stored in stable media up to and including the commit record</div> <li> <div class="msocomtxt">The commit record is added to the log buffer</div> <li> <div class="msocomtxt">The log buffer is closed out and written to disk (Only no buffering requested)</div> <li> <div class="msocomtxt">Write completes and FlushFileBuffers is issued to harden</div></li></ol> <p class="msocomtxt">The advantage of allowing the SQL Server log writer to issue FlushFileBuffers is a reduction in flush requests over the default write, flush of the Linux kernel.&nbsp; SQL Server can pack multiple log records from multiple sessions in the same log buffer and log buffers without commit requests don’t require individual flush requests.&nbsp; When the flush request occurs, all previous writes achieve hardened state via the block device flush request.  <p class="msocomtxt">The following diagram shows the SQL Server checkpoint activity with forced flush behavior is enabled.&nbsp; Since the writes are not being done with Fua, FlushFileBuffers for all the files in the database takes place at the conclusion of the checkpoint.&nbsp; The individual writes take place with no buffering and at the end of the checkpoint phase, the data is hardened.&nbsp; Only after the FlushFileBuffer calls successfully occur can the log records can be truncated.  <p class="msocomtxt">&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/2018/12/image77.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb71.png" width="564" height="211"></a>  <blockquote> <p><font size="2"><strong>Note:</strong> SQL Server In-memory optimized, File Stream, Backup and other storage operations issue FlushFileBuffers as well.&nbsp; For example, a backup is not considered complete until FlushFileBuffers returns successfully.&nbsp; If FlushFileBuffers returns a failure the backup is terminated in error.</font></p></blockquote> <h3>Settings and Adjustments</h3> <p class="msocomtxt"><strong>SQL Server Trace Flags<br></strong>The forced flush behavior is controlled using SQL Server trace flags.&nbsp; </p> <p class="msocomtxt"><strong>Note: </strong>These flags are global (startup only) to the SQL Server instance.&nbsp; The entire SQL Server instance uses the configured settings.</p> <table cellspacing="0" cellpadding="0" width="1150" border="1"> <tbody> <tr> <td valign="top" width="62"> <p><b>Flag</b></p></td> <td valign="top" width="568"> <p><b>Description</b><b></b></p></td> <td valign="top" width="518"><strong>The Elevator Pitch (thanks to Jamie Burroughs)</strong></td></tr> <tr> <td valign="top" width="62"> <p><b>-T3979</b></p></td> <td valign="top" width="568"> <p><b>“Request Fua Writes”</b>  <p>SQL Server opens database data and log files with FILE_FLAG_WRITE_<a></a>THROUGH, mapping to O_DSYNC in the Host Extension, asking for Fua writes.&nbsp; <p><strong>Linux Default:</strong> Trace flag considered Off <strong>*</strong><br><strong>Windows Default:</strong> Trace flag considered On <strong>**</strong></p><strong>*</strong> The trace flag does not apply to SQL Server on Linux SQL 2017 RTM thru CU5.&nbsp; The behavior is assumed enabled prior to CU 6. <br><br><strong>**</strong> The trace flag does not apply to Windows.&nbsp; On Windows it is always assumed to be enabled. </td> <td valign="top" width="518">On Linux, you need a file system that provides DpuFua=1 enablement or you have confirmed your system is O_DIRECT safe.&nbsp;&nbsp; <br><br>By enabling the trace flag you disable the batch flush requests from SQL Server and are trusting SQLPAL, HE and the I/O subsystem configuration to achieve durability.<br><br><br><br></td></tr> <tr> <td valign="top" width="62"> <p><b>-T3982</b></p></td> <td valign="top" width="570"> <p><b>“Avoid Fua Writes”</b>  <p>Forces SQL Server to open database data and log files without FILE_FLAG_WRITE_THROUGH and issue the FlushFileBuffers calls to complete transactions and checkpoint activities.  <p><strong>Linux Default:</strong> Trace flag is considered On<br><strong>Windows Default:</strong> Trace flag is considered Off <strong>*</strong>  <p><strong>*</strong>Microsoft retains the policy that SQL Server should always be run on a system with stable media configurations.&nbsp; The trace flag is NOT supported on Windows.</p> <p><a href="https://support.microsoft.com/en-us/help/86903/description-of-caching-disk-controllers-in-sql-server" target="_blank">This article</a> highlights these support boundaries.&nbsp; It was written by David Campbell, Bob Ward, Keith Elmore and I many years ago and the forced flush feature does not alter the intent: <em>“SQL Server requires systems to support ‘ guaranteed delivery to stable media ’ as outlined under the Microsoft SQL Server Always-On Storage Solution Review program.&nbsp; For more information about the input and output requirements for the SQL Server database engine.”</em></p></td> <td valign="top" width="586">When running on Linux kernels or file systems that do not support optimized Fua capabilities.<br><br><em>The trace flag and forced flush behavior is intended to be a workaround for Linux installations until the SQL Server instance id deployed on a system providing optimized, Fua capabilities.</em></td></tr></tbody></table></div> <div style="line-height: normal">&nbsp;</div> <div style="line-height: normal"><strong>Host Extension Settings</strong></div> <div style="line-height: normal">The trace flags provide the ability to control how SQL Server requests write behavior and the associated hardening activities.&nbsp; The Host Extension (HE) provides 2 control options (control.writethrough and control.alternatewritethrough) which can be configured using <a href="https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf?view=sql-server-2017" target="_blank">mssql-conf set</a>.</div> <div style="line-height: normal">&nbsp;</div> <div style="line-height: normal"><strong>Note: </strong>These flags are global (startup only) for the entire SQLPAL instance.</div> <div style="line-height: normal"><a name="_msocom_1"></a>&nbsp;</div> <div style="line-height: normal"> <table cellspacing="0" cellpadding="0" width="1149" border="1"> <tbody> <tr> <td valign="top" width="144"> <p><b>Setting</b><b></b></p></td> <td valign="top" width="57"> <p><b>Default</b><b></b></p></td> <td valign="top" width="503"> <p><b>Description</b><b></b></p></td> <td valign="top" width="443"><strong>The Elevator Pitch</strong></td></tr> <tr> <td valign="top" width="144"> <p><b>writethrough</b></p></td> <td valign="top" width="57"> <p>1</p></td> <td valign="top" width="503"> <p>Used to mask the O_DSYNC flag for the open invocation.  <ul> <li>1 = If FILE_FLAG_WRITE_THROUGH requested, retain O_DSYNC.<br> <li>0 = If FILE_FLAG_WRITE_THROUGH is NOT requested, remove O_DSYNC.</li></ul></td> <td valign="top" width="443">For most installations it is unsafe to disable the write-through.&nbsp; For example, SQL Server 2019 supports DTC/XA transactions.&nbsp; Disabling write through could compromise the DTC transaction logging durability.<br><br>If your system is deemed O_DIRECT safe it may be acceptable to disable write-through.<br><br>When DpoFua = 0 or you are on a non-Fua optimized installation, you may need to disable the write through.&nbsp; By removing the O_DSYNC from the open, you remove the write, flush Linux kernel activity.&nbsp; However, you must configure SQL Server with –T8932 to maintain durability.&nbsp; A safer choice, for this situation, is to maintain write through and enable alternate write through behavior.<br></td></tr> <tr> <td valign="top" width="144"> <p><b>alternatewritethough</b></p></td> <td valign="top" width="57"> <p>1</p></td> <td valign="top" width="504"> <p>Controls how the write, flush behavior takes place.&nbsp; When enabled the HE opens the file without O_DSYNC and during I/O completion, batches fdatasync requests based on the major, parent device id.  <ul> <li>1 = Enables optimized flushing by the Host Extension for FILE_FLAG_WRITE_THROUGH requests.  <p>Writes needing the alternate flush behavior are grouped by the block device id to reduce the number of fdatasync requests. <br></p> <li>0 = Disables the alternate flush optimizations. The file is opened with O_DSYNC and the underlying file system performs the necessary write, flush requests. </li></ul> <p><b>Note:</b> Alternate write through settings only apply when writethrough=1.</p></td> <td valign="top" width="514">When running on a DpoFuo = 0 or non-Fua optimized installation the alternate writethrough performs better than allowing the Linux kernel to handle the write, flush on every write.&nbsp; <br><br>On non-optimized, Fua systems using alternatewritethrough and –T3982 is the best performance and durability option.</td></tr></tbody></table></div> <p>&nbsp; <p>The following is a high-level flowchart of the settings and outcomes.  <p>&nbsp; <p><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image78.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;border-top-width: 0px;margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb72.png" width="597" height="584"></a>  <h3>Safety and Performance</h3> <p>To help make sense of all of this I have broken down the various trace flag and configuration options by data safety and performance.&nbsp; <p><strong>Safe Installation (Best performance):</strong><br>- SQL Server 2017 CU6 or newer<br>- Linux kernel 4.18 or newer with xfs storage<br>- T3979<br>- DpuFua=1<br>- control.writethrough = 1<br>- control.alternatewritethrough = 0</p> <p><strong>Safe Installation (Best Grouping Performance – Forced Flush from SQL Server and HE):</strong><br>- SQL Server 2017 CU6 or newer<br>- T3982<br>- DpuFua = 0<br>- control.writethrough = 1<br>- control.alternatewritethrough =1<br><br><strong>Safe Installation (Midrange Grouping Performance - Grouped device level flushes from HE):</strong><br>- SQL Server 2017 CU6 or newer<br>- T3979<br>- DpuFua = 0<br>- control.writethrough = 1<br>- control.alternatewritethrough =1<br><br><strong>Safe Installation (Slowest Performance - Linux kernel write, flush O_DSYNC behavior):</strong><br>- SQL Server 2017 CU6 or newer<br>- T3979<br>- DpuFua = 0<br>- control.writethrough = 1<br>- control.alternatewritethrough =0<br><br><strong>Alternative Installation (O_DIRECT Safe Reliance on I/O Subsystem):</strong><br>- SQL Server 2017 CU6 or newer<br>- T3979<br>- DpuFua = 0<br>- control.writethrough = 0<br>- control.alternatewritethrough =0 </p> <p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Note:</strong> This achieves the prior configuration of SQL Server 2017 RTM to CU5 on Linux using only O_DIRECT are relying on O_DIRECT safe installations.</p> <table class="MsoTable15Grid1LightAccent5" style="border-top: medium none;border-right: medium none;border-collapse: collapse;border-bottom: medium none;margin-left: 30.35pt;border-left: medium none;line-height: normal" cellspacing="0" cellpadding="0" border="1"> <tbody> <tr> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="143"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">SQL Server 2017</font></span></b><b><span style="font-family:"></span></b></p></td> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="149" colspan="3"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Linux RTM-CU5</font></span></b><b><span style="font-family:"></span></b></p></td> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="151" colspan="3"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Linux CU6+</font></span></b><b><span style="font-family:"></span></b></p></td> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="142" colspan="2"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Windows RTM-CU5</font></span></b><b><span style="font-family:"></span></b></p></td> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="126" colspan="2"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Windows CU6+</font></span></b><b><span style="font-family:"></span></b></p></td></tr> <tr> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="143"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></b></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">xfs</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000"><font size="2">xfs<sup> opt</sup></font></font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="52"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">ext4</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="55"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">xfs</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000"><font size="2">xfs<sup> opt</sup></font></font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">ext4</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="64"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">ntfs</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="78"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">refs</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="72"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">ntfs</font></span><span style="font-family:"></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="54"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">refs</font></span><span style="font-family:"></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="143"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">-T3979 </font></span></b></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeD</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeD</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="52"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeD</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="55"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeX</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #a8d08d;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Safe</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeX</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #a8d08d;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="64"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Safe</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #a8d08d;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="78"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Safe</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #a8d08d;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="72"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Safe</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #a8d08d;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="54"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Safe</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="143"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">-T3982</font></span></b></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="52"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #bdd6ee;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="55"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeX</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #bdd6ee;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Safe</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;background: #bdd6ee;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="48"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">SafeX</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="64"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="78"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="72"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="54"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">N/A</font></span></p></td></tr></tbody></table> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">&nbsp;</font></span></p> <table class="MsoTable15Grid1LightAccent5" style="border-top: medium none;border-right: medium none;border-collapse: collapse;border-bottom: medium none;margin-left: 66.35pt;border-left: medium none;line-height: normal" cellspacing="0" cellpadding="0" border="1"> <tbody> <tr style="height: 4pt"> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" height="5" valign="top" width="67"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font style="font-size: 9pt" color="#000000">State</font></span></b></p></td> <td style="border-top: #bdd6ee 1pt solid;border-right: #bdd6ee 1pt solid;border-bottom: #9cc2e5 1.5pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" height="5" valign="top" width="600"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font style="font-size: 9pt" color="#000000">Description</font></span></b></p></td></tr> <tr> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="67"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font style="font-size: 9pt" color="#000000">SafeD</font></span></b></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="600"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">Unless the system meets O_DIRECT safe criteria (many do not), you are exposed to possible data </font><a><font style="font-size: 9pt" color="#000000">loss</font></a>.</span></p></td></tr> <tr> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="67"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font style="font-size: 9pt" color="#000000">Safe</font></span></b></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="600"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">Requires alternatewritethrough=0, writethrough=1 and I/O subsystem supporting optimized Fua and DpoFua = 1.</font></span></p></td></tr> <tr> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: #bdd6ee 1pt solid;padding-right: 5.4pt" valign="top" width="67"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:"><font style="font-size: 9pt" color="#000000">SafeX</font></span></b></p></td> <td style="border-top: medium none;border-right: #bdd6ee 1pt solid;border-bottom: #bdd6ee 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: medium none;padding-right: 5.4pt" valign="top" width="600"> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font style="font-size: 9pt" color="#000000">Requires alternatewritethrough=1, writethrough =1 enabling alternate flush behavior.</font></span></p></td></tr></tbody></table> <div style="line-height: normal"> <h3>O_DIRECT Safe</h3></div> <p>O_DIRECT safe refers to is the ability to perform writes with O_DIRECT and without O_DSYNC and maintain durability.&nbsp; If the I/O subsystem avoids the proper buffering mechanism until it reaches stable media (battery-backed cache for example) then the Fua option may not be required.&nbsp; However, to be O_DIRECT safe you must ensure the kernel, drivers, and hardware are able to place a write into non-volatile storage before indicating the write is complete.</p> <p><font color="#c0504d">I am unaware of tracing mechanisms to determine if the system is O_DIRECT safe.</font>&nbsp; Microsoft has done extensive testing of durability on systems believed to be O_DIRECT safe and SQL Server for Linux RTM thru CU5 was configured for O_DIRECT safe write activities.&nbsp; However, Microsoft does not recommend reliance on O_DIRECT safe configurations and instead provides SQL Server 2017 CU6 and newer builds with explicit durability capabilities (forced flush or optimized Fua writes.)</p> <p>If you choose to configure your system for O_DIRECT safe writes be sure to employ an appropriate backup or high availability strategy.</p> <blockquote> <h6 style="margin: 2pt 0in 0pt;line-height: 12pt"><span style="color:"><font color="#ff0000" size="2">Caution<br></font></span></h6> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Unless you are using an updated file system, it is unsafe to assume the REQ_FUA behavior.<span>&nbsp; </span>SQL Server automatically enables -T3982 (forced flush behavior) on SQL Server for Linux.<span>&nbsp; </span>If you are able to, verify that a write on your system meets the following criteria, you may be able to achieve data integrity compliance without Fua capabilities as long as you are able to make sure the O_DIRECT path supports write completion when the data has been stored on stable media. – “O_DIRECT Safe.”</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><font size="2"><span><span>1.<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family:">I/O subsystem and drivers do not cache FILE_FLAG_NO_BUFFERING (O_DIRECT) in volatile cache. All cache involvement must be power outage hardened.</span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><font size="2"><span><span>2.<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family:">All files in the database are on these stable media, compliant I/O paths (data, log, checkpoint files, standby recovery files, backups, …)</span></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 0pt 0.5in;line-height: normal;text-indent: -0.25in"><font color="#000000"><font size="2"><span><span>3.<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family:">All SQL Server support files are on the stable media (cluster files, registry files, …) </span></font></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><b><span style="font-family:;color:"><font color="#c00000" size="2">If you are unsure maintain the forced flush behavior configuration.</font></span></b><span></span></p></blockquote> <h3>Virtual Environments (VMs and Containers)</h3> <p>Virtual environments may not provide the write behavior required to maintain durability.&nbsp; Microsoft has validated Hyper-V, Windows Azure Virtual Machines, Windows Storage and various Docker implementations pass the flush requirements to the host properly.&nbsp; When performing a Fua write the Fua requirement must be passed to the host and the host must carry the write in stable media.&nbsp; If the virtualization or host caching does not support the Fua requirement you should use forced flush behaviors to maintain durability.</p> <h4>How did I get DpoFua=1 enabled for a Hyper-V installation of Linux?</h4> <h6 style="margin: 2pt 0in 0pt;line-height: 12pt"><span style="font-family:"><font color="#000000" size="2">On virtual systems, additional effort may be required to confirm the virtualization technology passes the Fua intent to the host and the host honors the request.&nbsp; </font></span><font size="2"><span style="font-family:"><font color="#000000">You may use a directly mounted device (direct pass-through drive for Hyper-V or iSCSI supporting Fua capabilities) and/or confirm the VHD | VHDx storage path supports Fua.<span>&nbsp; </span></font></span></font></h6> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span style="font-family:"><font color="#000000"><span></span></font></span></font>&nbsp;</p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><font size="2"><span style="font-family:"><font color="#000000"><span><strong><font color="#ff0000">WARNING:</font> </strong></span></font><i><span style="color:"><font color="#ff0000">Use caution as the </font><font color="#ff0000">Hyper-V configuration does not query the device for Fua support and trusts the setting provided.</font></span></i></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">Using the Hyper-V, PowerShell cmdlets, from Windows 2016, you can configure Fua reporting for the guest virtual machine.</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 1in;line-height: normal"><span style="font-family:"><font color="#000000" size="2">$a = <b>Get-VMHardDiskDrive</b> -VMName "xxxxxxxxxxx" <br>foreach ($b in $a) { $b; $b.WriteHardeningMethod }</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt 45pt;line-height: normal"><span style="font-family:"><font color="#000000" size="2">&nbsp;</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt 1in;line-height: normal"><b><span style="font-family:"><font color="#000000" size="2">Set-VMHardDiskDrive</font></span></b><span style="font-family:"><font size="2"><font color="#000000"> -VMName "xxxxxxxxxxx"<span>&nbsp; </span>-OverrideCacheAttributes </font><span style="color:"><font style="background-color: #000000" color="#ffd966">WriteCacheAndFuaEnabled</font></span></font><font size="2"><font color="#000000"> <br><br></font><i><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp; </span><b>Note:</b> You may need to add a controller type such as -ControllerType SCSI</font></i></font></span></p> <h3>Linux Kernel 4.18 Updates</h3> <p>I have worked at Microsoft since 1994 and this issue truly points to the spirit of ‘Microsoft Loves Linux.’&nbsp; I was strongly supported, funded and encouraged to track down the issue and make it better for customers.&nbsp; The Linux committer and vendor engagements where insightful and helpful and, in the end, I am able to proudly say that <em>Microsoft helped to improve Linux</em>.  <p>Several code changes were made to the imap, block device, and XFS components to accommodate optimized Fua writes.&nbsp; The changes in the imap and block device areas can be leveraged by other file systems but as Dec 2018 (this post) only XFS has enabled optimized Fua data write capabilities.  <p><strong>Key Commit References in 4.18 and newer kernel releases</strong>  <ul> <li>ed5c3e6 xfs: move generic_write_sync calls inwards  <li>4f8ff44 iomap: iomap_dio_rw() handles all sync writes  <li>0ce9144 block: add blk_queue_fua() helper function  <li>3460cac iomap: Use FUA for pure data O_DSYNC DIO writes </li></ul> <blockquote> <p><font size="2"><strong><u><font color="#008080">Support</font><br></u></strong></font><font size="2">Microsoft has tested and confirmed the Fua changes are included in Linux kernel build 4.18 and newer kernels while </font><font size="2">Red Hat has tested and confirmed the changes are included in RHEL 8.0.</font></p></blockquote> <p><strong>Hint: </strong>Use the <i>uname -sr</i> command to discover the Linux Kernel version.  <h3>Tracing SQL Server Behavior (XEvent)</h3> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span style="line-height: 10pt"><font color="#000000" size="2">The following XEvents can be used to monitor the flush behavior employed by SQL Server.</font></span></p> <h3 style="margin: 2pt 0in 0pt;line-height: 13pt"><a><font color="#1f3763" size="2">XEvents (Debug channel)</font></a></h3> <p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><font size="2"><span style="font-family:;line-height: 10pt"><span>·<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 10pt">flush*</span></font></font></p> <p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><font size="2"><span style="font-family:;line-height: 10pt"><span>·<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 10pt">make_durable*</span></font></font></p> <p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 8pt 0.5in;line-height: 12pt;text-indent: -0.25in"><font color="#000000"><font size="2"><span style="font-family:;line-height: 10pt"><span>·<span style="font-family:;line-height: normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 10pt">checkpoint*</span></font></font></p> <h4 style="margin: 2pt 0in 0pt;line-height: 12pt"><font color="#2f5496" size="2"><em>-T3979 (Force Flush Disabled) Checkpoint</em></font></h4> <p style="margin: 2pt 0in 0pt;line-height: 12pt"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image79.png"><font size="2"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb73.png" width="704" height="45"></font></a></p> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span><font size="2"></font></span></p> <h4 style="margin: 2pt 0in 0pt;line-height: 12pt"><font color="#2f5496" size="2"><em>-T3982 (Force Flush Enabled) Checkpoint</em></font></h4> <p class="MsoNormal" style="margin: 0in 0in 8pt;line-height: 12pt"><span style="line-height: 10pt"><font color="#000000" size="2">Notice the make_writes_durable and flush_file_buffers events for the database log and data files used for ACI(D)urability.</font></span></p> <p><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image80.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb74.png" width="725" height="292"></a>  <h3>Testing and Futures (<em><font color="#c0504d">Warning: Plans May Change</font></em>)</h3> <p>When it comes to database consistency there is no discussion on doing the right thing.&nbsp; When I told Slava I was going to put in the <em>forced flush behavior</em> and it would have a performance impact, he simply said do it!&nbsp; Not 2 seconds passed between us making the decision. As a team, we would figure out ways to improve the performance, but the safety of the data took priority.</p> <p>When SQL Server 7.0 shipped Microsoft SQL Server made a distinct change to transaction log writes, aligning on sector boundaries and removing the 2K page rewrites of the 6.x and Sybase code to improve ACID properties of the SQL Server.&nbsp; This generated lots of calls to Microsoft Support because it changed the I/O performance characteristics in ways customers didn’t expect and lead to the first code I added to SQL70IOStress, which I would later rewrite into what you know today as <a href="https://support.microsoft.com/en-us/help/231619/how-to-use-the-sqliosim-utility-to-simulate-sql-server-activity-on-a-d" target="_blank">SQLIOSim</a>.&nbsp; </p> <p>I mention this because folks like Keith Elmore, Bob Ward and I were running tests in the lab.&nbsp; In fact, I was pulling the power between the power supply and the hard drive, waiting a few minutes, plugging the power back in and validating the durability and consistency provided by the I/O subsystem.&nbsp; This lasted a couple of days until I electric-arc’ed the drive and burnt out the power supply. The lab manager would no longer allow me to manually pull the power.&nbsp; It just so happened that Ed Harper was on our team and he built me a wire wrapped board.&nbsp; It had a few D-Batteries and a switch on it with a plug on one end for the power supply and a plug on the other for the drive.&nbsp; I used the generic driver sample and could signal the switch to open and close which I could then signal from SQL70IOStress and perform 1000s of ACID related tests overnight.&nbsp; I won’t even tell you how many disk drives I have worn out doing I/O testing.</p> <p>Creating SQL 2017 CU6 updates involved revisiting similar tests.&nbsp; The SQL Server test infrastructure can inject <strong>fail points</strong>.&nbsp; Dylan added additional fail points to checkpoint, lazy writer, and log writer.&nbsp; Ben, Mitch, and Kapil performed physical pull the plug and kill the VM testing.&nbsp; Pat added forced flush behavior to SQLIOSim, which we have been running in a Linux package, in our daily lab runs since before SQL Server 2017 was released.&nbsp; We also added additional coverage to containers, high-availability, replication, backup, restore and recovery test suites.</p> <p>Met <a href="https://www.linkedin.com/in/tejas-shah-72a62027/" target="_blank">Tejas</a>, a long time Microsoft SQL Server Support Escalation Engineer, is a Program Manager for SQL Server on Linux.&nbsp; He is working on the Linux experience, testing and capabilities surrounding SQL Server WAL and ACID capabilities.&nbsp; Some of the areas he is currently looking into are as follows (<em>as always these a goals we would like to achieve</em>:)</p> <table cellspacing="2" cellpadding="2" width="1007" border="0"> <tbody> <tr> <td valign="top" width="262"><strong>/opt/mssql/bin/mssql-conf</strong></td> <td valign="top" width="737">Providing single selection capability to configure the various Fua settings for a target environment</td></tr> <tr> <td valign="top" width="262"><strong>Auto configuration</strong></td> <td valign="top" width="737">Can SQLPAL and SQL Server use the DpoFua detection to automatically do the right thing</td></tr> <tr> <td valign="top" width="262"><a href="https://support.microsoft.com/en-us/help/231619/how-to-use-the-sqliosim-utility-to-simulate-sql-server-activity-on-a-d" target="_blank"><strong>SQLIOSim</strong></a></td> <td valign="top" width="737">Provide the SQLIOSim package used in Microsoft SQL Server’s daily testing to customers for <em>yum/apt-get install sqliosim</em> testing capabilities</td></tr> <tr> <td valign="top" width="262"><a href="https://gallery.technet.microsoft.com/DiskSpd-A-Robust-Storage-6ef84e62" target="_blank"><strong>DiskSpd</strong></a> (SQLIO)</td> <td valign="top" width="737">Provide a package to customers for <em>yum/apt-get install diskspd </em>testing capabilities<br><a title="https://blogs.msdn.microsoft.com/sql_server_team/sqlio-disk-subsystem-benchmark-tool-is-being-retired/" href="https://blogs.msdn.microsoft.com/sql_server_team/sqlio-disk-subsystem-benchmark-tool-is-being-retired/">https://blogs.msdn.microsoft.com/sql_server_team/sqlio-disk-subsystem-benchmark-tool-is-being-retired/</a></td></tr> <tr> <td valign="top" width="262"><a href="https://www.cs.utexas.edu/~vijay/papers/hotstorage17-crashmonkey-slides.pdf" target="_blank"><strong>Crash Monkey</strong></a></td> <td valign="top" width="737">Evaluating facilities such as Crash Monkey and B3 to see if we can include it with our daily and stress testing activities</td></tr> <tr> <td valign="top" width="262"><strong>Vendors</strong></td> <td valign="top" width="737">When we released SQLIOSim for Windows many vendors added it to their test suites. We hope to achieve similar adoption from the Linux distribution vendors</td></tr> <tr> <td valign="top" width="262"><strong>Azure</strong></td> <td valign="top" width="737">For years the SQL Azure storage team has and continues to run SQLIOSim in their daily tests and with storage, fail points as well.&nbsp; Expand the coverage to Linux guests running SQLIOSim</td></tr> <tr> <td valign="top" width="262"><strong>WHCL Storage Certification<br>SQL Server I/O reliability Program</strong></td> <td valign="top" width="737">For more than a decade, SQLIOSim has been part of the WHCL Storage Certification for Windows as well as the <a href="https://msdnshared.blob.core.windows.net/media/2018/12/SQL_Server_IO_Reliability_Program_Review_Requirements.pdf" target="_blank">SQL Server I/O Reliability Program</a>.&nbsp; Vendors, such as Red Hat, have similar programs for Linux who Tejas is engaging</td></tr></tbody></table> <p><br>As of this post, XFS on Linux 4.18 or newer is Fua optimized and we have also reached out to additional, Linux file system committers.&nbsp; For example, the EXT4 committers are aware of the changes and evaluating the changes.</p> <h3><a name="_Toc512277897"><font color="#000000">Odds and Ends</font></a></h3> <p>Updates and changes like this tend to expose some odds and ends.  <h5><a name="_Toc512277898">Checkpoint Record Flush</a></h5> <p><font color="#000000">SQL Server creates a log record (LOP_BUF_WRITE) to assist recovery. The record has an array of page ids written to disk. The checkpoint flush record has a limited size and is written whenever it becomes full.&nbsp; The flushing of the checkpoint record requires FlushFileBuffers when forced flush behavior is enabled to maintain durability.</font>  <h5><a name="_Toc512277899">All Data Files For Same Database Flushed</a></h5> <p><font color="#000000">Forced flush loops over all database files in the target database and issues FlushFileBuffers to complete a checkpoint. The data files may be on the same block device and the secondary flushes may be redundant but are inexpensive. Future SQL Server updates may optimize this behavior.</font>  <h5><a name="_Toc512277900">TEMPDB Is Faster</a></h5> <p><font color="#000000">You may find that TEMPDB is faster using -T3982. TEMPDB is always rebuilt upon SQL Server restart and forced flush removes the FILE_FLAG_WRITE_THOUGH requirement of TEMPDB.&nbsp; Since TEMPDB does not need to issue checkpoints, FlushFileBuffers may be </font><a><font color="#000000">skipped</font></a><font color="#000000">.&nbsp; In fact, our performance team is evaluating a SQL Server 2019 change that never opens the TEMPDB file with the FILE_FLAG_WRITE_THROUGH.</font>  <h5><a name="_Toc512277901">RWF_ODSYNC</a></h5> <p><font color="#000000">Another choice, provided in the Linux Fall 2017 Update, allows individual I/O requests (io_submit) to set the RWF_ODSYNC flag, forcing O_DSYNC for individual write requests. SQL Server does not use RWF_ODSYNC.</font>  <h3>Simple Test and Results</h3> <table class="MsoTableGrid" style="border-top: medium none;border-right: medium none;border-collapse: collapse;border-bottom: medium none;margin-left: 30.2pt;border-left: medium none;line-height: normal" cellspacing="0" cellpadding="0" border="1"> <tbody> <tr> <td style="border-top: windowtext 1pt solid;border-right: windowtext 1pt solid;border-bottom: windowtext 1pt solid;padding-bottom: 0in;padding-top: 0in;padding-left: 5.4pt;border-left: windowtext 1pt solid;padding-right: 5.4pt" valign="top" width="1399"> <p class="MsoNormal" style="margin: 0in 0in 0pt"><span><font color="#1f497d" size="2" face="Courier New">Raw Results from Fedora 4.17 to 4.18 using SQL Server 2019 CTP 2.2</font></span></p> <p class="MsoNormal" style="margin: 0in 0in 0pt"><span><font color="#1f497d" size="2" face="Courier New">&nbsp;</font></span></p> <p class="MsoNormalCxSpMiddle"><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; Win10, 8 proc, 32GB ram host<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; Samsung SSD drive<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; Fedora, Hyper-V Vm, 8GB, 4 proc - FUA enabled for SCSI using xfs<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; Filesystem&nbsp;&nbsp;&nbsp;&nbsp; Type&nbsp;&nbsp;&nbsp;&nbsp; 1K-blocks&nbsp;&nbsp;&nbsp; Used Available Use% Mounted on<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; devtmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; devtmpfs&nbsp;&nbsp; 4048256&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 4048256&nbsp;&nbsp; 0% /dev<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4060892&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 4060892&nbsp;&nbsp; 0% /dev/shm<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4060892&nbsp;&nbsp;&nbsp;&nbsp; 864&nbsp;&nbsp; 4060028&nbsp;&nbsp; 1% /run<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4060892&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 4060892&nbsp;&nbsp; 0% /sys/fs/cgroup<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; /dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 67076096 7750028&nbsp; 59326068&nbsp; 12% /<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4060892&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 4060892&nbsp;&nbsp; 0% /tmp<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; /dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vfat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26201584&nbsp;&nbsp;&nbsp; 8064&nbsp; 26193520&nbsp;&nbsp; 1% /boot/efi<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 812176&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 812176&nbsp;&nbsp; 0% /run/user/0<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- =============================================================================================================<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; Fedora 29 - Release Package Downloaded from web <br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux fedora29ws 4.18.16-300.fc29.x86_64 #1 SMP Sat Oct 20 23:24:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; Create DB Inserts Checkpoint Options<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; --------- ------- ---------- -----------------------------------<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; 5437&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8747&nbsp;&nbsp;&nbsp; 27&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O_DIRECT | O_DSYNC via aio_submit<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; 4910&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8630&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O_DIRECT | O_DSYNC via aio_submit<br></font></span><font face="Courier New"><span style="font-family:;color:"><font color="#008000" size="2">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2">--&nbsp; blktrace -d /dev/sda -o - | blkparse -i - -f "%5T.%9t %10p %-10S %D %2c %8s %2a %3d %10n %32C\n"<br></font></span></font><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 68.327939698&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020 78009696&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; 33481&nbsp; A WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 68.327941298&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020 78009696&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; 33482&nbsp; Q WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 68.327945198&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020 78009696&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; 33483&nbsp; G WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 68.327945698&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; 33484&nbsp; P&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 68.327947798&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020 78009696&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; 33485&nbsp; I WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- =============================================================================================================<br></font></span><span style="font-family:;color:"><font color="#008000"><font size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; Fedora 29 - 4.18 kernel at: </font></font><a href="https://kojipkgs.fedoraproject.org/packages/kernel/4.18.0/1.fc29/x86_64/" target="_blank"><span style="color:"><span style="color:"><font color="#000000"><u><font face="Courier New"><font size="2">ht<span style="color:">tps://kojipkgs.fedoraproject.org/packages/kernel/4.18.0/1.fc29/x86_64/</span></font></font></u></font></span></span></a><br></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux fedora29ws 4.18.0-1.fc29.x86_64 #1 SMP Mon Aug 13 16:10:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; Create DB Inserts Checkpoint Options<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; --------- ------- ---------- -----------------------------------<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; 4710&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9797&nbsp;&nbsp;&nbsp; 23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O_DIRECT | O_DSYNC via aio_submit<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; 4103&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7336&nbsp;&nbsp;&nbsp; 40&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O_DIRECT | O_DSYNC via aio_submit<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051548381&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77979112&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6840&nbsp; A WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051549981&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77979112&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6841&nbsp; Q WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051554581&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77979112&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6842&nbsp; G WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051555181&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6843&nbsp; P&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051556881&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77979112&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6844&nbsp; I WFS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051557381&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6845&nbsp; U&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 26.051557981&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77979112&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 6846&nbsp; D <font style="background-color: #000000" color="#00ff00">WFS</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- =============================================================================================================<br></font></span><span style="font-family:;color:"><font color="#008000"><font size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp; Fedora 29 - 4.17 kernel at: </font></font><a href="https://kojipkgs.fedoraproject.org/packages/kernel/4.17.0/1.fc29/x86_64/" target="_blank"><span style="color:"><span style="color:"><font color="#000000"><u><font face="Courier New"><font size="2">https://kojipkgs.fedoraproject.org/packages/kernel/<span style="color:">4.17.0/1.fc29/x86_64/</span></font></font></u></font></span></span></a><br></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux fedora29ws 4.17.0-1.fc29.x86_64 #1 SMP Mon Jun 4 16:44:10 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; Create DB Inserts Checkpoint Options<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; --------- ------- ---------- -----------------------------------<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; 4450&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 27680&nbsp;&nbsp; 40&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O_DIRECT | O_DSYNC via aio_submit<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--&nbsp; 4287&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25234&nbsp;&nbsp; 47&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; O_DIRECT | O_DSYNC via aio_submit<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536937686&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77967216&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41912&nbsp; A&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536938986&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77967216&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41913&nbsp; Q&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536946985&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77967216&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41914&nbsp; G&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536947585&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41915&nbsp; P&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536950385&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77967216&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41916&nbsp; I&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536953685&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; insert_request<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536955485&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; add_to_rr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536959385&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; preempt<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536961085&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1029S&nbsp; slice expired t=1<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536963385&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1029S&nbsp; resid=97883024<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536965485&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N served: vt=413491973181440 min_vt=413483294265344<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536967285&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1029S&nbsp; sl_used=2118876 disp=1 charge=2118876 iops=0 sect=8<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536968685&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1029S&nbsp; del_from_rr\<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536971285&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; set_active wl_class:0 wl_type:2<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536972085&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; dispatch_insert<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536973285&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; dispatched a request<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.536973985&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; activate rq, drv=1<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536974385&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 77967216&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41917&nbsp; D&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.536984685&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1027 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41918&nbsp; U&nbsp;&nbsp; N&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlservr<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.537480680&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 77967216&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41919&nbsp; C&nbsp; WS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; swapper/0<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.537499979&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; complete rqnoidle 0<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.537502179&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; set_slice=100000000<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.537505779&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq1027S&nbsp; arm_idle: 8000000 group_idle: 0<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 45.537506079&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; m&nbsp;&nbsp; N cfq schedule dispatch<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.537531779&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 36 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41920&nbsp; Q <font style="background-color: #ff0000" color="#ffffff">FWS</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/0:1<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.537535279&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 36 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41921&nbsp; G FWS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/0:1<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- 45.537536579&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 36 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8,0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 41922&nbsp; I FWS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kworker/0:1<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">set</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">nocount</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2">on<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">use</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2">master<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">drop</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">database</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">IF</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">EXISTS</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> fuaTest<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- Always stamp disk space on creation<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">dbcc</font></span><span style="font-family:;color:"><font color="#000000"> traceon</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">1805</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">-</font></span><span style="font-family:;color:"><font color="#000000">1</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">)<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">declare</font></span><span style="font-family:;color:"><font color="#000000"> @start </font></span><span style="font-family:;color:"><font color="#0000ff">datetime</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">GetUtcDate</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">()<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">CREATE</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">DATABASE</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> fuaTest&nbsp; <br></font></span></font><font face="Courier New"><span style="font-family:;color:"><font color="#0000ff" size="2">ON<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">NAME</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> fua_dat</font></span><span style="font-family:;color:"><font color="#808080">,</font></span></font><span style="font-family:;color:"><font color="#000000" size="2">&nbsp; <br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="font-family:;color:"><font color="#0000ff">FILENAME</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff0000">'/var/opt/mssql/data/fua.mdf'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span></font><span style="font-family:;color:"><font color="#000000" size="2">&nbsp; <br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp; SIZE </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> 4096MB</font></span><span style="font-family:;color:"><font color="#808080">)</font></span></font><span style="font-family:;color:"><font color="#000000" size="2">&nbsp; <br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#ff00ff">LOG</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">ON</font></span></font><span style="font-family:;color:"><font color="#000000" size="2">&nbsp; <br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">NAME</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> fua_log</font></span><span style="font-family:;color:"><font color="#808080">,</font></span></font><span style="font-family:;color:"><font color="#000000" size="2">&nbsp; <br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="font-family:;color:"><font color="#0000ff">FILENAME</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff0000">'/var/opt/mssql/data/fua.ldf'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span></font><span style="font-family:;color:"><font color="#000000" size="2">&nbsp; <br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp; SIZE </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> 1024MB</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000">&nbsp; </font></span></font></font></p> <p class="MsoNormalCxSpMiddle"><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">declare</font></span><span style="font-family:;color:"><font color="#000000"> @end </font></span><span style="font-family:;color:"><font color="#0000ff">datetime</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">GetUtcDate</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">()<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">select</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff0000">'Create DB'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @start </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> [Start]</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @end </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> [End]</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">datediff</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">ms</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @start</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @end</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> [Elapsed MS]<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- Control when checkpoint is executed<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">ALTER</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">DATABASE</font></span><span style="font-family:;color:"><font color="#000000"> fuaTest </font></span><span style="font-family:;color:"><font color="#0000ff">set</font></span><span style="font-family:;color:"><font color="#000000"> TARGET_RECOVERY_TIME </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> 1024 </font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2">minutes<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">ALTER</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">DATABASE</font></span><span style="font-family:;color:"><font color="#000000"> fuaTest </font></span><span style="font-family:;color:"><font color="#0000ff">set</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">RECOVERY</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2">SIMPLE<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">backup</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">database</font></span><span style="font-family:;color:"><font color="#000000"> fuaTest </font></span><span style="font-family:;color:"><font color="#0000ff">to</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">disk</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#ff0000" size="2">'nul'<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#800000">sp_configure</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff0000">'show advanced'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> 1<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">reconfigure</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">with</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2">override<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#800000">sp_configure</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff0000">'recovery interval'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> 1024<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">reconfigure</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">with</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2">override<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- Do some inserts<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><font face="Courier New"><span style="font-family:;color:"><font color="#0000ff" size="2">use</font></span><span style="font-family:;color:"><font color="#000000" size="2"> fuaTest<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">declare</font></span><span style="font-family:;color:"><font color="#000000"> @start </font></span><span style="font-family:;color:"><font color="#0000ff">datetime</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">GetUtcDate</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">()<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">create</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">table</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> tblTest<br></font></span></font><span style="font-family:;color:"><font color="#808080" size="2" face="Courier New">(<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iID </font></span><span style="font-family:;color:"><font color="#0000ff">int</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">NOT</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">NULL</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">PRIMARY</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">KEY</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">CLUSTERED</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">IDENTITY</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">1</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000">1</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">),<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="font-family:;color:"><font color="#0000ff">data</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">char</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">100</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">NOT</font></span><span style="font-family:;color:"><font color="#000000"> </font></span></font><span style="font-family:;color:"><font color="#808080" size="2">NULL<br></font></span></font><span style="font-family:;color:"><font color="#808080" size="2" face="Courier New">)<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">truncate</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">table</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> tblTest<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">insert</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">into</font></span><span style="font-family:;color:"><font color="#000000"> tblTest</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#0000ff">data</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">values </font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#ff00ff">cast</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#ff00ff">GetUTCDate</font></span><span style="font-family:;color:"><font color="#808080">()</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">char</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">100</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">)))<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">while</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#ff00ff">@@IDENTITY</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">&lt;</font></span><span style="font-family:;color:"><font color="#000000"> 10000</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">)<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">begin<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="font-family:;color:"><font color="#0000ff">insert</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">into</font></span><span style="font-family:;color:"><font color="#000000"> tblTest</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#0000ff">data</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">values </font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#ff00ff">cast</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#ff00ff">GetUTCDate</font></span><span style="font-family:;color:"><font color="#808080">()</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">char</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">100</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">)))<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">end</font></span><span style="font-family:;color:"><font color="#000000" size="2" face="Courier New">&nbsp;<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">declare</font></span><span style="font-family:;color:"><font color="#000000"> @end </font></span><span style="font-family:;color:"><font color="#0000ff">datetime</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">GetUtcDate</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">()<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">select</font></span><span style="font-family:;color:"><font color="#000000">&nbsp; </font></span><span style="font-family:;color:"><font color="#ff0000">'Inserts'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @start </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> [Start]</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @end </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> [End]</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">datediff</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">ms</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @start</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @end</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> [Elapsed MS]<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></span></p> <p class="MsoNormalCxSpMiddle"><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">-- Execute checkpoint<br></font></span><span style="font-family:;color:"><font color="#008000" size="2" face="Courier New">--<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">declare</font></span><span style="font-family:;color:"><font color="#000000"> @start </font></span><span style="font-family:;color:"><font color="#0000ff">datetime</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">GetUtcDate</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">()<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">checkpoint<br></font></span><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">declare</font></span><span style="font-family:;color:"><font color="#000000"> @end </font></span><span style="font-family:;color:"><font color="#0000ff">datetime</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#808080">=</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">GetUtcDate</font></span></font><span style="font-family:;color:"><font color="#808080" size="2">()<br></font></span></font><font face="Courier New"><font size="2"><span style="font-family:;color:"><font color="#0000ff">select</font></span><span style="font-family:;color:"><font color="#000000">&nbsp; </font></span><span style="font-family:;color:"><font color="#ff0000">'Checkpoint'</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @start </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> [Start]</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @end </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span><span style="font-family:;color:"><font color="#000000"> [End]</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#ff00ff">datediff</font></span><span style="font-family:;color:"><font color="#808080">(</font></span><span style="font-family:;color:"><font color="#000000">ms</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @start</font></span><span style="font-family:;color:"><font color="#808080">,</font></span><span style="font-family:;color:"><font color="#000000"> @end</font></span><span style="font-family:;color:"><font color="#808080">)</font></span><span style="font-family:;color:"><font color="#000000"> </font></span><span style="font-family:;color:"><font color="#0000ff">as</font></span></font><span style="font-family:;color:"><font color="#000000" size="2"> [Elapsed MS]<br></font></span></font><span style="font-family:;color:"><font color="#0000ff" size="2" face="Courier New">go</font></p></span></td></tr></tbody></table> <p>&nbsp; <h3>IOPerfTest</h3> <table cellspacing="2" cellpadding="2" width="1008" border="0"> <tbody> <tr> <td valign="top" width="1002"> <p><font color="#000000"></font><font size="2" face="Courier New">#include &lt;stdio.h&gt;<br>#include &lt;sys/types.h&gt;<br>#include &lt;unistd.h&gt;<br>#include &lt;sys/stat.h&gt;<br>#include &lt;fcntl.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;errno.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;sys/syscall.h&gt;<br>#include &lt;aio.h&gt;<br>#include &lt;linux/aio_abi.h&gt;<br>#include &lt;sys/mman.h&gt;<br>#include &lt;inttypes.h&gt;<br>&nbsp;<br>#include &lt;iostream&gt;<br>using namespace std;<br>&nbsp;<br>int main(int argc, char** argv)<br>{<br>&nbsp;&nbsp;&nbsp; const char * fileName = "iotest.txt";<br>&nbsp;&nbsp;&nbsp; const int fileSize = (1024*1024*128);<br>&nbsp;&nbsp;&nbsp; const int chunks = 128;<br>&nbsp;&nbsp;&nbsp; int returnCode;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; if(argc != 6)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Arguments:&nbsp; 1|0 = O_DSYNC&nbsp; 1|0 = O_DIRECT&nbsp; 1|0 = RWF_DSYNC&nbsp; WriteCount&nbsp; WriteSize" &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(99);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; int useDsync = (1 == atoi(argv[1]) ? O_DSYNC : 0);<br>&nbsp;&nbsp;&nbsp; int useDirect = (1 == atoi(argv[2]) ? O_DIRECT : 0);<br>&nbsp;&nbsp;&nbsp; int useRWFDsync = (1 == atoi(argv[3]) ? 0x2 : 0);<br>&nbsp;&nbsp;&nbsp; int writes = atoi(argv[4]);<br>&nbsp;&nbsp;&nbsp; int writeSize = atoi(argv[5]);<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Opening file" &lt;&lt; endl;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; int fd = open(fileName, O_CREAT | O_RDWR | useDirect | O_NOATIME | useDsync, S_IRWXU);<br>&nbsp;&nbsp;&nbsp; if(fd &gt; 0)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Allocating file space" &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnCode = fallocate(fd, 0 , 0, fileSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!returnCode)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void * buffer = mmap(NULL, writeSize * chunks, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(buffer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memset(buffer, 0xCC, writeSize * chunks);<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Stamping file space" &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int writeCount = 0; writeCount &lt; writes; writeCount++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write(fd, buffer, writeSize*chunks);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fsync(fd);<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Starting write test" &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct timespec startTime;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock_gettime(CLOCK_REALTIME, &amp;startTime);<br>&nbsp;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int loops = 0; loops &lt; writes; loops++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aio_context_t ctx = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct iocb cb[chunks];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct iocb*cbs[chunks];<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memset(&amp;cb, 0, sizeof(cb));<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; errno = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnCode = syscall(__NR_io_setup, chunks, &amp;ctx);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //cout &lt;&lt; "Setup: " &lt;&lt; returnCode &lt;&lt; " " &lt;&lt; errno &lt;&lt; " " &lt;&lt; strerror(errno) &lt;&lt; endl;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int chunk = 0; chunk &lt; chunks; chunk++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb[chunk].aio_fildes = fd;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb[chunk].aio_lio_opcode = IOCB_CMD_PWRITE;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb[chunk].aio_buf = (uint64_t) buffer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb[chunk].aio_offset = chunk * writeSize;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb[chunk].aio_nbytes = writeSize;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cb[chunk].aio_rw_flags = useRWFDsync; // RWF_DSYNC (0x2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cbs[chunk] = &amp;cb[chunk];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; errno = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnCode = syscall(__NR_io_submit, ctx, chunks, cbs);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(returnCode != chunks)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Submit: (" &lt;&lt; loops &lt;&lt; ") " &lt;&lt; returnCode &lt;&lt; " " &lt;&lt; errno &lt;&lt; " " &lt;&lt; strerror(errno) &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(chunks == returnCode)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct io_event events[chunks];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; errno = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnCode = syscall(__NR_io_getevents, ctx, chunks, chunks, events, NULL);<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(returnCode != chunks)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Events: " &lt;&lt; returnCode &lt;&lt; " " &lt;&lt; errno &lt;&lt; " " &lt;&lt; strerror(errno) &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syscall(__NR_io_destroy, ctx);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct timespec endTime;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock_gettime(CLOCK_REALTIME, &amp;endTime);<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Wall Clock Elapsed: " &lt;&lt; endTime.tv_sec - startTime.tv_sec &lt;&lt; "." &lt;&lt; endTime.tv_nsec - startTime.tv_nsec &lt;&lt; endl;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; munmap(buffer, writeSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Unable to allocate buffer memory" &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Unable to allocate space for file: " &lt;&lt; errno &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close(fd);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Unable to open: " &lt;&lt; fileName &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Complete" &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp; return 0;<br>}</font><font color="#000000"><br></font></p></td></tr></tbody></table> <h3><a name="_Toc512277904"><font color="#000000">SCSI Fua Write Command Reference [write(10), write(12), and write(16)]</font></a></h3><u><a href="https://www.seagate.com/staticfiles/support/disc/manuals/scsi/100293068a.pdf">https://www.seagate.com/staticfiles/support/disc/manuals/scsi/100293068a.pdf</a></u>  <p><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image81.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb75.png" width="541" height="378"></a></p> <p><font color="#a5a5a5" size="1"></font>&nbsp;</p> <p><font color="#000000" size="2"><strong><u>Related References</u></strong></font></p> <ul> <li><a title="https://blogs.msdn.microsoft.com/psssql/2013/06/03/how-it-works-the-io-path-sql-server-running-in-windows-azure-virtual-machine-iaas/" href="https://blogs.msdn.microsoft.com/psssql/2013/06/03/how-it-works-the-io-path-sql-server-running-in-windows-azure-virtual-machine-iaas"><font size="2">https://blogs.msdn.microsoft.com/psssql/2013/06/03/how-it-works-the-io-path-sql-server-running-in-windows-azure-virtual-machine-iaas</font></a>  <li><a href="https://blogs.msdn.microsoft.com/bobsql/2018/12/10/sql-server-instant-file-initialization-setfilevaliddata-windows-vs-fallocate-linux"><font size="2">https://blogs.msdn.microsoft.com/bobsql/2018/12/10/sql-server-instant-file-initialization-setfilevaliddata-windows-vs-fallocate-linux</font></a>  <li><a href="https://blogs.msdn.microsoft.com/bobsql/2018/07/31/sql-server-on-linux-how-is-delete-on-close-handled"><font size="2">https://blogs.msdn.microsoft.com/bobsql/2018/07/31/sql-server-on-linux-how-is-delete-on-close-handled</font></a>  <li><a href="https://blogs.msdn.microsoft.com/bobsql/2017/01/31/sql-server-on-linux-scattergather-vectored-io"><font size="2">https://blogs.msdn.microsoft.com/bobsql/2017/01/31/sql-server-on-linux-scattergather-vectored-io</font></a>  <li><a href="https://blogs.msdn.microsoft.com/psssql/2010/03/24/how-it-works-bob-dorrs-sql-server-io-presentation"><font size="2">https://blogs.msdn.microsoft.com/psssql/2010/03/24/how-it-works-bob-dorrs-sql-server-io-presentation</font></a>  <li><a href="https://blogs.msdn.microsoft.com/psssql/2011/01/07/discussion-about-sql-server-io"><font size="2">https://blogs.msdn.microsoft.com/psssql/2011/01/07/discussion-about-sql-server-io</font></a>  <li><a href="https://technet.microsoft.com/en-us/library/cc966412.aspx"><font size="2">https://technet.microsoft.com/en-us/library/cc966412.aspx</font></a>  <li><a href="https://blogs.msdn.microsoft.com/psssql/2008/11/12/how-it-works-sqliosim-running-average-target-duration-discarded-buffers"><font size="2">https://blogs.msdn.microsoft.com/psssql/2008/11/12/how-it-works-sqliosim-running-average-target-duration-discarded-buffers</font></a>  <li><a href="https://blogs.msdn.microsoft.com/psssql/2008/04/04/sqliosim-is-not-an-io-performance-tuning-tool"><font size="2">https://blogs.msdn.microsoft.com/psssql/2008/04/04/sqliosim-is-not-an-io-performance-tuning-tool</font></a>  <li><a title="https://support.microsoft.com/en-us/help/231619/how-to-use-the-sqliosim-utility-to-simulate-sql-server-activity-on-a-d" href="https://support.microsoft.com/en-us/help/231619/how-to-use-the-sqliosim-utility-to-simulate-sql-server-activity-on-a-d"><font size="2">https://support.microsoft.com/en-us/help/231619/how-to-use-the-sqliosim-utility-to-simulate-sql-server-activity-on-a-d</font></a>  <li><a href="https://blogs.msdn.microsoft.com/psssql/2007/02/21/sql-server-urban-legends-discussed">https://blogs.msdn.microsoft.com/psssql/2007/02/21/sql-server-urban-legends-discussed</a></li></ul> <p><font color="#a5a5a5" size="1"></font>&nbsp;</p> <p><font color="#a5a5a5" size="1">Robert Dorr – SQL Server - Principle Software Engineer<br>Editing Assistance – Nathan Dorr</font></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Instant File Initialization: SetFileValidData (Windows) vs fallocate (Linux)</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-instant-file-initialization-setfilevaliddata-windows-vs-fallocate-linux</link>
      <pubDate>Mon, 10 Dec 2018 11:01:15 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=3045</guid>
      <description><![CDATA[SQL Server Books Online documents Instant File Initialization and the associated security...]]></description>
      <content:encoded><![CDATA[<p>SQL Server Books Online documents <a href="https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-instant-file-initialization?view=sql-server-2017" target="_blank">Instant File Initialization</a> and the associated security considerations.&nbsp;&nbsp; This blog highlights the underlying file system implementations and differences in behavior between Windows and Linux.</p> <p>SQL Server performs the following API calls when creating or extending (growing) data and log files.</p> <ul> <li><a href="https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea" target="_blank">CreateFile</a> – Create or open a file  <li><a href="https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setendoffile" target="_blank">SetEndOfFile</a>– Establish the file size and acquire space from the I/O device  <li><a href="https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setfilevaliddata" target="_blank">SetFileValidData</a> – Establish the valid data size</li></ul> <ol> <li>If the file is a log file (LDF) SQL Server always writes a known pattern (other than zeros) to the allocated space.  <li>If the file is a data file (MDF/NDF) SQL Server checks the instant file initialization and trace flag 1805 settings to decide if a pattern should be written to the allocated space.</li></ol> <p><strong>Trace flag: 1805 (<em>undocumented in SQL Server Books Online</em>):</strong> Disables instant file initialization for data files.<br><strong>Note:</strong> The stamping is usually performed in 4MB chunks for optimal performance and alignment with both Windows and Linux file system page and block size alignments.</p> <p><strong><u><font size="3">Windows</font></u></strong></p> <p>Windows (ntfs and refs) file systems have two members key to instant file initialization.</p> <blockquote> <p>EOF – End Of File Location</p> <p>VDL – Valid Data Length Location</p></blockquote> <table cellspacing="2" cellpadding="2" width="861" border="1"> <tbody> <tr> <td valign="top" width="569"><strong>Empty File</strong><br><br>When a file is first created the EOF and VDL both point to the beginning of the file.<br><br>EOF = 0<br>VDL = 0</td> <td valign="top" width="284"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image21.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb15.png" width="40" height="99"></a></td></tr> <tr> <td valign="top" width="569"><strong>SetEndOfFile<br><br></strong>SetEnfOfFile extends the file, acquiring space from the I/O device, and adjusting the EOF value.&nbsp;&nbsp; Notice that the VDL value remains unchanged.<br><br>EOF = 10GB<br>VDL = 0</td> <td valign="top" width="284"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image22.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb16.png" width="240" height="149"></a></td></tr> <tr> <td valign="top" width="569"><strong>SetFileValidData</strong><br><br>SetFileValidData is used to move the VDL.&nbsp; Once the VDL is moved all data before the VDL offset if considered to have been written (even if no writes took place) and reads of the space before the VDL may return stale data from the I/O device.&nbsp; Data after the VDL is considered invalid and zeros are returned for read requests.<br><br>EOF = 10GB<br>VDL = 1GB<br><br><strong>Note:</strong> Carefully reads the SQL Server Books Online documentation related to security considerations.<br></td> <td valign="top" width="284"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image23.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb17.png" width="240" height="117"></a></td></tr> <tr> <td valign="top" width="569"><strong>Write beyond the current VDL (WriteFile*)</strong><br><br>When a write occurs, beyond the VDL offset, Windows moves the VDL to accommodate the write and also writes zeros to any offsets between the previous VDL and the start of the write request.<br><br>EOF=10GB<br>Prev VDL = 1GB<br>VDL = 5GB</td> <td valign="top" width="284"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image24.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb18.png" width="266" height="83"></a></td></tr> <tr> <td valign="top" width="569"><strong>Instant File Initialization (New File)</strong><br><br>Instead of incremental changes to the VDL, SQL Server uses the fast allocation capability of SetEndOfFile and then calls SetFileValidData with the same offset.&nbsp; All data prior the VDL is considered written (valid) by the Windows file system.&nbsp; <br><br>Windows does not write zeros nor will SQL Server stamp a pattern (in data files) when Instant File Initialization is enabled.&nbsp;&nbsp; The internal, SQL Server, database allocation structures track SQL Server, data file allocations and valid data read activities.</td> <td valign="top" width="284"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image25.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb19.png" width="240" height="108"></a></td></tr> <tr> <td valign="top" width="569"><strong>Instant File Initialization (Grow)</strong><br><br>Growing a file, using Instant File Initialization, performs SetEndOfFile and SetFileValidData with the new offset.&nbsp; Windows treats the data between the previous offset of new offset as valid.</td> <td valign="top" width="284"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image26.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb20.png" width="240" height="99"></a></td></tr></tbody></table> <p>&nbsp;</p> <p><strong><u><font size="3">Linux</font></u></strong></p> <p>Linux support file allocation with the <a href="https://man7.org/linux/man-pages/man2/fallocate.2.html" target="_blank">fallocate</a> system call (ABI.)&nbsp; The Windows API calls are mapped to Linux ABI calls as follows.</p> <ul> <li>CreateFile – Uses Linux <a href="https://man7.org/linux/man-pages/man2/open.2.html" target="_blank">open</a>  <li>SetEndOfFile – Uses Linux <a href="https://man7.org/linux/man-pages/man2/fallocate.2.html" target="_blank">fallocate</a>  <li>SetFileValidData – Noop on Linux</li></ul> <p>The main difference between Windows and Linux file systems is the tracking of extents, not a valid data length (VDL.)&nbsp; On Linux each extent contains a<em><strong> flag indicating if it has been written</strong></em> to the I/O device.</p> <table cellspacing="2" cellpadding="2" width="859" border="1"> <tbody> <tr> <td valign="top" width="573"><strong>Empty File<br><br></strong>When the file is first created the EOF = 0 and the covering extent is set to (N) for not written.<br><br>A read of a not-written extent always returns zeros on Linux. Linux does not engage the I/O device but simply fills the return buffer with zeros for the space tracked by the not-written extent.<br><br><strong>Hint: </strong>Check the documentation of the Linux file system for extent sizes and adjustments.&nbsp;&nbsp; The default size usually aligns with a memory page size boundary (often 4K) which aligns well with SQL Server 8K pages and 64K extent boundaries for optimal performance.</td> <td valign="top" width="278"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image27.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb21.png" width="165" height="154"></a></td></tr> <tr> <td valign="top" width="573"><strong>SetEndOfFile</strong><br><br>File size growth takes place with an fallocate invocation.&nbsp; Linux acquires space from the I/O device and establishes the EOF as well as the tracking extent meta data, indicating not-written.&nbsp; <br><br><em>The fallocate acquires space just as SetEndOfFile acquires space for a Windows file system, allowing fast creation of large files.</em><br><br><strong>The difference is the SetFileValidData.&nbsp;&nbsp; Linux does not provide the ability to set the extent tracking to ‘written’ without an actual write</strong>.<br><br>Reference unimplemented Linux File System request to mark extents as written (security concerns): <a title="https://www.spinics.net/lists/linux-ext4/msg31637.html" href="https://www.spinics.net/lists/linux-ext4/msg31637.html">https://www.spinics.net/lists/linux-ext4/msg31637.html</a><br><br><strong>Performance Consideration: </strong>If fallocate is not supported for the target file system, SQL Server uses <a href="https://linux.die.net/man/1/truncate" target="_blank">ftruncate</a>.&nbsp;&nbsp; Contrary to its name, the ftruncate ABI can be used to grow a file but is a thin-provisioned operation (space is not acquired only the metadata updated.)&nbsp; When ftruncate is required SQLPAL write zeros to the file to acquire the physical space and provide fallocate, zero read behavior to SQLPAL processes.<br></td> <td valign="top" width="278"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image28.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb22.png" width="240" height="130"></a></td></tr> <tr> <td valign="top" width="573"><strong>Write</strong><br><br>When the first write takes place the the metadata data for the extent(s) are also updated.&nbsp; The extent may be split for tracking written and not-written data or the write extended, by the Linux kernel, to write zeros to the space on disk so the entire extent can be marked as written.<br><br><strong>Note:</strong> On most Linux file systems this results in two (2) write requests but may be more depending on the write size and offset alignment.&nbsp; 1 request for the file data and 1 request for the metadata change.<br></td> <td valign="top" width="278"><a href="https://msdnshared.blob.core.windows.net/media/2018/12/image29.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/12/image_thumb23.png" width="240" height="130"></a></td></tr></tbody></table> <p>&nbsp;</p> <p><strong><u><font size="3">Pay Me Now Or Later Decision</font></u></strong></p> <p>On Windows the SetFileValidData is a single metadata operation.&nbsp; Once the VDL is established a write (sequential or random) does not require additional metadata updates as the VDL == EOF.&nbsp; On Linux the write requires the extent update(s) requiring a write for the data and a write for the metadata.</p> <p>You can create and grow a file as quickly on Linux as you can on Windows.&nbsp;&nbsp; However, the first write on Linux results in the metadata maintenance.&nbsp;&nbsp; </p> <ul> <li>If database creation speed is a concern use Instant File Initialization and allow the first writes to encounter the additional overhead.&nbsp;&nbsp; <br><strong>Note:</strong> The overhead is often hidden by SQL Server as most writes take place with background processes such as Checkpoint or Lazy Writer.&nbsp; Bulk loading is an exception as write can occur on the active SQL Server session.<br> <li>If the creation speed can be elongated you can enable<strong> –T1805</strong> causing the database, data file space to be stamped during creation and growth.&nbsp;&nbsp; The stamping is optimized in large chunks and becomes the write path encountering the first write data and metadata operations.&nbsp;&nbsp; Once the location has been written (stamped) the writes no longer require the additional metadata write.</li></ul> <p><strong>Note:</strong> If the file system does not support fallocate the file is stamped with zeros by SQLPAL.&nbsp;&nbsp; The log file (LDF) always stamps a known pattern on top of the zeros and you can safely retain Instant File Initialization for the data files as the metadata has already been updated when SQLPAL zeroed the space.</p> <p><font color="#a5a5a5">Bob Dorr - Principal Software Engineer SQL Server</font></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL MYSTERIES: Tracing BCP Might Fool You</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-mysteries-tracing-bcp-might-fool-you</link>
      <pubDate>Tue, 07 Aug 2018 08:55:38 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=2855</guid>
      <description><![CDATA[Today I was tracking a large BCP.exe ‘IN’ operation and monitoring the sys.dm_exec_requests...]]></description>
      <content:encoded><![CDATA[<p>Today I was tracking a large BCP.exe ‘IN’ operation and monitoring the <font face="Courier New">sys.dm_exec_requests</font> entries.&nbsp; The ‘BULK INSERT’ command entry appeared, showing the CPU, reads, writes, … but these values where getting reset from time to time.&nbsp; Here are 3 snapshots from my system. </p> <p><font size="2" face="Courier New">cpu_time&nbsp;&nbsp;&nbsp; total_elapsed_time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; session_id&nbsp;&nbsp; start_time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; command </font> <p><font size="2" face="Courier New">1387&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1396&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2018-08-07 00:45:42.670 BULK INSERT<br></font><font size="2" face="Courier New">1930&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1941&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 66&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2018-08-07 00:46:02.087 BULK INSERT<br></font><font size="2"><font face="Courier New">632&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 638&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2018-08-07 00:46:23.313 BULK INSERT</font> </font> <p>Instead of a single BULK INSERT batch I saw multiple BULK INSERT batches taking place on the same session.&nbsp; When you specify the BCP, batch size (-b) the rows are streamed until the batch size is reached, a commit is issued and a new batch is started for subsequent rows.&nbsp; Thus, you see a series of BULK INSERT operations and not the BCP in it entirety.&nbsp; <p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: normal"><span><font color="#a6a6a6" face="Calibri"><font style="font-size: 8pt">Bob Dorr - </font></font><font style="font-size: 8pt"><font color="#a6a6a6" face="Calibri">Principal Software Engineer SQL Server</font></font></span></p>]]></content:encoded>
    </item>
    <item>
      <title>SQL Server Mysteries: The Case of the Dropped AD Group Login</title>
      <link>https://docs.microsoft.com/archive/blogs/bobsql/sql-server-mysteries-the-case-of-the-dropped-ad-group-login</link>
      <pubDate>Fri, 03 Aug 2018 11:19:08 GMT</pubDate>
      <dc:creator><![CDATA[RDORR]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/bobsql/?p=2845</guid>
      <description><![CDATA[Dylan (who kindly wrote up the contents of this blog for me) was modifying the tests for Active...]]></description>
      <content:encoded><![CDATA[<p><font color="#8064a2" size="2">Dylan (<em>who kindly wrote up the contents of this blog for me</em>) was modifying the tests for Active Directory Login activities.&nbsp; As Dylan and I reviewed the changes a specific behavior involving Active Directory Group Logins caught our attention.</font> <p><font size="2">Imagine you have a group on your domain [CONTOSO\group] which has a member [CONTOSO\user], and <strong>the [CONTOSO\group] has login permissions</strong> to a SQL Server instance. Running “DROP LOGIN [CONTOSO\group]” we expected that the [CONTOSO\user] would no longer have access to SQL Server.&nbsp; However, what we observed was:</font> <ul> <li><font size="2">New connections from [CONTOSO\user] are not accepted</font></li> <li><font size="2">Existing connections may still function as described </font><a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql?view=sql-server-2017"><font size="2">here</font></a><font size="2">&nbsp; (The existing [CONTOSO\user] connections have their group memberships and permissions cached, so the connection will be able to continue issuing queries until those values are refreshed.)</font></li></ul> <p><font size="2">If [CONTOSO\user] was added as a login and connected to SQL when “DROP LOGIN [CONTOSO\user]” was run, the “DROP LOGIN” command fails with error “Could not drop login 'CONTOSO\user' as the user is currently logged in.” Once [CONTOSO\user] disconnects, “DROP LOGIN [CONTOSO\user]” will succeed and the user will no longer have access to SQL Server.</font> <p><font size="2">If [CONTOSO\group] was added as a login and [CONTOSO\user] was logged in when you ran the command “DROP LOGIN [CONTOSO\group]”, the “DROP LOGIN” command succeeds. However, you can run “SELECT login_name FROM sys.dm_exec_sessions WHERE login_name = ‘CONTOSO\user’” to see that [CONTOSO\user] is still logged in.</font> <p><font size="2">When you run “DROP LOGIN &lt;loginName&gt;”, SQL Server checks if there are any active connections for the account &lt;loginName&gt;. If there are no connections active for this login, the login is removed, and the command succeeds. However, if the &lt;loginName&gt; is an AD group, SQL Server does not check if any members of the group have active logins.&nbsp; When we dropped [CONTOSO\group], the command succeeded because there were no active connections for [CONTOSO\group], even though [CONTOSO\user] was logged in and a member of [CONTOSO\group]. In fact, [CONTOSO\user] will stay connected until they perform a privileged action (e.g. create a login) or they reset their connection (e.g. log out and back in again, sp_reset_connection). At that time, SQL Server will check the permissions of [CONTOSO\user], see it no longer has a valid login, and kill the connection.</font> <p><font size="2">You can force these connections to be reset. After dropping the group login, run “SELECT session_id FROM sys.dm_exec_sessions WHERE login_name=’CONTOSO\user’”. This will give you the session IDs of all [CONTOSO\user]’s connections. Now, run “KILL &lt;session_id&gt;” to terminate the connection. The next time [CONTOSO\user] runs a query, they will be forced to recreate the connection which will fail because they no longer have a valid login.</font> <p><font size="2">The connection itself can also force a permissions update by calling sp_reset_connection which causes the thread to log out and back in to SQL Server. This is useful for connection pooling since the connections are persistent and do not perform permissions checks by continuously logging out and back in. By calling sp_reset_connection when you retrieve a pooled connection, the connection has to authenticate and fails if the login permissions have been revoked.</font> <p><font size="2">Now what about revoking permissions? Once permissions for an action are revoked for a group, the member users’ permissions are immediately revoked. For example, if [CONTOSO\group] had select permissions on table “foo”, and you ran “REVOKE SELECT ON foo TO [CONTOSO\group]”, [CONTOSO\user] would immediately lose their select permissions on “foo”.</font> <p><font size="2">Test it for yourself with the commands below:</font></p> <p><font size="2"><br># Login as an admin user to SQL Server and add [CONTOSO\group] as a login<br></font><font size="2">#<br></font><font size="2">CREATE LOGIN [CONTOSO\group] FROM WINDOWS<br></font><font size="2">GO</font></p> <p><font size="2"># In another terminal, login to SQL Server as [CONTOSO\user] and run a query to show you have access<br></font><font size="2">#<br></font><font size="2">SELECT @@VERSION<br></font><font size="2">GO</font> <p><font size="2"># Switch back to your admin terminal and drop the group login. It will succeed even though [CONTOSO\user] is connected.<br></font><font size="2">#<br></font><font size="2">DROP LOGIN [CONTOSO\group]<br></font><font size="2">GO</font> <p><font size="2"># Switch back to your [CONTOSO\user] window and check you still have access<br></font><font size="2">#<br>SELECT @@VERSION<br></font><font size="2">GO</font> <p><font size="2"># Switch to the admin terminal and kill the connection<br></font><font size="2">#<br>SELECT session_id FROM sys.dm_exec_sessions WHERE login_name = ‘CONTOSO\user’<br></font><font size="2">GO</font> <p><font size="2">KILL &lt;session_id from query above&gt;<br></font><font size="2">GO</font> <p><font size="2"># Switch to your [CONTOSO\user] window to see they no longer have access. This command should not return the version information.<br></font><font size="2">#<br></font><font size="2">SELECT @@VERSION<br></font><font size="2">GO</font> <p><font size="2"></font>&nbsp; <p><font color="#a5a5a5" size="2">Dylan Gray – Software Engineer<br>Bob Dorr – Principal Software Engineer</font>]]></content:encoded>
    </item>
  </channel>
</rss>