pnoltes commented on code in PR #470:
URL: https://github.com/apache/celix/pull/470#discussion_r1390457651


##########
libs/utils/src/celix_hash_map.c:
##########
@@ -339,21 +327,27 @@ static bool celix_hashMap_remove(celix_hash_map_t* map, 
const char* strKey, long
         visit = visit->next;
     }
     if (removedEntry != NULL) {
+        char* removedKey = NULL;
+        if (map->keyType == CELIX_HASH_MAP_STRING_KEY) {
+            removedKey = (char*)removedEntry->key.strKey;
+        }
         celix_hashMap_destroyRemovedEntry(map, removedEntry);
+        if (removedKey) {
+            celix_hashMap_destroyRemovedKey(map, removedKey);
+        }
         return true;
     }
     return false;
 }
 
-static void celix_hashMap_init(
+celix_status_t celix_hashMap_init(
         celix_hash_map_t* map,
         celix_hash_map_key_type_e keyType,
         unsigned int initialCapacity,
         double loadFactor,
         unsigned int (*hashKeyFn)(const celix_hash_map_key_t*),
         bool (*equalsKeyFn)(const celix_hash_map_key_t*, const 
celix_hash_map_key_t*)) {
     map->loadFactor = loadFactor;

Review Comment:
   Here are the load factor benchmark result (on my machine, using a release 
build type and cpupower on performance):
   
   # Hash3 , max load 0.75
   ```
   
-----------------------------------------------------------------------------------------------------------------------------------------
   Benchmark                                                                    
           Time             CPU   Iterations UserCounters...
   
-----------------------------------------------------------------------------------------------------------------------------------------
   LongHashmapBenchmark_findEntryFromStdMap/10/process_time/real_time           
       0.421 ns        0.421 ns   1000000000 items_per_second=2.37362G/s
   LongHashmapBenchmark_findEntryFromStdMap/100/process_time/real_time          
       0.421 ns        0.421 ns   1000000000 items_per_second=2.37341G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000/process_time/real_time         
       0.422 ns        0.422 ns   1000000000 items_per_second=2.36961G/s
   LongHashmapBenchmark_findEntryFromStdMap/10000/process_time/real_time        
       0.421 ns        0.421 ns   1000000000 items_per_second=2.37266G/s
   LongHashmapBenchmark_findEntryFromStdMap/100000/process_time/real_time       
       0.422 ns        0.422 ns   1000000000 items_per_second=2.3715G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000000/process_time/real_time      
       0.422 ns        0.422 ns   1000000000 items_per_second=2.3694G/s
   LongHashmapBenchmark_findEntryFromCelixMap/10/process_time/real_time         
        2.32 ns         2.32 ns    302202596 averageNrOfEntriesPerBucket=0.625 
items_per_second=431.121M/s nrOfBuckets=16 resizeCount=0 
stdDeviationNrOfEntriesPerBucket=0.856957
   LongHashmapBenchmark_findEntryFromCelixMap/100/process_time/real_time        
        2.58 ns         2.58 ns    272789300 
averageNrOfEntriesPerBucket=0.390625 items_per_second=387.522M/s 
nrOfBuckets=256 resizeCount=4 stdDeviationNrOfEntriesPerBucket=0.687322
   LongHashmapBenchmark_findEntryFromCelixMap/1000/process_time/real_time       
        2.37 ns         2.37 ns    295845710 
averageNrOfEntriesPerBucket=0.488281 items_per_second=421.411M/s 
nrOfBuckets=2.048k resizeCount=7 stdDeviationNrOfEntriesPerBucket=0.695872
   LongHashmapBenchmark_findEntryFromCelixMap/10000/process_time/real_time      
        2.39 ns         2.39 ns    294741774 
averageNrOfEntriesPerBucket=0.610352 items_per_second=417.892M/s 
nrOfBuckets=16.384k resizeCount=10 stdDeviationNrOfEntriesPerBucket=0.784076
   LongHashmapBenchmark_findEntryFromCelixMap/100000/process_time/real_time     
        2.40 ns         2.40 ns    297425736 
averageNrOfEntriesPerBucket=0.718061 items_per_second=417.292M/s 
nrOfBuckets=139.264k resizeCount=22 stdDeviationNrOfEntriesPerBucket=0.846435
   LongHashmapBenchmark_findEntryFromCelixMap/1000000/process_time/real_time    
        2.27 ns         2.27 ns    308634832 
averageNrOfEntriesPerBucket=0.747751 items_per_second=440.035M/s 
nrOfBuckets=1.33734M resizeCount=139 stdDeviationNrOfEntriesPerBucket=0.863872
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10/process_time/real_time    
        3.53 ns         3.53 ns    198927031 items_per_second=283.682M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/100/process_time/real_time   
        3.52 ns         3.52 ns    198043432 items_per_second=283.711M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/1000/process_time/real_time  
        3.53 ns         3.53 ns    195734925 items_per_second=283.213M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10000/process_time/real_time 
        3.53 ns         3.53 ns    197803895 items_per_second=283.436M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/100000/process_time/real_time   
     3.52 ns         3.52 ns    198613048 items_per_second=284.045M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/1000000/process_time/real_time  
     3.50 ns         3.50 ns    199963559 items_per_second=285.326M/s
   ```
   
   # Hash3 , max load 3
   ```
   
-----------------------------------------------------------------------------------------------------------------------------------------
   Benchmark                                                                    
           Time             CPU   Iterations UserCounters...
   
-----------------------------------------------------------------------------------------------------------------------------------------
   LongHashmapBenchmark_findEntryFromStdMap/10/process_time/real_time           
       0.425 ns        0.425 ns   1000000000 items_per_second=2.35061G/s
   LongHashmapBenchmark_findEntryFromStdMap/100/process_time/real_time          
       0.426 ns        0.426 ns   1000000000 items_per_second=2.34699G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000/process_time/real_time         
       0.426 ns        0.426 ns   1000000000 items_per_second=2.34825G/s
   LongHashmapBenchmark_findEntryFromStdMap/10000/process_time/real_time        
       0.426 ns        0.426 ns   1000000000 items_per_second=2.34747G/s
   LongHashmapBenchmark_findEntryFromStdMap/100000/process_time/real_time       
       0.426 ns        0.426 ns   1000000000 items_per_second=2.3473G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000000/process_time/real_time      
       0.437 ns        0.437 ns   1000000000 items_per_second=2.28811G/s
   LongHashmapBenchmark_findEntryFromCelixMap/10/process_time/real_time         
        2.34 ns         2.34 ns    299224720 averageNrOfEntriesPerBucket=0.625 
items_per_second=428.114M/s nrOfBuckets=16 resizeCount=0 
stdDeviationNrOfEntriesPerBucket=0.856957
   LongHashmapBenchmark_findEntryFromCelixMap/100/process_time/real_time        
        2.76 ns         2.76 ns    252886933 averageNrOfEntriesPerBucket=1.5625 
items_per_second=362.06M/s nrOfBuckets=64 resizeCount=2 
stdDeviationNrOfEntriesPerBucket=1.26089
   LongHashmapBenchmark_findEntryFromCelixMap/1000/process_time/real_time       
        2.34 ns         2.34 ns    299386105 
averageNrOfEntriesPerBucket=1.95312 items_per_second=428.21M/s nrOfBuckets=512 
resizeCount=5 stdDeviationNrOfEntriesPerBucket=1.47033
   LongHashmapBenchmark_findEntryFromCelixMap/10000/process_time/real_time      
        2.55 ns         2.55 ns    274628326 
averageNrOfEntriesPerBucket=2.44141 items_per_second=392.449M/s 
nrOfBuckets=4.096k resizeCount=8 stdDeviationNrOfEntriesPerBucket=1.56031
   LongHashmapBenchmark_findEntryFromCelixMap/100000/process_time/real_time     
        2.34 ns         2.34 ns    299777246 
averageNrOfEntriesPerBucket=2.71267 items_per_second=428.166M/s 
nrOfBuckets=36.864k resizeCount=12 stdDeviationNrOfEntriesPerBucket=1.64409
   LongHashmapBenchmark_findEntryFromCelixMap/1000000/process_time/real_time    
        2.33 ns         2.33 ns    299923251 
averageNrOfEntriesPerBucket=2.99559 items_per_second=428.295M/s 
nrOfBuckets=333.824k resizeCount=41 stdDeviationNrOfEntriesPerBucket=1.73026
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10/process_time/real_time    
        3.63 ns         3.63 ns    192852998 items_per_second=275.666M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/100/process_time/real_time   
        3.63 ns         3.63 ns    192824656 items_per_second=275.619M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/1000/process_time/real_time  
        3.63 ns         3.63 ns    192825416 items_per_second=275.698M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10000/process_time/real_time 
        3.63 ns         3.63 ns    192885922 items_per_second=275.674M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/100000/process_time/real_time   
     3.63 ns         3.63 ns    193014477 items_per_second=275.727M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/1000000/process_time/real_time  
     3.66 ns         3.66 ns    191065573 items_per_second=272.882M/s
   ```
   
   # Hash3, max load 5
   ```
   
-----------------------------------------------------------------------------------------------------------------------------------------
   Benchmark                                                                    
           Time             CPU   Iterations UserCounters...
   
-----------------------------------------------------------------------------------------------------------------------------------------
   LongHashmapBenchmark_findEntryFromStdMap/10/process_time/real_time           
       0.414 ns        0.414 ns   1000000000 items_per_second=2.4128G/s
   LongHashmapBenchmark_findEntryFromStdMap/100/process_time/real_time          
       0.414 ns        0.414 ns   1000000000 items_per_second=2.41719G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000/process_time/real_time         
       0.414 ns        0.414 ns   1000000000 items_per_second=2.41582G/s
   LongHashmapBenchmark_findEntryFromStdMap/10000/process_time/real_time        
       0.414 ns        0.414 ns   1000000000 items_per_second=2.41681G/s
   LongHashmapBenchmark_findEntryFromStdMap/100000/process_time/real_time       
       0.414 ns        0.414 ns   1000000000 items_per_second=2.41521G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000000/process_time/real_time      
       0.414 ns        0.414 ns   1000000000 items_per_second=2.41732G/s
   LongHashmapBenchmark_findEntryFromCelixMap/10/process_time/real_time         
        2.26 ns         2.26 ns    307909253 averageNrOfEntriesPerBucket=0.625 
items_per_second=441.585M/s nrOfBuckets=16 resizeCount=0 
stdDeviationNrOfEntriesPerBucket=0.856957
   LongHashmapBenchmark_findEntryFromCelixMap/100/process_time/real_time        
        3.39 ns         3.39 ns    211113789 averageNrOfEntriesPerBucket=3.125 
items_per_second=295.319M/s nrOfBuckets=32 resizeCount=1 
stdDeviationNrOfEntriesPerBucket=1.86665
   LongHashmapBenchmark_findEntryFromCelixMap/1000/process_time/real_time       
        2.48 ns         2.48 ns    281288298 
averageNrOfEntriesPerBucket=3.90625 items_per_second=403.557M/s nrOfBuckets=256 
resizeCount=4 stdDeviationNrOfEntriesPerBucket=2.16123
   LongHashmapBenchmark_findEntryFromCelixMap/10000/process_time/real_time      
        3.31 ns         3.31 ns    211375732 
averageNrOfEntriesPerBucket=4.88281 items_per_second=302.161M/s 
nrOfBuckets=2.048k resizeCount=7 stdDeviationNrOfEntriesPerBucket=2.2035
   LongHashmapBenchmark_findEntryFromCelixMap/100000/process_time/real_time     
        2.48 ns         2.48 ns    282405576 
averageNrOfEntriesPerBucket=3.75601 items_per_second=403.207M/s 
nrOfBuckets=26.624k resizeCount=11 stdDeviationNrOfEntriesPerBucket=1.92598
   LongHashmapBenchmark_findEntryFromCelixMap/1000000/process_time/real_time    
        2.90 ns         2.90 ns    241719478 
averageNrOfEntriesPerBucket=4.98246 items_per_second=344.381M/s 
nrOfBuckets=200.704k resizeCount=28 stdDeviationNrOfEntriesPerBucket=2.23011
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10/process_time/real_time    
        3.54 ns         3.54 ns    197602959 items_per_second=282.865M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/100/process_time/real_time   
        3.54 ns         3.53 ns    197704646 items_per_second=282.885M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/1000/process_time/real_time  
        3.53 ns         3.53 ns    197684458 items_per_second=282.891M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10000/process_time/real_time 
        3.54 ns         3.54 ns    197731536 items_per_second=282.88M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/100000/process_time/real_time   
     3.54 ns         3.54 ns    197896830 items_per_second=282.817M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/1000000/process_time/real_time  
     3.54 ns         3.54 ns    198110019 items_per_second=282.856M/s
   ```
   
   # Hash3, max load 10
   ```
   
-----------------------------------------------------------------------------------------------------------------------------------------
   Benchmark                                                                    
           Time             CPU   Iterations UserCounters...
   
-----------------------------------------------------------------------------------------------------------------------------------------
   LongHashmapBenchmark_findEntryFromStdMap/10/process_time/real_time           
       0.435 ns        0.435 ns   1000000000 items_per_second=2.29977G/s
   LongHashmapBenchmark_findEntryFromStdMap/100/process_time/real_time          
       0.432 ns        0.432 ns   1000000000 items_per_second=2.31494G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000/process_time/real_time         
       0.426 ns        0.426 ns   1000000000 items_per_second=2.34589G/s
   LongHashmapBenchmark_findEntryFromStdMap/10000/process_time/real_time        
       0.426 ns        0.426 ns   1000000000 items_per_second=2.34525G/s
   LongHashmapBenchmark_findEntryFromStdMap/100000/process_time/real_time       
       0.426 ns        0.426 ns   1000000000 items_per_second=2.34972G/s
   LongHashmapBenchmark_findEntryFromStdMap/1000000/process_time/real_time      
       0.425 ns        0.425 ns   1000000000 items_per_second=2.35186G/s
   LongHashmapBenchmark_findEntryFromCelixMap/10/process_time/real_time         
        2.33 ns         2.33 ns    299579738 averageNrOfEntriesPerBucket=0.625 
items_per_second=428.363M/s nrOfBuckets=16 resizeCount=0 
stdDeviationNrOfEntriesPerBucket=0.856957
   LongHashmapBenchmark_findEntryFromCelixMap/100/process_time/real_time        
        2.57 ns         2.57 ns    274525405 averageNrOfEntriesPerBucket=6.25 
items_per_second=388.373M/s nrOfBuckets=16 resizeCount=0 
stdDeviationNrOfEntriesPerBucket=2.53722
   LongHashmapBenchmark_findEntryFromCelixMap/1000/process_time/real_time       
        3.03 ns         3.03 ns    219679035 averageNrOfEntriesPerBucket=7.8125 
items_per_second=329.912M/s nrOfBuckets=128 resizeCount=3 
stdDeviationNrOfEntriesPerBucket=3.12687
   LongHashmapBenchmark_findEntryFromCelixMap/10000/process_time/real_time      
        8.02 ns         8.02 ns     81140813 
averageNrOfEntriesPerBucket=9.76562 items_per_second=124.642M/s 
nrOfBuckets=1024 resizeCount=6 stdDeviationNrOfEntriesPerBucket=3.15172
   LongHashmapBenchmark_findEntryFromCelixMap/100000/process_time/real_time     
        2.55 ns         2.55 ns    274930765 
averageNrOfEntriesPerBucket=6.10352 items_per_second=392.633M/s 
nrOfBuckets=16.384k resizeCount=10 stdDeviationNrOfEntriesPerBucket=2.46868
   LongHashmapBenchmark_findEntryFromCelixMap/1000000/process_time/real_time    
        3.18 ns         3.18 ns    220016340 
averageNrOfEntriesPerBucket=9.21285 items_per_second=313.99M/s 
nrOfBuckets=108.544k resizeCount=19 stdDeviationNrOfEntriesPerBucket=3.02688
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10/process_time/real_time    
        3.62 ns         3.62 ns    193278219 items_per_second=276.196M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/100/process_time/real_time   
        3.62 ns         3.62 ns    193216614 items_per_second=276.198M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/1000/process_time/real_time  
        3.62 ns         3.62 ns    193269813 items_per_second=276.076M/s
   LongHashmapBenchmark_findEntryFromDeprecatedMap/10000/process_time/real_time 
        3.62 ns         3.62 ns    193179709 items_per_second=276.217M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/100000/process_time/real_time   
     3.62 ns         3.62 ns    193208642 items_per_second=276.177M/s
   
LongHashmapBenchmark_findEntryFromDeprecatedMap/1000000/process_time/real_time  
     3.62 ns         3.62 ns    193566533 items_per_second=276.364M/s
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to