Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/filecache.cfa

    r2ecbd7b r53e4562  
    8282
    8383[int fd, size_t size] get_file( * const char file, size_t len ) {
    84         uint32_t idx = murmur3_32( (const uint8_t *)file, len, options.file_cache.hash_seed ) % file_cache.size;
     84        uint32_t idx = murmur3_32( (const uint8_t *)file, len, options.hash_seed ) % file_cache.size;
    8585
    8686        for(int i = 0;; i++) {
     
    9999
    100100int put_file( cache_line & entry ) {
    101         uint32_t idx = murmur3_32( (const uint8_t *)entry.file, strlen(entry.file), options.file_cache.hash_seed ) % file_cache.size;
     101        uint32_t idx = murmur3_32( (const uint8_t *)entry.file, strlen(entry.file), options.hash_seed ) % file_cache.size;
    102102
    103103        int i = 0;
     
    136136                raw[idx].file = strdup(fpath+2);
    137137                raw[idx].size = sb->st_size;
    138                 if( !options.file_cache.list ) {
    139                         raw[idx].fd = open( fpath, options.file_cache.open_flags );
     138                if( !options.file_cache_list ) {
     139                        raw[idx].fd = open( fpath, options.open_flags );
    140140                        if(raw[idx].fd < 0) {
    141141                                abort( "open file error: (%d) %s\n", (int)errno, strerror(errno) );
     
    154154        }
    155155
    156         // Step 2 create the cache
    157         file_cache.size = options.file_cache.size > 0 ? options.file_cache.size : fsize;
    158         if( file_cache.size < fcount ) {
    159                 abort("File Cache too small\n");
    160         }
    161 
    162         file_cache.entries = anew(file_cache.size);
    163 
    164         // Step 3 fill the cache
    165         int conflicts = 0;
    166         for(i; fcount) {
    167                 conflicts += put_file( raw[i] );
    168         }
    169         printf("Filled cache from path \"%s\" with %zu files\n", path, fcount);
    170         if( conflicts > 0 ) {
    171                 printf("Found %d conflicts (seed: %u)\n", conflicts, options.file_cache.hash_seed);
    172                 #if defined(REJECT_CONFLICTS)
    173                         abort("Conflicts found in the cache");
    174                 #endif
    175         }
    176 
    177         if(options.file_cache.list) {
     156        if(options.file_cache_list) {
    178157                printf("Listing files and exiting\n");
    179158                for(i; fcount) {
     
    184163                }
    185164                free(raw);
    186                 adelete(file_cache.size, file_cache.entries);
    187165                exit(0);
     166        }
     167
     168        // Step 2 create the cache
     169        file_cache.size = options.file_cache_size > 0 ? options.file_cache_size : fsize;
     170        if( file_cache.size < fcount ) {
     171                abort("File Cache too small\n");
     172        }
     173
     174        file_cache.entries = anew(fsize);
     175
     176        // Step 3 fill the cache
     177        int conflicts = 0;
     178        for(i; fcount) {
     179                printf("Added file %s\n", raw[i].file);
     180                conflicts += put_file( raw[i] );
     181        }
     182        printf("Filled cache from path \"%s\" with %zu files\n", path, fcount);
     183        if( conflicts > 0 ) {
     184                printf("Found %d conflicts (seed: %u)\n", conflicts, options.hash_seed);
     185                #if defined(REJECT_CONFLICTS)
     186                        abort("Conflicts found in the cache");
     187                #endif
    188188        }
    189189
Note: See TracChangeset for help on using the changeset viewer.