writeImageFile() without snapshot()?

Avi Bryant avi.bryant at gmail.com
Thu Oct 13 18:05:57 UTC 2005


On Oct 7, 2005, at 5:37 PM, Andreas Raab wrote:

> Avi -
>
> Try this: Instead of "self fullGC" in primSnapshot, try inserting:
>
>     "DISCLAIMER: This requires some careful review which I
>     don't have the time for right now. This is NOT working
>     or tested code so don't even think of submitting this
>     to VMMaker unless you actually understand why this ought
>     to work and what differences there possibly might be
>     between a full GC and an incremental GC + tenuring."
>
>     savedThreshold := tenuringThreshold. "remember prior threshold"
>     tenuringThreshold := 0. "reset tenuring threshold"
>     self incrementalGC. "force tenuring"
>     tenuringThreshold := savedThreshold.
>
> This may already be enough since tenuring will clean up the roots  
> and thus leave the image in a stable state. But of course, it does  
> require the image to perform a full GC if you want to reclaim space  
> before the snapshot.

For what it's worth (probably not much) I've been running for the  
last several days with this in place, along with a fork before  
writing out the image, and haven't seen any ill effects.  Here's the  
full #snapshot: I'm using:

snapshot: embedded
     "update state of active context"
     | activeProc dataSize rcvr setMacType savedThreshold |
     compilerInitialized
         ifTrue: [self compilerPreSnapshot]
         ifFalse: [self storeContextRegisters: activeContext].

     "update state of active process"
     activeProc _ self fetchPointer: ActiveProcessIndex ofObject:  
self schedulerPointer.
     self
         storePointer: SuspendedContextIndex
         ofObject: activeProc
         withValue: activeContext.

     "compact memory and compute the size of the memory actually in use"
     self incrementalGC.

     "DISCLAIMER: This requires some careful review which I
     don't have the time for right now. This is NOT working
     or tested code so don't even think of submitting this
     to VMMaker unless you actually understand why this ought
     to work and what differences there possibly might be
     between a full GC and an incremental GC + tenuring."

     savedThreshold _ tenuringThreshold. "remember prior threshold"
     tenuringThreshold _ 0. "reset tenuring threshold"
     self incrementalGC. "force tenuring"
     tenuringThreshold _ savedThreshold.

     self snapshotCleanUp.

     dataSize _ freeBlock - self startOfMemory. "Assume all objects  
are below the start of the free block"
     successFlag
         ifTrue: [rcvr _ self popStack.
             "pop rcvr"
             self push: trueObj.
             (self cCode: 'fork()') = 0 ifTrue: [self writeImageFile:  
dataSize. self cCode: '_exit(0)'].

             embedded
                 ifFalse: ["set Mac file type and creator; this is a  
noop on other platforms"
                     setMacType _ self ioLoadFunction:  
'setMacFileTypeAndCreator' From: 'FilePlugin'.
                     setMacType = 0
                         ifFalse: [self cCode: '((int (*) (char*,  
char*, char*)) setMacType) (getImageName(), "STim", "FAST")']].
             self pop: 1].

     "activeContext was unmarked in #snapshotCleanUp, mark it old "
     self beRootIfOld: activeContext.
     successFlag
         ifTrue: [self push: falseObj]
         ifFalse: [self push: rcvr].
     compilerInitialized
         ifTrue: [self compilerPostSnapshot]



More information about the Squeak-dev mailing list