[squeak-dev] UTCDateAndTime updated for Squeak trunk Chronology and Spur (was: UTCDateAndTime updated for Squeak 4.6/5.0)

David T. Lewis lewis at mail.msen.com
Tue Mar 15 11:52:56 UTC 2016


On Tue, Mar 15, 2016 at 10:02:20AM +0100, Bert Freudenberg wrote:
> If we have to touch the VM for this anyway, is there any reason not to use the Smalltalk epoch for this primitive, as Eliot suggested? This would put it in line with the other primitives (and make it slightly cheaper to use the skewed VM time).
> 
> - Bert -

There is no requirement to touch the VM, the current implementation in Cog/Spur
is sufficient. Levente's suggestion is a nice enhancement but not a requirement.
I have already added this to the UTCDateAndTime package in such a way that
Levente's approach is used if the VM supports it, otherwise my original
implementation is used at the cost of one extra Array instantiation when
calling DateAndTime now.

I would not want to change the current primitive, but it would be easy to
add an additional one with a different name such that a transition could be
done at a later time if someone wanted to do so. This is not a numbered
primitive, so it is not a problem to add a different implementation with
a slightly different name.

>From the point of view of UTCDateAndTime, using the Smalltalk epoch would be
a disadvantage because Olson time zone tables are based on Posix epoch. This
means that you would be converting Posix -> Smalltalk in the VM, then converting
it back to the Posix time base in the image.

The background on this is that I would like to be able to do a clean integration
of TimeZoneDatabase (the Olson tz tables) with DateAndTime, and get rid of 
the historical baggage associated with Squeak's original reliance on local
time in the VM. The overall result should be much easier to understand and
test, and will use concepts that are well documented on wikipedia.

Dave


> > On 15.03.2016, at 02:50, David T. Lewis <lewis at mail.msen.com> wrote:
> > 
> > Urk. Sorry for the confusion, but I was looking at the wrong image and I see
> > now that my original statement was correct:
> > 
> >   "I had the same idea, and I already implemented it in trunk interpreter
> >   VMMaker, but it is probably not in oscog yet. I did not add it on the
> >   image side, although we could do so if we update the VMs."
> > 
> > This is in the trunk VMM (interpreter VM), though not in Cog/Spur yet. Better
> > yet, it already works with Levente's idea (see below) of passing the DateAndTime
> > instance to the primitive. No further changes to the primitive are needed to
> > do this.
> > 
> > Therefore the following works in a Squeak 4.6 image with UTCDateAndTime loaded,
> > and running on an interpreter VM:
> > 
> >  DateAndTime>>initializeFromPrimitive
> > 	^Time primPosixMicrosecondClockWithOffset: self
> > 
> >  DateAndTime basicNew initializeFromPrimitive ==> 2016-03-14T21:38:49.81355-04:00
> > 
> > So I think this is a very good idea that just needs a couple of minor VM
> > updates to make it available.
> > 
> > Dave
> > 
> > 
> > On Sun, Mar 13, 2016 at 03:03:55PM -0400, David T. Lewis wrote:
> >> Apologies, this is not right. I was replying from a cell phone and my
> >> recollection was wrong.
> >> 
> >> I did at one point implement a #primitiveUtcWithOffset that could receive
> >> an array of size two as an argument into which the result values are stored,
> >> instead if allocating the array in the primitive. However, I did *not* commit
> >> it to VMMaker, and it is not in any currently available VMs.
> >> 
> >> I think I decided at the time that this approach was dangerous because it
> >> would invite problems in cases involving multiple processes, where some
> >> other process might call the primitive using the same array. In that case
> >> the time value in the array would magically change without the first process
> >> being aware.
> >> 
> >> I still think that it is a good idea, but maybe not worth the risk unless
> >> there is a noticable affect of performance or GC activity. Of course, adding
> >> the capability to the primitive would not force anyone to actually use it
> >> that way.
> >> 
> >> Sorry for the misinformation.
> >> 
> >> Dave
> >> 
> >> 
> >> On Sat, Mar 12, 2016 at 11:37:55PM -0500, David T. Lewis wrote:
> >>> I had the same idea, and I already implemented it in trunk interpreter
> >>> VMMaker, but it is probably not in oscog yet. I did not add it on the
> >>> image side, although we could do so if we update the VMs.
> >>> 
> >>> Dave
> >>> 
> >>>> I always forget to mention, even though I have had this idea since you had
> >>>> introduced primitiveUtcWithOffset, that it would be better if the
> >>>> primitive could take an optional argument to store the values in the first
> >>>> two slots of it instead of creating a new Array. If it's too much burden
> >>>> to accept any object, then the argument type can be limited to Array.
> >>>> This change would make it possible to decrease the GC pressure when many
> >>>> timestamps are created in a row.
> >>>> 
> >>>> Levente
> >>>> 
> >>>> On Sat, 12 Mar 2016, David T. Lewis wrote:
> >>>> 
> >>>>> On Mon, Mar 07, 2016 at 12:21:38AM -0500, David T. Lewis wrote:
> >>>>>> On Sun, May 24, 2015 at 12:36:02PM -0400, David T. Lewis wrote:
> >>>>>>> UTCDateAndTime is a UTC based implementation of class DateAndTime with
> >>>>>>> one instance variable representing the magnitude of the point in time,
> >>>>>>> and another representing local time zone offset.
> >>>>>> 
> >>>>>> I have updated the UTCDateAndTime package to make it loadable in the
> >>>>>> latest
> >>>>>> Squeak trunk and Spur.
> >>>>> 
> >>>>> Has anyone looked at this yet? Any interest?
> >>>>> 
> >>>>> Dave
> >>>>> 
> >>>>>> 
> >>>>>> A new Monticello repository is at
> >>>>>> http://www.squeaksource.com/UTCDateAndTime.
> >>>>>> The home page (with a new SAR) is at
> >>>>>> http://wiki.squeak.org/squeak/6197.
> >>>>>> 
> >>>>>> Starting with an updated trunk image, you can load UTCDateAndTime in
> >>>>>> two ways:
> >>>>>> 
> >>>>>> 1) Open the http://www.squeaksource.com/UTCDateAndTime repository, and
> >>>>>> load
> >>>>>> the MCZ files in sequence beginning with Chronology-Core-dtl.3.
> >>>>>> 
> >>>>>> 2) In a preferences browser, in category 'updates' set the 'Update URL'
> >>>>>> preference to 'http://www.squeaksource.com/UTCDateAndTime', and do
> >>>>>> world -> help... -> update code from server.
> >>>>>> 
> >>>>>> The main objective of UTCDateAndTime is to make DateAndTime
> >>>>>> conceptually
> >>>>>> simpler, but a happy side effect is that it is also significantly
> >>>>>> faster
> >>>>>> than the old implementation.
> >>>>>> 
> >>>>>> Dave
> >>>>> 
> >>>>> 
> >>>> 
> >>> 
> >>> 
> >>> 
> >>> 
> > 
> 
> 



> 



More information about the Squeak-dev mailing list