Skip to content

Commit

Permalink
Stop using std::hash for sharding (#99)
Browse files Browse the repository at this point in the history
To make sure different configurations make sharding in the same way
stop using std::hash.
  • Loading branch information
matthewtff authored and abyss7 committed Mar 15, 2017
1 parent e6c3039 commit e33c476
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/daemon/emitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ void Emitter::DoCheckCache(const base::WorkerPool& pool) {

STAT(SIMPLE_CACHE_MISS);

auto hash = GenerateHash(incoming->flags(), source, extra_files);
DCHECK(!conf->emitter().has_total_shards() ||
conf->emitter().total_shards() > 0);
ui32 shard = conf->emitter().has_total_shards()
? std::hash<Immutable>{}(hash.str.Hash(4)) %
conf->emitter().total_shards()
: Queue::DEFAULT_SHARD;
ui32 shard = Queue::DEFAULT_SHARD;
if (conf->emitter().has_total_shards()) {
DCHECK(conf->emitter().total_shards() > 0);
auto hash = GenerateHash(incoming->flags(), source, extra_files);
shard = (*reinterpret_cast<const ui32*>(hash.str.Hash(4).c_str())) %
conf->emitter().total_shards();
}
all_tasks_->Push(std::move(*task), shard);
}
}
Expand Down

0 comments on commit e33c476

Please sign in to comment.