httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sadaf Alvi" <sa...@uffaq.com>
Subject [request for comments ] performance issue : calloc & free vs creating subpool for cache memory management???
Date Tue, 13 Jul 2004 11:55:21 GMT
thanx!
i wanna write a cache library and come up with 2 different techniques to allocate cache memory
1) use calloc & free for each node 
2) create a subpool in pconf for each node 
i did some experiment with both. 

#define LOOP_SIZE 10000
#define MEM_SIZE 400


long iCounter;
 char *ptr = NULL;
 apr_pool_t *sub_pool = NULL;
 clock_t t1,t2; 
                
 for(iCounter=0; iCounter < LOOP_SIZE; iCounter++ ) {
     apr_pool_create(&sub_pool,conf->pool);
     ptr = apr_pcalloc(sub_pool,MEM_SIZE);
     apr_pool_destroy(sub_pool);
 }
 //end time: subpool

 t2=clock();
 ap_log_error(APLOG_MARK, APLOG_ERR, 0, 0,"SUB_POOL :  %.4lf seconds of processing\n", (t2-t1)/(double)CLOCKS_PER_SEC);


 //start time: calloc
 t1=clock();
        
 for(iCounter=0; iCounter < LOOP_SIZE; iCounter++ ) {
     ptr = (char *) calloc( sizeof(char),  MEM_SIZE);
     if(ptr)
        free((void*) ptr);
 }
 
 //end time: calloc
 t2=clock();
 ap_log_error(APLOG_MARK, APLOG_ERR, 0, 0,"CALLOC : %.4lf seconds of processing\n", (t2-t1)/(double)CLOCKS_PER_SEC);

tried above code with 
LOOP_SIZE = 10000, MEM_SIZE = 400 

found in error_log  
SUB_POOL : 0.0200 seconds of processing
CALLOC : 0.0200 seconds of processing
                
tried above code with
LOOP_SIZE = 60000, MEM_SIZE = 200

found in error_log  
SUB_POOL : 0.1300 seconds of processing
CALLOC : 0.0700 seconds of processing
Mime
View raw message