| 1508 | } |
| 1509 | |
| 1510 | void DataCache::Partition::Trace( |
| 1511 | const trace::EventType& type, const DataCache::CacheKey& key, |
| 1512 | int64_t lookup_len, int64_t entry_len) { |
| 1513 | if (tracer_ == nullptr) return; |
| 1514 | |
| 1515 | // When tracing a percentage of the requests, we want to trace all the accesses for a |
| 1516 | // consistent subset of the entries rather than a subset of accesses for all entries. |
| 1517 | // This gives the access trace more useful data. |
| 1518 | // |
| 1519 | // This uses the hash to determine a consistent subset to trace. Note that this is |
| 1520 | // tracing at the partition level. If there are multiple partitions, the entry has |
| 1521 | // been mapped to a specific partition by taking a modulus of the hash value. This |
| 1522 | // can impact which bits are still useful. For example, if there are two partitions, |
| 1523 | // this would have only even hash values or only odd hash values. To minimize the |
| 1524 | // impact of this, we use 101 rather than 100, because 101 is prime. |
| 1525 | uint64_t unsigned_key_hash = static_cast<uint64_t>(key.Hash()); |
| 1526 | if (FLAGS_data_cache_trace_percentage < 100 && |
| 1527 | unsigned_key_hash % 101 >= FLAGS_data_cache_trace_percentage) { |
| 1528 | return; |
| 1529 | } |
| 1530 | |
| 1531 | tracer_->Trace(type, WallTime_Now(), key.filename(), key.mtime(), key.offset(), |
| 1532 | lookup_len, entry_len); |
| 1533 | } |
| 1534 | |
| 1535 | } // namespace io |
| 1536 | } // namespace impala |