<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 25, 2016 at 8:51 AM, David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Thu, Mar 24, 2016 at 10:05:17PM -0700, Eliot Miranda wrote:<br>
><br>
><br>
> > On Mar 23, 2016, at 6:55 PM, David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br>
> ><br>
> >> On Wed, Mar 23, 2016 at 05:50:19PM -0700, Eliot Miranda wrote:<br>
> >>> On Wed, Mar 23, 2016 at 4:51 PM, David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br>
> >>><br>
> >>>> On Wed, Mar 23, 2016 at 04:22:21PM -0700, Eliot Miranda wrote:<br>
> >>>><br>
> >>>> Turns out this isn't needed for Cog. I have ioLocalSecondsOffset which<br>
> >>>> answers a value determined at start-up and only changed<br>
> >>>> via ioUpdateVMTimezone, which itself is controlled by<br>
> >>>> primitiveUpdateTimezone, #243. So ioUTCMicroseconds is all that's needed<br>
> >>>> to get at the clock and timezone atomically.<br>
> >>><br>
> >>> If it is updated at start-up, then it's wrong. Think of daylight savings<br>
> >>> time transitions.<br>
> >><br>
> >> So update it automatically once a second or some such?<br>
> ><br>
> > Are you joking, or is that a serious question?<br>
><br>
> Yes. I see two or three system calls in the code below. gettimeofday, one inside localtime and one inside gmtime. That's expensive.<br>
><br>
<br>
</span>It's gettimeofday() and localtime(). The #else is fallback for older unix platforms.<br></blockquote><div><br></div><div>As I said, two or three.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">In any case, caching the value and updating it periodically does not sound like a good idea to me.<br></blockquote><div><br></div><div>Why not? Why does the time zone need to be determined on every time call even though it only has a resolution of seconds? If including the timezone in every time call slows down accessing the time by, say, 33%, is it a good idea, when the VM can easily eliminate this overhead?</div><div><br></div><div><div>| c |</div><div>c := LargePositiveInteger.</div><div>[1 to: 10000000 do: [:i| c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8. c basicNew: 8]] timeToRun 884</div><div><br></div><div><br></div><div><br></div><div>[1 to: 10000000 do: [:i| Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock. Time utcMicrosecondClock]] timeToRun 6412</div><div><br></div><div><br></div><div>6412 / 884.0 7.253393665158371</div></div><div><br></div><div>So the overhead of the system calls involved in accessing time are much greater than the costs of allocating and garbage collecting 64-bit large integer results; much larger.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dave<br>
<div class=""><div class="h5"><br>
<br>
> ><br>
> > Confused,<br>
> > Dave<br>
> ><br>
> ><br>
> > /* implementation of ioUtcWithOffset(), defined in config.h to<br>
> > /* override default definition in src/vm/interp.h<br>
> > */<br>
> > sqInt sqUnixUtcWithOffset(sqLong *microSeconds, int *offset)<br>
> > {<br>
> > struct timeval timeval;<br></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">
> > if (gettimeofday(&timeval, NULL) == -1) return -1;<br>
> > time_t seconds= timeval.tv_sec;<br>
> > suseconds_t usec= timeval.tv_usec;<br>
> > *microSeconds= seconds * 1000000 + usec;<br>
> > #if defined(HAVE_TM_GMTOFF)<br>
> > *offset= localtime(&seconds)->tm_gmtoff;<br>
> > #else<br>
> > {<br>
> > struct tm *local= localtime(&seconds);<br>
> > struct tm *gmt= gmtime(&seconds);<br>
> > int d= local->tm_yday - gmt->tm_yday;<br>
> > int h= ((d < -1 ? 24 : 1 < d ? -24 : d * 24) + local->tm_hour - gmt->tm_hour);<br>
> > int m= h * 60 + local->tm_min - gmt->tm_min;<br>
> > *offset= m * 60;<br>
> > }<br>
> > #endif<br>
> > return 0;<br>
> > }<br>
> ><br>
> ><br>
> ><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>