Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
Semi-tested change to improve I/O patterns with lots of null blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Phipps committed Dec 12, 2009
1 parent ececa0c commit cef50d5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions c/librcksum/hash.c
Expand Up @@ -83,9 +83,15 @@ int build_hash(struct rcksum_state *z) {
return 0;
}

/* Now fill in the hash tables */
for (id = 0; id < z->blocks; id++) {
struct hash_entry *e = z->blockhashes + id;
/* Now fill in the hash tables.
* Minor point: We do this in reverse order, because we're adding entries
* to the hash chains by prepending, so if we iterate over the data in
* reverse then the resulting hash chains have the blocks in normal order.
* That's improves our pattern of I/O when writing out identical blocks
* once we are processing data; we will write them in order. */
for (id = z->blocks; id > 0;) {
/* Decrement the loop variable here, and get the hash entry. */
struct hash_entry *e = z->blockhashes + (--id);

/* Prepend to linked list for this hash entry */
unsigned h = calc_rhash(z, e);
Expand All @@ -98,7 +104,7 @@ int build_hash(struct rcksum_state *z) {
return 1;
}

/* unlink_block(self, block_id)
/* remove_block_from_hash(self, block_id)
* Remove the given data block from the rsum hash table, so it won't be
* returned in a hash lookup again (e.g. because we now have the data)
*/
Expand All @@ -119,6 +125,5 @@ void remove_block_from_hash(struct rcksum_state *z, zs_blockid id) {
p = &((*p)->next);
}
}
fprintf(stderr, "failed to remove block %u from hash\n", id);
}

0 comments on commit cef50d5

Please sign in to comment.