LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Shink your code and execution speeds.

[ILUG] Shink your code and execution speeds.

Mel mel at csn.ul.ie
Thu Sep 7 10:37:47 IST 2000


On Thu, 7 Sep 2000, Caolan McNamara wrote:

> You know if linux is always going to overcommit memory so that the
> malloc family never returns NULL then maybe gcc should have an
> optimization option to prune execution branches that rely on their
> failure.
> 

be kinda a hard thing to pick up with a translation schema of any sort
because people check NULL values in different ways. Not impossible, I can
see how it might be done, it would just look weird

> I know of course that you'd be mad to use the option, especially to
> create binaries to give to others who might have overcommittment
> turned off now or in the future, but it would be amusing to see what
> sort of a difference it makes size/speed wise (not a lot Id guess,
> but could be fun)
> 
> Possibly already supported in some form or other ?
> 


hmmm. Macros I would imagine. Something less ugly (too early to think of
something nice) than this off the top of my head

#ifdef MALLOC_NONULLCHECK
#define MALLOC(TYPE, VAR, SIZE) VAR = (TYPE)malloc(sizeof(TYPE) * SIZE);
#else
#define MALLOC(TYPE, VAR, SIZE) if (VAR = (TYPE)malloc((sizeof(TYPE) * SIZE) == NULL) { exit(-1); }
#endif

Write a test program and compile it with MALLOC_NONULLCHECK defined and
then undefined, lamp through time a couple of times and see if there is
any increase.

	Mel






More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell