<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:d="http://www.askemos.org/2000/NameSpaceDSSSL" xmlns:editor="urn:editor" xmlns:mind="http://www.askemos.org/2000/CoreAPI" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xml:space="default">
 <editor:state>
  <mind:tick>Fri, 29 Oct 2004 21:24:59 +0200</mind:tick>
  <errors>0</errors>
 </editor:state>
 <xsl:template match="request[@type=&quot;read&quot;]">
  <xsl:choose>
   <d:when test="(is-meta-form? msg)">
    <d:copy-of select="
(if (is-metainfo-request? msg)
    (me (me &apos;get &apos;id) &apos;metainfo)
    (message-body (metaview me msg)))"></d:copy-of>
   </d:when>
   <xsl:otherwise>
    <html>
     <head>
      <title>Accuracy Test</title>
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"></meta>
      <style type="text/css">
dt {
   font-weight:bold;
}
sub,sup {
   font-size:80%;
}
.footnote{
  font-size:80%;
  width:50%;
  border:solid blue 1px;
}
</style>
     </head>
     <body bgcolor="white" style="font-size: 10pt;">
      <h2 align="center"><a href="/Ad60e3fb123a79b2e5128915116b288f7/index.html">Askemos</a> Accuracy Test</h2>
      <h3>About the Test</h3>
      <p>Here we compute some statistics on the accuracy of the
Askemos network.
Accuracy is approximately the equivalent of "<code>uptime</code>"
for physical computers.
Within the network we have two types of availability:
</p>
      <dl>
       <dt>locally available / read available</dt>
       <dd>Data can be read, and modified on a single machine,
but modification with respect to replica synchrony is not checked.</dd>
       <dt>replica synchrony / write available</dt>
       <dd>A replicated transaction
was performed under non-repudiation protocol.</dd>
      </dl>
      <p>Since we run from the same basic hardware and
- for the most part - software setup as most web services
(PC's loaded with
<a href="http://www.kernel.org/">Linux</a>
or
<a href="http://www.freebsd.org/">FreeBSD</a>)
average read availability is a fixed value of about 99.999%
(less than 5 minutes a year of downtime).</p>
      <h3>Test Setup</h3>
      <p>To measure replica synchrony,
each node in the network is configured to send
a local, public write message with it's idea of current time
to it's replica of
<d:a d:href="(literal #\/ (me &quot;clock&quot;))">the clock over there</d:a>.
The nodes try to find an
<a href="/A849640f672ed0df0958abc0712110f3c/ByzantineAgreement">agreement</a>
on that common time
and if that can be found within 5 seconds,
keep it and notify this agent here.</p>
      <p>
Here in turn we run the agreement protocol again
to count how many minutes passed since the
last agreed-on time tick.
Furthermore we count the missing minutes as errors.</p>
      <h3>Interpretation</h3>
      <p>The whole test amounts to two runs of the protocol,
which both fail with a certain probability for a variety of reasons
like network latency, messages drops,
delays from data base access, software updates,
broken hardware etc.
The time out of 5 seconds is actually sometimes hard to meet for the
WAN test setup,
though on average we have less than 0.3 seconds per agreement
over SSL.
The logfile confirms, that messages arrive as late as 20 seconds
past the full minute.</p>
      <p>The reason for the low availability measured here
is that we measure the test network, which has downtime
due to bugs.</p>
      <p>
The average accuracy is
with <var>a<sub>total</sub></var> total number of agreements (failed and successful)
and <var>a<sub>failure</sub></var> number of failures roughly<a href="#footnote1"><sup>[1]</sup></a>:
</p>
      <p style="text-align:center;">
       <img alt="P_{accuracy} = \sqrt\frac{a_{total} - a_{failure}}{a_{total}}" height="67" src="/Aca8d2a68a7b9854f41f8305eda2dffd3" width="300"></img>
      </p>
      <h3>Results</h3>
      <table align="center" border="1" cellpadding="5pt" style="border:1px solid; border-collapse: collapse;">
       <tr>
        <th>Current Time</th>
        <td>
         <d:copy-of select="(literal (current-date (date-zone-offset (msg &apos;dc-date))))"></d:copy-of>
        </td>
       </tr>
       <tr>
        <th>Checked Time</th>
        <td>
         <d:copy-of select="((sxpath &apos;(state tick *text*)) (grove-root (current-node)))"></d:copy-of>
        </td>
       </tr>
       <tr>
        <th>Failure Count</th>
        <td>
         <d:copy-of select="((sxpath &apos;(state errors *text*)) (grove-root (current-node)))"></d:copy-of>
         <smaller> (<a href="/Aa74788d1a4ebf89ce05546df215cd7db">failure notes</a>)</smaller>
        </td>
       </tr>
       <tr>
        <th>Accuracy</th>
        <td><d:copy-of select="((sxpath &apos;(state avail *text*)) (grove-root (current-node)))"></d:copy-of>%</td>
       </tr>
      </table>
      <h3>Source</h3>
      <p>You may visit <d:a d:href="
(read-locator (msg &apos;location-format)
  (list body: &quot;xmlns=mind&quot; (me &apos;get &apos;id)))
">this place in debug mode</d:a> (read only)
or read the <a href="/A367597ff503cbd42948f9fe705ff3197/AccuracyCounter.xml">source code</a> of the agent.</p>
      <hr></hr>
      <p>
       <a name="footnote1"><sup>[1] </sup> Only geometric mean at this time. There is a need for
more spot test data to gather enough information to evaluate
a sufficient guess for the distribution. We can not take
a normal distribution as given.
</a>
      </p>
     </body>
    </html>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="request[@type=&quot;write&quot;]">
  <xsl:variable name="now">
   <d:copy-of select="(children (current-node))"></d:copy-of>
  </xsl:variable>
  <xsl:variable name="next">
   <editor:state xml:space="default">
    <d:copy-of select="
(let* ((last-tick (data ((sxpath &apos;(state tick))
                         (grove-root (current-node)))))
       (last-time (date-&gt;time-utc
                    (if (string-null? last-tick) (msg 'dc-date)
                        (string-&gt;date last-tick
                         &quot;~a, ~d ~b ~Y ~H:~M:~S ~z&quot;))))
       (n (quotient (- (time-second (date-&gt;time-utc (msg &apos;dc-date)))
                       (time-second last-time) 5)
                    60))
       (e (string-&gt;number (data ((sxpath &apos;(state errors))
                                    (grove-root (current-node)))))))
(node-list
 (select-elements (xsl-variable &quot;now&quot;) &apos;tick)
 (make element gi: &apos;errors (literal (+ n e)))
 (make element gi: &apos;avail
  (literal (let ((total (/ (- (time-second last-time) 1116892800) 60)))
     (* 100 (sqrt (/ (- total (+ n e)) total))))))
))
"></d:copy-of>
   </editor:state>
  </xsl:variable>
  <d:if test="(or
 (eq? (msg &apos;caller) (me &quot;clock&quot;))
 (error &quot;wrong caller&quot;))">
   <mind:reply>
    <d:copy-of select="#CONTENT">
(root
    (let ((this-root (document-element (grove-root (current-node)))))
      (make element
        gi: (gi this-root) ns: (ns this-root)
        attributes: (copy-attributes this-root)
        (node-list-map
         (lambda (node)
           (cond
            ((match-element? 'state node)
             (xsl-variable "next"))
            ((match-element? 'include node) (make element gi: 'include ns: (ns this-root) attributes: `((href "A367597ff503cbd42948f9fe705ff3197/AccuracyCounter.xml"))))
            (else node)))
         ;; The children of the root of the style sheet.
         ((sxpath '(*)) this-root)))))
   </d:copy-of>
   </mind:reply>
  </d:if>
 </xsl:template>
</xsl:stylesheet>
