Commit a902ef88 authored by leszeks's avatar leszeks Committed by Commit bot

[turbofan] Tune the ValueNumberingReducer's growth rate

Changes the ValueNumberingReducer to grow when at 80% capacity, rather
than at 50% capacity. This matches the behaviour of base/hashmap.

Review-Url: https://codereview.chromium.org/2474873003
Cr-Commit-Position: refs/heads/master@{#40734}
parent e637154b
......@@ -69,7 +69,7 @@ Reduction ValueNumberingReducer::Reduce(Node* node) {
}
DCHECK(size_ < capacity_);
DCHECK(size_ * kCapacityToSizeRatio < capacity_);
DCHECK(size_ + size_ / 4 < capacity_);
const size_t mask = capacity_ - 1;
size_t dead = capacity_;
......@@ -85,10 +85,10 @@ Reduction ValueNumberingReducer::Reduce(Node* node) {
entries_[i] = node;
size_++;
// Resize to keep load factor below 1/kCapacityToSizeRatio.
if (size_ * kCapacityToSizeRatio >= capacity_) Grow();
// Resize to keep load factor below 80%
if (size_ + size_ / 4 >= capacity_) Grow();
}
DCHECK(size_ * kCapacityToSizeRatio < capacity_);
DCHECK(size_ + size_ / 4 < capacity_);
return NoChange();
}
......@@ -152,11 +152,10 @@ Reduction ValueNumberingReducer::Reduce(Node* node) {
void ValueNumberingReducer::Grow() {
// Allocate a new block of entries kCapacityToSizeRatio times the previous
// capacity.
// Allocate a new block of entries double the previous capacity.
Node** const old_entries = entries_;
size_t const old_capacity = capacity_;
capacity_ *= kCapacityToSizeRatio;
capacity_ *= 2;
entries_ = temp_zone()->NewArray<Node*>(capacity_);
memset(entries_, 0, sizeof(*entries_) * capacity_);
size_ = 0;
......
......@@ -22,7 +22,7 @@ class V8_EXPORT_PRIVATE ValueNumberingReducer final
Reduction Reduce(Node* node) override;
private:
enum { kInitialCapacity = 256u, kCapacityToSizeRatio = 2u };
enum { kInitialCapacity = 256u };
void Grow();
Zone* temp_zone() const { return temp_zone_; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment