@@ -459,15 +459,12 @@ size_t QList::DefragIfNeeded(PageUsage* page_usage) {
459459 return reallocated;
460460}
461461
462- void QList::SetTieringParams (const TieringParams& params) {
463- tiering_params_ = make_unique<TieringParams>(params);
464- }
465-
466462QList::QList (int fill, int compress)
467463 : fill_(fill),
468464 dict_learning_failed_ (0 ),
469465 dict_compress_failed_(0 ),
470466 dict_bulk_finished_(0 ),
467+ tiering_enabled_(0 ),
471468 compress_(compress),
472469 bookmark_count_(0 ) {
473470}
@@ -480,10 +477,10 @@ QList::QList(QList&& other) noexcept
480477 dict_learning_failed_(other.dict_learning_failed_),
481478 dict_compress_failed_(other.dict_compress_failed_),
482479 dict_bulk_finished_(other.dict_bulk_finished_),
480+ tiering_enabled_(other.tiering_enabled_),
483481 compress_(other.compress_),
484482 bookmark_count_(other.bookmark_count_),
485- num_offloaded_nodes_(other.num_offloaded_nodes_),
486- tiering_params_(std::move(other.tiering_params_)) {
483+ num_offloaded_nodes_(other.num_offloaded_nodes_) {
487484 other.head_ = nullptr ;
488485 other.len_ = other.count_ = 0 ;
489486 other.num_offloaded_nodes_ = 0 ;
@@ -503,9 +500,9 @@ QList& QList::operator=(QList&& other) noexcept {
503500 dict_learning_failed_ = other.dict_learning_failed_ ;
504501 dict_compress_failed_ = other.dict_compress_failed_ ;
505502 dict_bulk_finished_ = other.dict_bulk_finished_ ;
503+ tiering_enabled_ = other.tiering_enabled_ ;
506504 compress_ = other.compress_ ;
507505 bookmark_count_ = other.bookmark_count_ ;
508- tiering_params_ = std::move (other.tiering_params_ );
509506 num_offloaded_nodes_ = other.num_offloaded_nodes_ ;
510507 other.head_ = nullptr ;
511508 other.len_ = other.count_ = other.num_offloaded_nodes_ = 0 ;
@@ -521,10 +518,8 @@ void QList::Clear() noexcept {
521518
522519 // If entry is offloaded we should skip freeing its memory.
523520 bool free_entry = current->offloaded == 0 ;
524- if (current->offloaded || current->io_pending ) {
525- if (tiering_params_ && tiering_params_->delete_cb ) {
526- tiering_params_->delete_cb (current);
527- }
521+ if (tiering_enabled_ && (current->offloaded || current->io_pending )) {
522+ CleanupOffloadedNode (current);
528523 } else {
529524 if (current->encoding != QUICKLIST_NODE_ENCODING_RAW) {
530525 quicklistLZF* lzf = (quicklistLZF*)current->entry ;
@@ -919,7 +914,7 @@ void QList::Replace(Iterator it, std::string_view elem) {
919914}
920915
921916void QList::CoolOff (Node* node, uint32_t node_id) {
922- if (tiering_params_ ) {
917+ if (tiering_enabled_ ) {
923918 // Dry run for offloading decision.
924919 // a. Node id is withing the offloadable depth - offload it if not already offloaded.
925920 // b. Node id is outside the offloadable depth - but we have too many nodes that are not
@@ -930,12 +925,12 @@ void QList::CoolOff(Node* node, uint32_t node_id) {
930925 // we won't need to traverse them again for "trivial" access patterns unless they
931926 // get accessed again. Another reason for missing offloaded nodes is that node_id can be
932927 // off due to merges (can be improved in future).
933- if (node_id >= tiering_params_-> node_depth_threshold &&
934- node_id + tiering_params_-> node_depth_threshold < len_) {
928+ if (node_id >= tiering_node_depth_threshold_ &&
929+ node_id + tiering_node_depth_threshold_ < len_) {
935930 if (!node->offloaded && !node->io_pending ) {
936931 OffloadNode (node);
937932 }
938- } else if (num_offloaded_nodes_ * 2 + tiering_params_-> node_depth_threshold * 2 < len_) {
933+ } else if (num_offloaded_nodes_ * 2 + tiering_node_depth_threshold_ * 2 < len_) {
939934 // We check `num_offloaded_nodes_ * 2` above to avoid frequent traversals.
940935 // So only when the gap between offloaded and non-offloaded nodes is large enough,
941936 // we do a traversal to offload more nodes.
@@ -946,8 +941,8 @@ void QList::CoolOff(Node* node, uint32_t node_id) {
946941 // Traverse from both ends towards the middle as we expect more offloads towards the ends
947942 // due to usual access patterns of adding items via lpush/rpush.
948943 while (traverse_node_id <= len_ / 2 &&
949- (num_offloaded_nodes_ + 2 * tiering_params_-> node_depth_threshold ) < len_) {
950- if (traverse_node_id >= tiering_params_-> node_depth_threshold ) {
944+ (num_offloaded_nodes_ + 2 * tiering_node_depth_threshold_ ) < len_) {
945+ if (traverse_node_id >= tiering_node_depth_threshold_ ) {
951946 if (fw->offloaded == 0 && fw->io_pending == 0 ) {
952947 OffloadNode (fw);
953948 }
@@ -1047,18 +1042,17 @@ void QList::CompressByDepth(Node* node) {
10471042}
10481043
10491044void QList::Materialize (Node* node) {
1050- if (!tiering_params_ || (!node->offloaded && !node->io_pending ))
1045+ if (!tiering_enabled_ || (!node->offloaded && !node->io_pending ))
10511046 return ;
10521047
10531048 // Cancel stash in progress before loading.
1054- if (node->io_pending && tiering_params_-> delete_cb ) {
1055- tiering_params_-> delete_cb (node);
1049+ if (node->io_pending ) {
1050+ CleanupOffloadedNode (node);
10561051 }
10571052
10581053 // Load the offloaded node data back into memory.
1059- if (node->offloaded && tiering_params_->onload_cb ) {
1060- stats.onload_requests ++;
1061- tiering_params_->onload_cb (node);
1054+ if (node->offloaded ) {
1055+ ReadOffloadedNode (node);
10621056 }
10631057
10641058 DCHECK (!node->offloaded );
@@ -1198,10 +1192,8 @@ void QList::DelNode(Node* node) {
11981192 malloc_size_ -= node->sz ;
11991193 }
12001194
1201- if (tiering_params_ && (node->offloaded || node->io_pending )) {
1202- if (tiering_params_->delete_cb ) {
1203- tiering_params_->delete_cb (node);
1204- }
1195+ if (tiering_enabled_ && (node->offloaded || node->io_pending )) {
1196+ CleanupOffloadedNode (node);
12051197 }
12061198
12071199 /* If we deleted a node within our compress depth, we
@@ -1249,12 +1241,18 @@ bool QList::DelPackedIndex(Node* node, uint8_t* p) {
12491241 return false ;
12501242}
12511243
1252- void QList::OffloadNode (Node* node) {
1253- DCHECK (tiering_params_ && node->offloaded == 0 && node->io_pending == 0 );
1244+ void QList::OffloadNode (Node* node) const {
1245+ DCHECK (tiering_enabled_ && node->offloaded == 0 && node->io_pending == 0 );
12541246 stats.offload_requests ++;
1255- if (tiering_params_->offload_cb ) {
1256- tiering_params_->offload_cb (node);
1257- }
1247+ node->io_pending = 1 ;
1248+ }
1249+
1250+ void QList::ReadOffloadedNode (QList::Node* node) const {
1251+ stats.onload_requests ++;
1252+ }
1253+
1254+ void QList::CleanupOffloadedNode (QList::Node* node) const {
1255+ node->io_pending = 0 ;
12581256}
12591257
12601258void QList::InitIteratorEntry (Iterator* it) const {
0 commit comments