Problem with #garbageCollect and -memory parameter

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

Problem with #garbageCollect and -memory parameter

Mariano Martinez Peck
 
Hi folks. I am using the standard SqueakVM  4.2.5beta1U.
If I run normaly the VM with a normal Pharo image and I print Smalltalk garbageCollect -> I get something like  492130460

Now...if I run the vm with the parameter -memory 1500m  and I then print Smalltalk garbageCollect -> I get a NEGATIVE number like:  -619402660

I guess there is a problem in somewhere like ObjectMemory >> bytesLeft:
but I don't know...

Anyway, the problem in my case is in SmalltalkImage:

okayToProceedEvenIfSpaceIsLow
    "Return true if either there is enough memory to do so safely or if the user gives permission after being given fair warning."

    self garbageCollectMost > self lowSpaceThreshold ifTrue: [^ true].  "quick"
    self garbageCollect > self lowSpaceThreshold ifTrue: [^ true].  "work harder"

    ^ self confirm:
'WARNING: There is not enough space to start the low space watcher.
If you proceed, you will not be warned again, and the system may
run out of memory and crash. If you do proceed, you can start the
low space notifier when more space becomes available simply by
opening and then closing a debugger (e.g., by hitting Cmd-period.)
Do you want to proceed?'


Since both of the first answers false because, of course garbageCollectMost and garbageCollect are negative....
then I have that poup all the time.

To fix this I have to posibilities:

1) Just patch this particular method to:

self garbageCollectMost.
self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "quick"
self garbageCollect
self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "work harder"

Notice that primBytesLeft is answering correct. Wait..I don't know if correct, but at least possitive:  5691396
I think this is possitive because the primitive is not receiving a parameter, and thus, Interpreter >> primitiveBytesLeft
evaluates the first part of the method, which just does self sizeOfFree: freeBlock , and not the second part where it does self bytesLeft: aBool.

2) understand why it is negative and fix it from the VM side (I have no idea how to do this).

Now, in addition, I wonder if there may be other places broken because of this....I am having some crashed and I don't know why :(

Thanks in advance,

Mariano
Reply | Threaded
Open this post in threaded view
|

Re: Problem with #garbageCollect and -memory parameter

David T. Lewis
 
Hi,

I'm away and cannot check this right now, but if you look in the
SqS/VMMaker archive there there are a number of recent updates that
may address this problem. See the Montecello update comments for
VMMaker-dtl.188, VMMaker-dtl.199, and VMMaker-dtl.200 for summaries.
These updates would not be in any of the released VMs at this point,
but I have a hunch that they will take care of this problem.

Dave


On Tue, Nov 30, 2010 at 02:43:50PM +0100, Mariano Martinez Peck wrote:

>  
> Hi folks. I am using the standard SqueakVM  4.2.5beta1U.
> If I run normaly the VM with a normal Pharo image and I print Smalltalk
> garbageCollect -> I get something like  492130460
>
> Now...if I run the vm with the parameter -memory 1500m  and I then print
> Smalltalk garbageCollect -> I get a NEGATIVE number like:  -619402660
>
> I guess there is a problem in somewhere like ObjectMemory >> bytesLeft:
> but I don't know...
>
> Anyway, the problem in my case is in SmalltalkImage:
>
> okayToProceedEvenIfSpaceIsLow
>     "Return true if either there is enough memory to do so safely or if the
> user gives permission after being given fair warning."
>
>     self garbageCollectMost > self lowSpaceThreshold ifTrue: [^ true].
> "quick"
>     self garbageCollect > self lowSpaceThreshold ifTrue: [^ true].  "work
> harder"
>
>     ^ self confirm:
> 'WARNING: There is not enough space to start the low space watcher.
> If you proceed, you will not be warned again, and the system may
> run out of memory and crash. If you do proceed, you can start the
> low space notifier when more space becomes available simply by
> opening and then closing a debugger (e.g., by hitting Cmd-period.)
> Do you want to proceed?'
>
>
> Since both of the first answers false because, of course garbageCollectMost
> and garbageCollect are negative....
> then I have that poup all the time.
>
> To fix this I have to posibilities:
>
> 1) Just patch this particular method to:
>
> self garbageCollectMost.
> self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "quick"
> self garbageCollect
> self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "work harder"
>
> Notice that primBytesLeft is answering correct. Wait..I don't know if
> correct, but at least possitive:  5691396
> I think this is possitive because the primitive is not receiving a
> parameter, and thus, Interpreter >> primitiveBytesLeft
> evaluates the first part of the method, which just does self sizeOfFree:
> freeBlock , and not the second part where it does self bytesLeft: aBool.
>
> 2) understand why it is negative and fix it from the VM side (I have no idea
> how to do this).
>
> Now, in addition, I wonder if there may be other places broken because of
> this....I am having some crashed and I don't know why :(
>
> Thanks in advance,
>
> Mariano

Reply | Threaded
Open this post in threaded view
|

Re: Problem with #garbageCollect and -memory parameter

Mariano Martinez Peck
 


On Tue, Nov 30, 2010 at 5:14 PM, David T. Lewis <[hidden email]> wrote:

Hi,

I'm away and cannot check this right now, but if you look in the
SqS/VMMaker archive there there are a number of recent updates that
may address this problem. See the Montecello update comments for
VMMaker-dtl.188, VMMaker-dtl.199, and VMMaker-dtl.200 for summaries.
These updates would not be in any of the released VMs at this point,
but I have a hunch that they will take care of this problem.

Hi Dave. Ok...after a couple of hours I could compile a new VM for MacOS with VMMaker 205 and integrating all my changes :)
So....this was something I have to do since several months already hehhehe

Now, as you guessed, something  was related to that. Now, these are the results:

normal:

Smalltalk garbageCollect   481957728
Smalltalk primBytesLeft 5738200

with -memory 1500m

Smalltalk garbageCollect    482093452
Smalltalk primBytesLeft 6444200
 

Now, at least it is not negative. But I wonder....shouldn't I have more bytes left when I send 1500m ?
how can I be sure that the VM is actually tacking into account this parameter?
can I check some parameter in Smalltalk vmParameterAt:
?

thanks!

mariano


Dave


On Tue, Nov 30, 2010 at 02:43:50PM +0100, Mariano Martinez Peck wrote:
>
> Hi folks. I am using the standard SqueakVM  4.2.5beta1U.
> If I run normaly the VM with a normal Pharo image and I print Smalltalk
> garbageCollect -> I get something like  492130460
>
> Now...if I run the vm with the parameter -memory 1500m  and I then print
> Smalltalk garbageCollect -> I get a NEGATIVE number like:  -619402660
>
> I guess there is a problem in somewhere like ObjectMemory >> bytesLeft:
> but I don't know...
>
> Anyway, the problem in my case is in SmalltalkImage:
>
> okayToProceedEvenIfSpaceIsLow
>     "Return true if either there is enough memory to do so safely or if the
> user gives permission after being given fair warning."
>
>     self garbageCollectMost > self lowSpaceThreshold ifTrue: [^ true].
> "quick"
>     self garbageCollect > self lowSpaceThreshold ifTrue: [^ true].  "work
> harder"
>
>     ^ self confirm:
> 'WARNING: There is not enough space to start the low space watcher.
> If you proceed, you will not be warned again, and the system may
> run out of memory and crash. If you do proceed, you can start the
> low space notifier when more space becomes available simply by
> opening and then closing a debugger (e.g., by hitting Cmd-period.)
> Do you want to proceed?'
>
>
> Since both of the first answers false because, of course garbageCollectMost
> and garbageCollect are negative....
> then I have that poup all the time.
>
> To fix this I have to posibilities:
>
> 1) Just patch this particular method to:
>
> self garbageCollectMost.
> self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "quick"
> self garbageCollect
> self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "work harder"
>
> Notice that primBytesLeft is answering correct. Wait..I don't know if
> correct, but at least possitive:  5691396
> I think this is possitive because the primitive is not receiving a
> parameter, and thus, Interpreter >> primitiveBytesLeft
> evaluates the first part of the method, which just does self sizeOfFree:
> freeBlock , and not the second part where it does self bytesLeft: aBool.
>
> 2) understand why it is negative and fix it from the VM side (I have no idea
> how to do this).
>
> Now, in addition, I wonder if there may be other places broken because of
> this....I am having some crashed and I don't know why :(
>
> Thanks in advance,
>
> Mariano


Reply | Threaded
Open this post in threaded view
|

Re: Problem with #garbageCollect and -memory parameter

Mariano Martinez Peck
 


On Wed, Dec 1, 2010 at 12:11 AM, Mariano Martinez Peck <[hidden email]> wrote:


On Tue, Nov 30, 2010 at 5:14 PM, David T. Lewis <[hidden email]> wrote:

Hi,

I'm away and cannot check this right now, but if you look in the
SqS/VMMaker archive there there are a number of recent updates that
may address this problem. See the Montecello update comments for
VMMaker-dtl.188, VMMaker-dtl.199, and VMMaker-dtl.200 for summaries.
These updates would not be in any of the released VMs at this point,
but I have a hunch that they will take care of this problem.

Hi Dave. Ok...after a couple of hours I could compile a new VM for MacOS with VMMaker 205 and integrating all my changes :)
So....this was something I have to do since several months already hehhehe

Now, as you guessed, something  was related to that. Now, these are the results:

normal:

Smalltalk garbageCollect   481957728
Smalltalk primBytesLeft 5738200

with -memory 1500m

Smalltalk garbageCollect    482093452
Smalltalk primBytesLeft 6444200

mmmmmmm  if instead of sending -memory I modify Info.plist  and I set 1572864000  (1500gb)
then I get

Smalltalk garbageCollect  1518058920
Smalltalk primBytesLeft 5898636

:)

so maybe the mac vm is not taking into acount -memory but it does the file?

Cheers

Mariano
 
 

Now, at least it is not negative. But I wonder....shouldn't I have more bytes left when I send 1500m ?
how can I be sure that the VM is actually tacking into account this parameter?
can I check some parameter in Smalltalk vmParameterAt:
?

thanks!

mariano


Dave


On Tue, Nov 30, 2010 at 02:43:50PM +0100, Mariano Martinez Peck wrote:
>
> Hi folks. I am using the standard SqueakVM  4.2.5beta1U.
> If I run normaly the VM with a normal Pharo image and I print Smalltalk
> garbageCollect -> I get something like  492130460
>
> Now...if I run the vm with the parameter -memory 1500m  and I then print
> Smalltalk garbageCollect -> I get a NEGATIVE number like:  -619402660
>
> I guess there is a problem in somewhere like ObjectMemory >> bytesLeft:
> but I don't know...
>
> Anyway, the problem in my case is in SmalltalkImage:
>
> okayToProceedEvenIfSpaceIsLow
>     "Return true if either there is enough memory to do so safely or if the
> user gives permission after being given fair warning."
>
>     self garbageCollectMost > self lowSpaceThreshold ifTrue: [^ true].
> "quick"
>     self garbageCollect > self lowSpaceThreshold ifTrue: [^ true].  "work
> harder"
>
>     ^ self confirm:
> 'WARNING: There is not enough space to start the low space watcher.
> If you proceed, you will not be warned again, and the system may
> run out of memory and crash. If you do proceed, you can start the
> low space notifier when more space becomes available simply by
> opening and then closing a debugger (e.g., by hitting Cmd-period.)
> Do you want to proceed?'
>
>
> Since both of the first answers false because, of course garbageCollectMost
> and garbageCollect are negative....
> then I have that poup all the time.
>
> To fix this I have to posibilities:
>
> 1) Just patch this particular method to:
>
> self garbageCollectMost.
> self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "quick"
> self garbageCollect
> self primBytesLeft > self lowSpaceThreshold ifTrue: [^ true].  "work harder"
>
> Notice that primBytesLeft is answering correct. Wait..I don't know if
> correct, but at least possitive:  5691396
> I think this is possitive because the primitive is not receiving a
> parameter, and thus, Interpreter >> primitiveBytesLeft
> evaluates the first part of the method, which just does self sizeOfFree:
> freeBlock , and not the second part where it does self bytesLeft: aBool.
>
> 2) understand why it is negative and fix it from the VM side (I have no idea
> how to do this).
>
> Now, in addition, I wonder if there may be other places broken because of
> this....I am having some crashed and I don't know why :(
>
> Thanks in advance,
>
> Mariano



Reply | Threaded
Open this post in threaded view
|

Re: Problem with #garbageCollect and -memory parameter

David T. Lewis
 
On Wed, Dec 01, 2010 at 12:41:44AM +0100, Mariano Martinez Peck wrote:

>  
> On Wed, Dec 1, 2010 at 12:11 AM, Mariano Martinez Peck <
> [hidden email]> wrote:
> >
> > On Tue, Nov 30, 2010 at 5:14 PM, David T. Lewis <[hidden email]>wrote:
> >>
> >> I'm away and cannot check this right now, but if you look in the
> >> SqS/VMMaker archive there there are a number of recent updates that
> >> may address this problem. See the Montecello update comments for
> >> VMMaker-dtl.188, VMMaker-dtl.199, and VMMaker-dtl.200 for summaries.
> >> These updates would not be in any of the released VMs at this point,
> >> but I have a hunch that they will take care of this problem.
> >>
> >
> > Hi Dave. Ok...after a couple of hours I could compile a new VM for MacOS
> > with VMMaker 205 and integrating all my changes :)
> > So....this was something I have to do since several months already hehhehe
> >
> > Now, as you guessed, something  was related to that. Now, these are the
> > results:
> >
> > normal:
> >
> > Smalltalk garbageCollect   481957728
> > Smalltalk primBytesLeft 5738200
> >
> > with -memory 1500m
> >
> > Smalltalk garbageCollect    482093452
> > Smalltalk primBytesLeft 6444200
> >
>
> mmmmmmm  if instead of sending -memory I modify Info.plist  and I set
> 1572864000  (1500gb)
> then I get
>
> Smalltalk garbageCollect  1518058920
> Smalltalk primBytesLeft 5898636
>
> :)
>
> so maybe the mac vm is not taking into acount -memory but it does the file?

Well that's as good a theory as anything I could have made up ;-)

To be serious, the -memory parameter is part of the unix VM, and
other platforms may do things differently. So yes, I think you
have found the right explanation.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Problem with #garbageCollect and -memory parameter

johnmci

If you are compiling your own macintosh VM then go look at
sqSqueakOSXApplication.m

- (NSInteger) parseArgument: (NSString *) argData peek: (NSString *) peek {
...
        if ([argData compare: @"-memory"] == NSOrderedSame) {
                gMaxHeapSize = (usqInt) [self strtobkm: [peek UTF8String]];
                return 2;
        }
        return 0;
}

and follow the bouncing gMaxHeapSize to see what happens.
You'll find the use at
         startOfmmapForANONMemory = mmap(startOfAnonymousMemory, freeSpaceRoundedUpToPageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED,0,(off_t)0);

in sqMacV2Memory.c


On 2010-11-30, at 5:03 PM, David T. Lewis wrote:

>
> On Wed, Dec 01, 2010 at 12:41:44AM +0100, Mariano Martinez Peck wrote:
>>
>> On Wed, Dec 1, 2010 at 12:11 AM, Mariano Martinez Peck <
>> [hidden email]> wrote:
>>>
>>> On Tue, Nov 30, 2010 at 5:14 PM, David T. Lewis <[hidden email]>wrote:
>>>>
>>>> I'm away and cannot check this right now, but if you look in the
>>>> SqS/VMMaker archive there there are a number of recent updates that
>>>> may address this problem. See the Montecello update comments for
>>>> VMMaker-dtl.188, VMMaker-dtl.199, and VMMaker-dtl.200 for summaries.
>>>> These updates would not be in any of the released VMs at this point,
>>>> but I have a hunch that they will take care of this problem.
>>>>
>>>
>>> Hi Dave. Ok...after a couple of hours I could compile a new VM for MacOS
>>> with VMMaker 205 and integrating all my changes :)
>>> So....this was something I have to do since several months already hehhehe
>>>
>>> Now, as you guessed, something  was related to that. Now, these are the
>>> results:
>>>
>>> normal:
>>>
>>> Smalltalk garbageCollect   481957728
>>> Smalltalk primBytesLeft 5738200
>>>
>>> with -memory 1500m
>>>
>>> Smalltalk garbageCollect    482093452
>>> Smalltalk primBytesLeft 6444200
>>>
>>
>> mmmmmmm  if instead of sending -memory I modify Info.plist  and I set
>> 1572864000  (1500gb)
>> then I get
>>
>> Smalltalk garbageCollect  1518058920
>> Smalltalk primBytesLeft 5898636
>>
>> :)
>>
>> so maybe the mac vm is not taking into acount -memory but it does the file?
>
> Well that's as good a theory as anything I could have made up ;-)
>
> To be serious, the -memory parameter is part of the unix VM, and
> other platforms may do things differently. So yes, I think you
> have found the right explanation.
>
> Dave
>
>

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




Reply | Threaded
Open this post in threaded view
|

Re: Problem with #garbageCollect and -memory parameter

Mariano Martinez Peck
 


On Wed, Dec 1, 2010 at 2:09 AM, John M McIntosh <[hidden email]> wrote:

If you are compiling your own macintosh VM

Thanks John for the answer. Yes, I am compiling my own, but the problem is present with the standard vm also. I answer above....
 
then go look at
sqSqueakOSXApplication.m

- (NSInteger) parseArgument: (NSString *) argData peek: (NSString *) peek {
...
       if ([argData compare: @"-memory"] == NSOrderedSame) {
               gMaxHeapSize = (usqInt) [self strtobkm: [peek UTF8String]];
               return 2;
       }
       return 0;
}



I tried this passing -memory 1500m.  The value is get and set correct here.
So, after this, we have:
gMaxHeapSize = 1572864000


The problem is that after, when you choose the image to start, and the function sqAllocateMemoryMac is called, gMaxHeapSize lost the value passes by -memory and has again the default.
So, in this case, when this function is called,

gMaxHeapSize = 536870912

and not 1572864000


 
and follow the bouncing gMaxHeapSize to see what happens.
You'll find the use at
        startOfmmapForANONMemory = mmap(startOfAnonymousMemory, freeSpaceRoundedUpToPageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED,0,(off_t)0);

in sqMacV2Memory.c



Here it doesn't pass because the big if
    if (gSqueakUseFileMappedMMAP) {
returns 0 since this is the value it has in the Info.plist

What is that if I set a special value in SqueakMaxHeapSize (1572864000) weird is that enabling or not that value, I have more or less the same results:

gSqueakUseFileMappedMMAP  ->   0
Smalltalk garbageCollect  1505201876

gSqueakUseFileMappedMMAP  ->   1
Smalltalk garbageCollect  1505199640

But in one case the
startOfmmapForANONMemory = mmap(startOfAnonymousMemory, freeSpaceRoundedUpToPageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED,0,(off_t)0);

is executed and in other one no.


Thanks in advance,

Mariano

 

On 2010-11-30, at 5:03 PM, David T. Lewis wrote:

>
> On Wed, Dec 01, 2010 at 12:41:44AM +0100, Mariano Martinez Peck wrote:
>>
>> On Wed, Dec 1, 2010 at 12:11 AM, Mariano Martinez Peck <
>> [hidden email]> wrote:
>>>
>>> On Tue, Nov 30, 2010 at 5:14 PM, David T. Lewis <[hidden email]>wrote:
>>>>
>>>> I'm away and cannot check this right now, but if you look in the
>>>> SqS/VMMaker archive there there are a number of recent updates that
>>>> may address this problem. See the Montecello update comments for
>>>> VMMaker-dtl.188, VMMaker-dtl.199, and VMMaker-dtl.200 for summaries.
>>>> These updates would not be in any of the released VMs at this point,
>>>> but I have a hunch that they will take care of this problem.
>>>>
>>>
>>> Hi Dave. Ok...after a couple of hours I could compile a new VM for MacOS
>>> with VMMaker 205 and integrating all my changes :)
>>> So....this was something I have to do since several months already hehhehe
>>>
>>> Now, as you guessed, something  was related to that. Now, these are the
>>> results:
>>>
>>> normal:
>>>
>>> Smalltalk garbageCollect   481957728
>>> Smalltalk primBytesLeft 5738200
>>>
>>> with -memory 1500m
>>>
>>> Smalltalk garbageCollect    482093452
>>> Smalltalk primBytesLeft 6444200
>>>
>>
>> mmmmmmm  if instead of sending -memory I modify Info.plist  and I set
>> 1572864000  (1500gb)
>> then I get
>>
>> Smalltalk garbageCollect  1518058920
>> Smalltalk primBytesLeft 5898636
>>
>> :)
>>
>> so maybe the mac vm is not taking into acount -memory but it does the file?
>
> Well that's as good a theory as anything I could have made up ;-)
>
> To be serious, the -memory parameter is part of the unix VM, and
> other platforms may do things differently. So yes, I think you
> have found the right explanation.
>
> Dave
>
>

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================