6969
7070namespace
7171{
72+ DbgCtl dbg_ctl_cache_ram{" cache_ram" };
7273DbgCtl dbg_ctl_cache_bc{" cache_bc" };
7374DbgCtl dbg_ctl_cache_disk_error{" cache_disk_error" };
7475DbgCtl dbg_ctl_cache_read{" cache_read" };
@@ -449,27 +450,56 @@ CacheVC::handleReadDone(int event, Event * /* e ATS_UNUSED */)
449450
450451int
451452CacheVC::handleRead (int /* event ATS_UNUSED */ , Event * /* e ATS_UNUSED */ )
452-
453453{
454454 cancel_trigger ();
455455
456456 f.doc_from_ram_cache = false ;
457457
458458 ink_assert (stripe->mutex ->thread_holding == this_ethread ());
459+
460+ // 1. check RAM cache
459461 if (load_from_ram_cache ()) {
460- goto LramHit;
461- } else if (load_from_last_open_read_call ()) {
462- goto LmemHit;
463- } else if (load_from_aggregation_buffer ()) {
462+ Dbg (dbg_ctl_cache_ram, " RAM cache hit" );
463+ f.doc_from_ram_cache = true ;
464+ io.aio_result = io.aiocb .aio_nbytes ;
465+
466+ Doc *doc = reinterpret_cast <Doc *>(buf->data ());
467+ if (cache_config_ram_cache_compress && doc->doc_type == CACHE_FRAG_TYPE_HTTP && doc->hlen ) {
468+ SET_HANDLER (&CacheVC::handleReadDone);
469+ return EVENT_RETURN;
470+ }
471+
472+ POP_HANDLER;
473+ return EVENT_RETURN;
474+ }
475+
476+ // 2. check last open read cache
477+ if (load_from_last_open_read_call ()) {
478+ Dbg (dbg_ctl_cache_ram, " last open read hit" );
479+ f.doc_from_ram_cache = true ;
480+ io.aio_result = io.aiocb .aio_nbytes ;
481+
482+ POP_HANDLER;
483+ return EVENT_RETURN;
484+ }
485+
486+ // 3. check aggregation buffer
487+ if (load_from_aggregation_buffer ()) {
488+ Dbg (dbg_ctl_cache_ram, " aggregation buffer hit" );
464489 f.doc_from_ram_cache = true ;
465490 io.aio_result = io.aiocb .aio_nbytes ;
491+
466492 SET_HANDLER (&CacheVC::handleReadDone);
467493 return EVENT_RETURN;
468494 }
469495
496+ // 4. read from Disk (AIO) due to all memory cache miss
497+ Dbg (dbg_ctl_cache_ram, " all memory cache miss" );
498+
470499 ts::Metrics::Counter::increment (cache_rsb.all_mem_misses );
471500 ts::Metrics::Counter::increment (stripe->cache_vol ->vol_rsb .all_mem_misses );
472501
502+ // enqueue AIO read
473503 io.aiocb .aio_fildes = stripe->fd ;
474504 io.aiocb .aio_offset = stripe->vol_offset (&dir);
475505 if (static_cast <off_t >(io.aiocb .aio_offset + io.aiocb .aio_nbytes ) > static_cast <off_t >(stripe->skip + stripe->len )) {
@@ -480,30 +510,14 @@ CacheVC::handleRead(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
480510 io.action = this ;
481511 io.thread = mutex->thread_holding ->tt == DEDICATED ? AIO_CALLBACK_THREAD_ANY : mutex->thread_holding ;
482512 SET_HANDLER (&CacheVC::handleReadDone);
483- ink_assert (ink_aio_read (&io) >= 0 );
484513
485- // ToDo: Why are these for debug only ??
486- #if DEBUG
514+ int res = ink_aio_read (&io);
515+ ink_assert (res >= 0 );
516+
487517 ts::Metrics::Counter::increment (cache_rsb.pread_count );
488518 ts::Metrics::Counter::increment (stripe->cache_vol ->vol_rsb .pread_count );
489- #endif
490519
491520 return EVENT_CONT;
492-
493- LramHit: {
494- f.doc_from_ram_cache = true ;
495- io.aio_result = io.aiocb .aio_nbytes ;
496- Doc *doc = reinterpret_cast <Doc *>(buf->data ());
497- if (cache_config_ram_cache_compress && doc->doc_type == CACHE_FRAG_TYPE_HTTP && doc->hlen ) {
498- SET_HANDLER (&CacheVC::handleReadDone);
499- return EVENT_RETURN;
500- }
501- }
502- LmemHit:
503- f.doc_from_ram_cache = true ;
504- io.aio_result = io.aiocb .aio_nbytes ;
505- POP_HANDLER;
506- return EVENT_RETURN; // allow the caller to release the volume lock
507521}
508522
509523bool
0 commit comments