jplevyak commented on code in PR #13893:
URL: https://github.com/apache/trafficserver/pull/13893#discussion_r4366037348
##########
src/iocore/cache/RamCacheCLFUS.cc:
##########
@@ -943,7 +977,7 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data,
uint32_t len, bool copy,
e = THREAD_ALLOC(ramCacheCLFUSEntryAllocator, this_ethread());
e->key = *key;
e->auxkey = auxkey;
- e->hits = 1;
+ e->hits = 2;
e->size = data->block_size();
e->flags = 0;
this->_bucket[i].push(e);
Review Comment:
The hits = 2 line only runs for history entries; it isn't shared with
resident entries:
- Lhistory: (RamCacheCLFUS.cc ~lineĀ 991). This is the only place set to
hits = 2. It always creates a history entry: it sets flag_bits.lru = 1, queues
the entry on _lru[1] and increments _history.
- Linsert: (~lineĀ 959). New resident entries are created here, and they
still start at hits = 1. The PR doesn't change this line.
Copilot does have half a point. A history entry that is later admitted
keeps its hits count. So an object that went through history becomes resident
with a higher count than one admitted directly. That is deliberate: it was
requested again while in history, so it has earned the extra weight. The hits =
2 start also gives it more than one _tick() before it ages out of history. That
retention is what the PR description means by "a multi-tick chance".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]