9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] thread STACK size
Date: Wed, 19 May 2010 09:56:15 -0400	[thread overview]
Message-ID: <45a0bc53c25d3f197697043a26824244@kw.quanstro.net> (raw)
In-Reply-To: <8a7d369bb212b77cb4ca5c8b1408a267@plan9.bell-labs.com>

> As a general rule in threaded programs, avoid declaring local arrays
> or large structs.  Instead, malloc them and free them when you're done.
> A file server, as an example, should never allocate an 8K message
> buffer on the stack.  If you can manage to obey the rule of not having
> arrays on the stack (as local variables), you can usually comfortably
> make use of 4K or 8K stacks.

i've always followed this rule myself.  but it just occurs to me that
there might be another way of looking at this.

if our mythical program needs a fixed-size message buffer for every
request, there are advantages to the stack.  dynamic allocation
with the pool library is slow and single-threaded.  and of course,
any dynamic allocation is more work and can be fatal.

- erik



      parent reply	other threads:[~2010-05-19 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19  9:04 Mathieu Lonjaret
2010-05-19  9:20 ` Sape Mullender
2010-05-19  9:55   ` Federico G. Benavento
2010-05-19 10:51     ` Francisco J Ballesteros
2010-05-19 13:56   ` erik quanstrom [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45a0bc53c25d3f197697043a26824244@kw.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).