Changeset 2ecbd7b for benchmark/io/http/filecache.cfa
- Timestamp:
- Jul 17, 2020, 5:39:26 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- e95a117
- Parents:
- 0d52c6f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/filecache.cfa
r0d52c6f r2ecbd7b 82 82 83 83 [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; 85 85 86 86 for(int i = 0;; i++) { … … 99 99 100 100 int 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; 102 102 103 103 int i = 0; … … 136 136 raw[idx].file = strdup(fpath+2); 137 137 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 ); 140 140 if(raw[idx].fd < 0) { 141 141 abort( "open file error: (%d) %s\n", (int)errno, strerror(errno) ); … … 154 154 } 155 155 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) { 157 178 printf("Listing files and exiting\n"); 158 179 for(i; fcount) { … … 163 184 } 164 185 free(raw); 186 adelete(file_cache.size, file_cache.entries); 165 187 exit(0); 166 }167 168 // Step 2 create the cache169 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 cache177 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 #endif188 188 } 189 189
Note: See TracChangeset
for help on using the changeset viewer.