Changes in benchmark/io/http/filecache.cfa [2ecbd7b:53e4562]
- File:
-
- 1 edited
-
benchmark/io/http/filecache.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/filecache.cfa
r2ecbd7b r53e4562 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. file_cache.hash_seed ) % file_cache.size;84 uint32_t idx = murmur3_32( (const uint8_t *)file, len, options.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. 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; 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. file_cache.open_flags );138 if( !options.file_cache_list ) { 139 raw[idx].fd = open( fpath, options.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 // 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) { 178 157 printf("Listing files and exiting\n"); 179 158 for(i; fcount) { … … 184 163 } 185 164 free(raw); 186 adelete(file_cache.size, file_cache.entries);187 165 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 188 188 } 189 189
Note:
See TracChangeset
for help on using the changeset viewer.