<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Benito,</p>
    <p>I'll see what I can do in that case.  I sense the optimisation
      may have to be done on a per-architecture basis because of it
      depending on how records are stored in memory.  I'll see what I
      can do though.  If it has to be a per-architecture optimisation,
      I'll only be able to do it for i386, x86_64 and whatever ARM
      processor is in my Raspberry Pi!<br>
    </p>
    <p>Gareth aka. Kit<br>
    </p>
    <div class="moz-cite-prefix">On 28/06/2020 12:22, Benito van der
      Zander wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:8361c3e9-6705-81aa-f75d-03acef1e7388@benibela.de">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div id="smartTemplate4-template">Hi J. Gareth,<br>
      </div>
      <div><br>
      </div>
      <div>that is a really important optimization.</div>
      <div><br>
      </div>
      <div>Especially with new record management operators. I am going
        to wrap almost all my variables in records, so they will be
        automatically initialized.<br>
      </div>
      <div><br>
      </div>
      <div>I have suggested it in the bug tracker, but it was closed,
        because they say the bug tracker is not for suggestions: <a
          class="moz-txt-link-freetext"
          href="https://bugs.freepascal.org/view.php?id=34915"
          moz-do-not-send="true">https://bugs.freepascal.org/view.php?id=34915</a><br>
        <br>
        Bye,<br>
        Benito </div>
      <div class="moz-cite-prefix">On 28.06.20 12:31, J. Gareth Moreton
        wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:e1ec1e5a-d00c-4f74-fd2b-aca3b0ac463b@moreton-family.com">
        <meta http-equiv="content-type" content="text/html;
          charset=UTF-8">
        <p>So someone reached out to me directly again asking for an FPC
          optimisation.  Now I want to see if this is possible to
          optimise and won't break something or be annoying specific.<br>
        </p>
        <div class="moz-forward-container">Gareth aka. Kit<br>
          <br>
          -------- Forwarded Message --------
          <table class="moz-email-headers-table" cellspacing="0"
            cellpadding="0" border="0">
            <tbody>
              <tr>
                <th valign="BASELINE" nowrap="nowrap" align="RIGHT">Subject:
                </th>
                <td>Re: An optimization suggestion for FPC</td>
              </tr>
              <tr>
                <th valign="BASELINE" nowrap="nowrap" align="RIGHT">Date:
                </th>
                <td>Sun, 28 Jun 2020 11:30:09 +0100</td>
              </tr>
              <tr>
                <th valign="BASELINE" nowrap="nowrap" align="RIGHT">From:
                </th>
                <td>J. Gareth Moreton <a class="moz-txt-link-rfc2396E"
                    href="mailto:gareth@moreton-family.com"
                    moz-do-not-send="true"><gareth@moreton-family.com></a></td>
              </tr>
              <tr>
                <th valign="BASELINE" nowrap="nowrap" align="RIGHT">To:
                </th>
                <td>Okoba <a class="moz-txt-link-rfc2396E"
                    href="mailto:okobapatino@protonmail.com"
                    moz-do-not-send="true"><okobapatino@protonmail.com></a></td>
              </tr>
            </tbody>
          </table>
          <br>
          <br>
          <meta http-equiv="Content-Type" content="text/html;
            charset=UTF-8">
          <p>Heh, I'm honoured you came to me directly.  I'll see if I
            can work anything out.  A lot of it is down to where the
            record is stored.  If it's on the stack, an optimisation
            shouldn't be difficult, but if it's on the heap somewhere,
            then it will be a bit more difficult.  Do you have your C++
            example, and which C++ compiler did you use?</p>
          <p>Gareth aka. Kit<br>
          </p>
          <div class="moz-cite-prefix">On 28/06/2020 11:06, Okoba wrote:<br>
          </div>
          <blockquote type="cite"
cite="mid:COSy75N1mtTY5M6vQwnzsgyu8OVBhd4k8garrPmksb_OhkIGbM6JKRQ1v9t7k4V46EyqUvoEmLOhGRQ8g_tc-9M4GIUn5sdyS8bmpm6p14k=@protonmail.com">
            <meta http-equiv="content-type" content="text/html;
              charset=UTF-8">
            <div>Hi,<br>
            </div>
            <div>It seems you are interested in optimizing FPC and I
              have a trouble with it and wanted to check it with you if
              I may.<br>
            </div>
            <div>I like to have a way to pass the record variable and
              inc it without losing speed. I wrote a sample and ran it
              with FPC trunk in Win64 and the times are commented. I
              should say the times for Delphi for the same target is the
              same. And tried a C++ version and all the times are almost
              the same and near 250.<br>
            </div>
            <div>I tried many ways including absolute, pointer, custom
              asm functions, custom functions with const and var params
              and the are almost always slower than the first loop.<br>
            </div>
            <div>So is there anyway to have a custom Inc function that
              get he record variable and inc it without losing speed in
              compare to the system inc?<br>
            </div>
            <div><br>
            </div>
            <div>Regards.</div>
            <div><br>
            </div>
            <div class="protonmail_signature_block
              protonmail_signature_block-empty">
              <div class="protonmail_signature_block-user
                protonmail_signature_block-empty"><br>
              </div>
              <div class="protonmail_signature_block-proton
                protonmail_signature_block-empty"><br>
              </div>
            </div>
            <div>program Project1;<br>
            </div>
            <div><br>
            </div>
            <div>uses<br>
            </div>
            <div>  SysUtils;<br>
            </div>
            <div><br>
            </div>
            <div>type<br>
            </div>
            <div>  TTest = record<br>
            </div>
            <div>    P: int64;<br>
            </div>
            <div>  end;<br>
            </div>
            <div><br>
            </div>
            <div>  procedure Test;<br>
            </div>
            <div>  var<br>
            </div>
            <div>    V: TTest;<br>
            </div>
            <div>    P: int64;<br>
            </div>
            <div>    T: UInt64;<br>
            </div>
            <div>    i, C: integer;<br>
            </div>
            <div>  begin<br>
            </div>
            <div>    C := 1000 * 1000 * 1000;<br>
            </div>
            <div><br>
            </div>
            <div>    T := GetTickCount64;<br>
            </div>
            <div>    P := 1;<br>
            </div>
            <div>    for i := 1 to C do<br>
            </div>
            <div>      Inc(P);<br>
            </div>
            <div>    WriteLn(GetTickCount64 - T); //266<br>
            </div>
            <div><br>
            </div>
            <div>    T := GetTickCount64;<br>
            </div>
            <div>    V.P := 1;<br>
            </div>
            <div>    for i := 1 to C do<br>
            </div>
            <div>      Inc(V.P);<br>
            </div>
            <div>    WriteLn(GetTickCount64 - T); //1400<br>
            </div>
            <div><br>
            </div>
            <div>    T := GetTickCount64;<br>
            </div>
            <div>    V.P := 1;<br>
            </div>
            <div>    P := V.P;<br>
            </div>
            <div>    for i := 1 to C do<br>
            </div>
            <div>      Inc(P);<br>
            </div>
            <div>    P := V.P;<br>
            </div>
            <div>    WriteLn(GetTickCount64 - T);  //250<br>
            </div>
            <div>  end;<br>
            </div>
            <div><br>
            </div>
            <div>begin<br>
            </div>
            <div>  Test;<br>
            </div>
            <div>  ReadLn;<br>
            </div>
            <div>end.<br>
            </div>
            <div><br>
            </div>
          </blockquote>
        </div>
        <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
          <table style="border-top: 1px solid #D3D4DE;">
            <tbody>
              <tr>
                <td style="width: 55px; padding-top: 13px;"><a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient"
                    target="_blank" moz-do-not-send="true"><img
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif"
                      alt="" style="width: 46px; height: 29px;"
                      moz-do-not-send="true" width="46" height="29"></a></td>
                <td style="width: 470px; padding-top: 12px; color:
                  #41424e; font-size: 13px; font-family: Arial,
                  Helvetica, sans-serif; line-height: 18px;">Virus-free.
                  <a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient"
                    target="_blank" style="color: #4453ea;"
                    moz-do-not-send="true">www.avast.com</a> </td>
              </tr>
            </tbody>
          </table>
          <a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
            height="1" moz-do-not-send="true"> </a></div>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-devel maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org" moz-do-not-send="true">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" moz-do-not-send="true">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
      </blockquote>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-devel maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
    </blockquote>
  </body>
</html>