Ignore:
Timestamp:
Jul 20, 2020, 3:52:38 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
124c1b7, 92850ef
Parents:
ffa48a8 (diff), 3f1d9b5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    rffa48a8 r7d94bfe3  
    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.hash_seed ) % file_cache.size;
     84        uint32_t idx = murmur3_32( (const uint8_t *)file, len, options.file_cache.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.hash_seed ) % file_cache.size;
     101        uint32_t idx = murmur3_32( (const uint8_t *)entry.file, strlen(entry.file), options.file_cache.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.open_flags );
     138                if( !options.file_cache.list ) {
     139                        raw[idx].fd = open( fpath, options.file_cache.open_flags );
    140140                        if(raw[idx].fd < 0) {
    141141                                abort( "open file error: (%d) %s\n", (int)errno, strerror(errno) );
     
    154154        }
    155155
    156         if(options.file_cache_list) {
     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) {
    157178                printf("Listing files and exiting\n");
    158179                for(i; fcount) {
     
    163184                }
    164185                free(raw);
     186                adelete(file_cache.size, file_cache.entries);
    165187                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.