The Trunk: Kernel-cmm.1049.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-cmm.1049.mcz

commits-2
Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.1049.mcz

==================== Summary ====================

Name: Kernel-cmm.1049
Author: cmm
Time: 11 November 2016, 2:55:37.977602 pm
UUID: c1a99cf9-1315-4aac-9bdb-c84fecc12912
Ancestors: Kernel-nice.1048

Give ReferenceStream the ability to serialize objects whose behaviors were extended via #primitiveChangeClassTo:.

=============== Diff against Kernel-nice.1048 ===============

Item was changed:
  ----- Method: Object>>storeDataOn: (in category 'objects from disk') -----
  storeDataOn: aDataStream
  "Store myself on a DataStream.  Answer self.  This is a low-level DataStream/ReferenceStream method. See also objectToStoreOnDataStream.  NOTE: This method must send 'aDataStream beginInstance:size:' and then (nextPut:/nextPutWeak:) its subobjects.  readDataFrom:size: reads back what we write here."
  | cntInstVars cntIndexedVars |
 
  cntInstVars := self class instSize.
  cntIndexedVars := self basicSize.
  aDataStream
+ beginInstance: self xxxClass
- beginInstance: self class
  size: cntInstVars + cntIndexedVars.
  1 to: cntInstVars do:
  [:i | aDataStream nextPut: (self instVarAt: i)].
 
  "Write fields of a variable length object.  When writing to a dummy
  stream, don't bother to write the bytes"
  ((aDataStream byteStream class == DummyStream) and: [self class isBits]) ifFalse: [
  1 to: cntIndexedVars do:
  [:i | aDataStream nextPut: (self basicAt: i)]].
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1049.mcz

Bert Freudenberg
On Fri, Nov 11, 2016 at 9:56 PM, <[hidden email]> wrote:
Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.1049.mcz

Give ReferenceStream the ability to serialize objects whose behaviors were extended via #primitiveChangeClassTo:.

Do you mean you subclassed an object but want it to be written as instance of its superclass? And you implemented xxxClass to return the superclass?
 

=============== Diff against Kernel-nice.1048 ===============
        | cntInstVars cntIndexedVars |

        cntInstVars := self class instSize.
        cntIndexedVars := self basicSize.
        aDataStream
+               beginInstance: self xxxClass
-               beginInstance: self class
                size: cntInstVars + cntIndexedVars.

I find the choice of xxxClass pretty odd. But maybe I can understand better if you could give an example how you use it.

- Bert - 


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1049.mcz

Chris Muller-3
> Do you mean you subclassed an object but want it to be written as instance
> of its superclass? And you implemented xxxClass to return the superclass?

Yes.

>
>>
>>
>> =============== Diff against Kernel-nice.1048 ===============
>>         | cntInstVars cntIndexedVars |
>>
>>         cntInstVars := self class instSize.
>>         cntIndexedVars := self basicSize.
>>         aDataStream
>> +               beginInstance: self xxxClass
>> -               beginInstance: self class
>>                 size: cntInstVars + cntIndexedVars.
>
>
> I find the choice of xxxClass pretty odd.

I don't care for the "xxx" nomenclature, I really wanted to use
#actualClass because its perfectly descriptive and something we
already have elsewhere.  Except not on Object.  At Object we have
Ted's #xxxClass from 1998 with two users.

I decided to use existing method rather than risk waking up sleeping
giant by introucing a new method into Object right now.  Right now I'm
only interested in addressing the performance issues of
source.squeak.org.

> But maybe I can understand better
> if you could give an example how you use it.

It is to support a performance fix for source.squeak.org.  One of the
bottlenecks I noticed while debugging the timeouts was the Magma
commit taking way too long.  If we were using ONLY a Magma backend,
then each repository save (Magma commit) should take only one or two
seconds.  However, because we are using both Magma AND the filesystem,
we were forced to read in the entire SSRepository object from Magma
into memory, instead of reading only the parts which are needed for
meeting user access demands.

This means that Magma's changed-detection took over a minute, because
a million objects have to be compared to their state in the DB to see
which ones changed and belong in that CommitPackage.

I want source.squeak.org to continue using FileBased for now, so my
solution to that was to turn on Magma's write-barrier feature.  Magma
incorporated Avi Bryant's WriteBarrier back in the mid 2000's so that
the changed-detection can run "as it goes" rather than as a bulk
operation part of the commit, once again speeding up commit saves to
sub-second.

The way it works is when an object is read from the DB, an anonymous
subclass is compiled which overrides all methods which could change an
instVar.  It compares the value on either side of the "super" call and
marks the object dirty then.  So the class of the object (and others
of its kind read in the future) is changed via #primChangeClassTo:.

But this creates an issue for ReferenceStream to send #class, because
we want to serialize instance of the superclass now.  The
anonymous subclass could not override #class to answer the superclass,
so it overrides #xxxClass, and ReferenceStream now sends, #xxxClass.

 - Chris