gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: optimization


From: Manuel Guesdon
Subject: Re: optimization
Date: Thu, 16 Dec 2004 15:04:13 +0100 (CET)

About GS_SMALL (NSShortNumber cached numbers), won't it be better to increse it 
to 
something like 128 (it is equal to 16) ?
Memory cost is small and it will save more alloc/dealloc cycle, won't it ?

Manuel

On Thu, 16 Dec 2004 14:05:50 +0100 (CET) Manuel Guesdon <address@hidden> wrote:

 >| Hi,
 >| 
 >| Would it be possible to add public declaration of boolN and boolY in 
 >Additions, with something like this:
 >| #ifdef NO_GNUSTEP
 >| #define NSNumberYes [NSNumber numberWithBool:YES]
 >| #define NSNumberNo [NSNumber numberWithBool:NO]
 >| #else
 >| #define NSNumberYes boolY       //Or another name
 >| #define NSNumberNo boolN       //Or another name
 >| #endif
 >| 
 >| So we won't have to call -numberWIthBool: each time we want a bool number.
 >| 
 >| Is it also possible to declare function wich use IMP for NSNumber 
 >numberWithInt:, 
 >| numberWithFloat:,..
 >| like this:
 >| 
 >| #ifdef NO_GNUSTEP
 >| #define NSNumberWithInt(value) [NSNumber numberWithInt:value]
 >| ...
 >| #else
 >| #define NSNumberWithInt(value) 
 >((*methodIMP)(NSNumberClass,NSNumberWithIntSelector,value))
 >| ...
 >| #endif
 >| 
 >| This probably save a lot of objc_msgSend calls with no (?) drawbacks 
 >(except poseAs: and dirty 
 >| class methods manipulations).
 >| 
 >| 
 >| 
 >| And my favorite one, a little more complex:
 >| "How to store millions NSIntNumber in 0 byte space" :-)
 >| 
 >| Using objects to store int numbers can take a lot of memory (real value 
 >storage+class 
 >| pointer+retain count,...) and cost allocation/deallocation/retain/release 
 >time
 >| 
 >| If we say that upper addressable memory won't be used (physicall memory 
 >will 
 >| be less than addressable memory).
 >| Say we 'reserve' (not allocate) a zone of 1024x1024=intNb starting at 
 >(unsigned char*)intBase 
 >| and stopping at (unsigned char*)intLimit in this zone
 >| 
 >| we could have:
 >| NSNumber -numberWithInt:(int)value like this
 >| {
 >|         if (value>=0 and value<intLimit)
 >|                 return ((unsigned char*)value)+intBase;
 >|         else
 >|         {
 >|                 usual allocation
 >|         }
 >| }
 >| 
 >| and -(int)intValue like that:
 >| {
 >|         if (self>=0 and self<intLimit)
 >|                 return ((unsigned char*)self)-intBase;
 >|         else
 >|         {
 >|                 usual allocation
 >|         }
 >| }
 >| we only have to modify NSNumber class to handle this case and some 
 >| other functions/macros (obj_msgSend,object_get_class,...).
 >| 
 >| cost: 2 tests in some functions
 >| gain: no allocation/deallocation/retain/release and no physical memory 
 >| usage for the choosen int range
 >| drawback(s): some tools can't check this memory and may report 
 >| errors.
 >| 
 >| What do you think ? Am I crazy ? :-)
 >| 
 >| 
 >| Manuel
 >| 
 >| 
 >| 
 >| --
 >| ______________________________________________________________________
 >| Manuel Guesdon - OXYMIUM <address@hidden>
 >| 14 rue Jean-Baptiste Clement  -  93200 Saint-Denis  -  France
 >| Tel: +33 1 4940 0999  -  Fax: +33 1 4940 0998
 >| 
 >| 
 >| 


-- 
Cordialement,

Manuel Guesdon

--
______________________________________________________________________
Manuel Guesdon - OXYMIUM <address@hidden>
14 rue Jean-Baptiste Clement  -  93200 Saint-Denis  -  France
Tel: +33 1 4940 0999  -  Fax: +33 1 4940 0998





reply via email to

[Prev in Thread] Current Thread [Next in Thread]