@@ -162,6 +162,9 @@ Status FilePrefetchBuffer::Prefetch(const IOOptions& opts,
162
162
163
163
Status s = Read (opts, reader, rate_limiter_priority, read_len, chunk_len,
164
164
rounddown_offset, curr_);
165
+ if (s.ok () && usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
166
+ RecordInHistogram (stats_, TABLE_OPEN_PREFETCH_TAIL_READ_BYTES, read_len);
167
+ }
165
168
return s;
166
169
}
167
170
@@ -612,7 +615,13 @@ bool FilePrefetchBuffer::TryReadFromCache(const IOOptions& opts,
612
615
if (track_min_offset_ && offset < min_offset_read_) {
613
616
min_offset_read_ = static_cast <size_t >(offset);
614
617
}
615
- if (!enable_ || (offset < bufs_[curr_].offset_ )) {
618
+ if (!enable_) {
619
+ return false ;
620
+ }
621
+ if (offset < bufs_[curr_].offset_ ) {
622
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
623
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
624
+ }
616
625
return false ;
617
626
}
618
627
@@ -635,6 +644,9 @@ bool FilePrefetchBuffer::TryReadFromCache(const IOOptions& opts,
635
644
if (!IsEligibleForPrefetch (offset, n)) {
636
645
// Ignore status as Prefetch is not called.
637
646
s.PermitUncheckedError ();
647
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
648
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
649
+ }
638
650
return false ;
639
651
}
640
652
}
@@ -648,17 +660,26 @@ bool FilePrefetchBuffer::TryReadFromCache(const IOOptions& opts,
648
660
#ifndef NDEBUG
649
661
IGNORE_STATUS_IF_ERROR (s);
650
662
#endif
663
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
664
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
665
+ }
651
666
return false ;
652
667
}
653
668
readahead_size_ = std::min (max_readahead_size_, readahead_size_ * 2 );
654
669
} else {
670
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
671
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
672
+ }
655
673
return false ;
656
674
}
657
675
}
658
676
UpdateReadPattern (offset, n, false /* decrease_readaheadsize*/ );
659
677
660
678
uint64_t offset_in_buffer = offset - bufs_[curr_].offset_ ;
661
679
*result = Slice (bufs_[curr_].buffer_ .BufferStart () + offset_in_buffer, n);
680
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
681
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_HIT);
682
+ }
662
683
return true ;
663
684
}
664
685
@@ -684,11 +705,17 @@ bool FilePrefetchBuffer::TryReadFromCacheAsync(
684
705
bufs_[curr_].buffer_ .Clear ();
685
706
bufs_[curr_ ^ 1 ].buffer_ .Clear ();
686
707
explicit_prefetch_submitted_ = false ;
708
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
709
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
710
+ }
687
711
return false ;
688
712
}
689
713
}
690
714
691
715
if (!explicit_prefetch_submitted_ && offset < bufs_[curr_].offset_ ) {
716
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
717
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
718
+ }
692
719
return false ;
693
720
}
694
721
@@ -714,6 +741,9 @@ bool FilePrefetchBuffer::TryReadFromCacheAsync(
714
741
if (!IsEligibleForPrefetch (offset, n)) {
715
742
// Ignore status as Prefetch is not called.
716
743
s.PermitUncheckedError ();
744
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
745
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
746
+ }
717
747
return false ;
718
748
}
719
749
}
@@ -729,10 +759,16 @@ bool FilePrefetchBuffer::TryReadFromCacheAsync(
729
759
#ifndef NDEBUG
730
760
IGNORE_STATUS_IF_ERROR (s);
731
761
#endif
762
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
763
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
764
+ }
732
765
return false ;
733
766
}
734
767
prefetched = explicit_prefetch_submitted_ ? false : true ;
735
768
} else {
769
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
770
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_MISS);
771
+ }
736
772
return false ;
737
773
}
738
774
}
@@ -748,6 +784,9 @@ bool FilePrefetchBuffer::TryReadFromCacheAsync(
748
784
if (prefetched) {
749
785
readahead_size_ = std::min (max_readahead_size_, readahead_size_ * 2 );
750
786
}
787
+ if (usage_ == FilePrefetchBufferUsage::kTableOpenPrefetchTail ) {
788
+ RecordTick (stats_, TABLE_OPEN_PREFETCH_TAIL_HIT);
789
+ }
751
790
return true ;
752
791
}
753
792
0 commit comments