caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Stack size on OS X
@ 2009-11-30 15:26 Christophe Raffalli
  2009-11-30 16:07 ` [Caml-list] " John Whitington
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe Raffalli @ 2009-11-30 15:26 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]


Hello,

It seems that the problem of stack size is still not solved in OS X (limited to 8Mo by default and
hard limit in the kernel to 64Mo with ulimit -s 64000). My unison is still crashing on
very big changes ...

However, I stumbled on this pdf

http://www.google.fr/url?sa=t&source=web&ct=res&cd=1&ved=0CAcQFjAA&url=http%3A%2F%2Fhomepage.mac.com%2Feric.c%2Fhpc%2Fcontents%2Fdocumentation%2FHow%2520to%2520increase%2520the%2520stack%2520size%2520on%2520Mac%2520OS%2520X.pdf&ei=v-MTS4aMG4Wj_AbFmok2&usg=AFQjCNH1qCjydtM1doAdtwtTJxaEAmwLSw&sig2=u9faAiBSuB7v-VzvHDPHRA)

(This is the first hit on google with "increasing stack size on OS X")

which explain how to use -stack-addr and -stack-size in the gnu linker to change the stack address
and size.

Did anyone try this on OS X for OCaml program ?

I think stack limitation, for a functional program is not good and it is even worse when the limit
depends upon the platform.

Cheers,
Christophe

-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Stack size on OS X
  2009-11-30 15:26 Stack size on OS X Christophe Raffalli
@ 2009-11-30 16:07 ` John Whitington
  2009-11-30 21:52   ` Christophe Raffalli
  0 siblings, 1 reply; 5+ messages in thread
From: John Whitington @ 2009-11-30 16:07 UTC (permalink / raw)
  To: Christophe Raffalli; +Cc: caml-list

Christophe,

On 30 Nov 2009, at 15:26, Christophe Raffalli wrote:
> It seems that the problem of stack size is still not solved in OS X (limited to 8Mo by default and
> hard limit in the kernel to 64Mo with ulimit -s 64000). My unison is still crashing on
> very big changes ...
> 
> However, I stumbled on this pdf
> 
> http://www.google.fr/url?sa=t&source=web&ct=res&cd=1&ved=0CAcQFjAA&url=http%3A%2F%2Fhomepage.mac.com%2Feric.c%2Fhpc%2Fcontents%2Fdocumentation%2FHow%2520to%2520increase%2520the%2520stack%2520size%2520on%2520Mac%2520OS%2520X.pdf&ei=v-MTS4aMG4Wj_AbFmok2&usg=AFQjCNH1qCjydtM1doAdtwtTJxaEAmwLSw&sig2=u9faAiBSuB7v-VzvHDPHRA)
> 
> (This is the first hit on google with "increasing stack size on OS X")
> 
> which explain how to use -stack-addr and -stack-size in the gnu linker to change the stack address
> and size.
> 
> Did anyone try this on OS X for OCaml program ?
> 
> I think stack limitation, for a functional program is not good and it is even worse when the limit
> depends upon the platform.

You may find that a small number of changes to the source code can prevent excess stack usage - it may not be riddled through the whole program. On an Intel macintosh, you can get the list of exceptions leading to the stack overflow from OCaml, and work through them to find the source of the problem.

On first compiling my codebase (about 100,000 lines) on a machine with limited stack size, it took only about a day to fix up.

I agree that, morally, stack space available and general memory available should be roughly equivalent concepts (like with Linux), but sometimes it's easier to give in - after all, how are you to estimate the size you actually need accurately?

Cheers,

-- 
John Whitington
Director, Coherent Graphics Ltd
http://www.coherentpdf.com/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Stack size on OS X
  2009-11-30 16:07 ` [Caml-list] " John Whitington
@ 2009-11-30 21:52   ` Christophe Raffalli
  2009-11-30 22:21     ` John Whitington
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe Raffalli @ 2009-11-30 21:52 UTC (permalink / raw)
  To: John Whitington; +Cc: OCaml

[-- Attachment #1: Type: text/plain, Size: 2233 bytes --]

John Whitington a écrit :
> Christophe,
>
> On 30 Nov 2009, at 15:26, Christophe Raffalli wrote:
>   
>> It seems that the problem of stack size is still not solved in OS X (limited to 8Mo by default and
>> hard limit in the kernel to 64Mo with ulimit -s 64000). My unison is still crashing on
>> very big changes ...
>>
>> However, I stumbled on this pdf
>>
>> http://www.google.fr/url?sa=t&source=web&ct=res&cd=1&ved=0CAcQFjAA&url=http%3A%2F%2Fhomepage.mac.com%2Feric.c%2Fhpc%2Fcontents%2Fdocumentation%2FHow%2520to%2520increase%2520the%2520stack%2520size%2520on%2520Mac%2520OS%2520X.pdf&ei=v-MTS4aMG4Wj_AbFmok2&usg=AFQjCNH1qCjydtM1doAdtwtTJxaEAmwLSw&sig2=u9faAiBSuB7v-VzvHDPHRA)
>>
>> (This is the first hit on google with "increasing stack size on OS X")
>>
>> which explain how to use -stack-addr and -stack-size in the gnu linker to change the stack address
>> and size.
>>
>> Did anyone try this on OS X for OCaml program ?
>>
>> I think stack limitation, for a functional program is not good and it is even worse when the limit
>> depends upon the platform.
>>     
>
> You may find that a small number of changes to the source code can prevent excess stack usage - it may not be riddled through the whole program. On an Intel macintosh, you can get the list of exceptions leading to the stack overflow from OCaml, and work through them to find the source of the problem.
>
>   
Yes, you can always use heap instead of stack, but stack allocation and
deallocation is faster (but sometimes hard to tell
how mush stack space a call cost, and some call can keep useless
pointers accessible if you are not carefull,
although quite rare in OCaml).
> On first compiling my codebase (about 100,000 lines) on a machine with limited stack size, it took only about a day to fix up.
>
> I agree that, morally, stack space available and general memory available should be roughly equivalent concepts (like with Linux), but sometimes it's easier to give in - after all, how are you to estimate the size you actually need accurately?
>   
I do not understand what you mean ? stack size + heap size = maximum of
available memory as in linux is the best ?

Cheers,
Christophe
> Cheers,
>
>   



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Stack size on OS X
  2009-11-30 21:52   ` Christophe Raffalli
@ 2009-11-30 22:21     ` John Whitington
  0 siblings, 0 replies; 5+ messages in thread
From: John Whitington @ 2009-11-30 22:21 UTC (permalink / raw)
  To: Christophe Raffalli; +Cc: OCaml

Hi Christophe,

On 30 Nov 2009, at 21:52, Christophe Raffalli wrote:
 not carefull,
> although quite rare in OCaml).
>> On first compiling my codebase (about 100,000 lines) on a machine with limited stack size, it took only about a day to fix up.
>> 
>> I agree that, morally, stack space available and general memory available should be roughly equivalent concepts (like with Linux), but sometimes it's easier to give in - after all, how are you to estimate the size you actually need accurately?
>> 
> I do not understand what you mean ? stack size + heap size = maximum of
> available memory as in linux is the best ?

In the sense that, since Linux expands the stack as needed, one needn't worry about a program which uses x Mb of stack being any more likely to 'crash' than one which uses x Mb of heap.

So, the total usage of a program (stack + heap) is the only metric needed. Unless (as you say) performance is to be considered.

Cheers,

-- 
John Whitington
Director, Coherent Graphics Ltd
http://www.coherentpdf.com/


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Stack size on OS X
@ 2009-11-30  8:05 Christophe Raffalli
  0 siblings, 0 replies; 5+ messages in thread
From: Christophe Raffalli @ 2009-11-30  8:05 UTC (permalink / raw)
  To: caml-list


[-- Attachment #1.1: Type: text/plain, Size: 1098 bytes --]


Hello,

It seems that the problem of stack size is still not solved in OS X (limited to 8Mo by default and
hard limit in the kernel to 64Mo with ulimit -s 64000). My unison is still crashing on
very big changes ...

However, I stumbled on this pdf (attached) which explain how to use
-stack-addr and -stack-size in the gnu linker to change the stack address and size.

Did anyone try this on OS X for OCaml program ?

I think stack limitation, for a functional program is not good and it is even worse when the limit
depends upon the platform.

Cheers,
Christophe

-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------

[-- Attachment #1.2: How to increase the stack size on Mac OS X.pdf --]
[-- Type: application/pdf, Size: 109566 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-30 22:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-30 15:26 Stack size on OS X Christophe Raffalli
2009-11-30 16:07 ` [Caml-list] " John Whitington
2009-11-30 21:52   ` Christophe Raffalli
2009-11-30 22:21     ` John Whitington
  -- strict thread matches above, loose matches on Subject: below --
2009-11-30  8:05 Christophe Raffalli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).