Skip to content

Commit

Permalink
replaced get_cumulative_stats() with direct access to cstats
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquintides committed May 3, 2024
1 parent 223f647 commit c1317cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
14 changes: 5 additions & 9 deletions include/boost/unordered/detail/foa/concurrent_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ class concurrent_table:
x.arrays=ah.release();
x.size_ctrl.ml=x.initial_max_load();
x.size_ctrl.size=0;
BOOST_UNORDERED_SWAP_STATS(
this->get_cumulative_stats(),x.get_cumulative_stats());
BOOST_UNORDERED_SWAP_STATS(this->cstats,x.cstats);
}

concurrent_table(compatible_nonconcurrent_table&& x):
Expand Down Expand Up @@ -1216,8 +1215,7 @@ class concurrent_table:
if(BOOST_LIKELY(bool(this->pred()(x,this->key_from(p[n]))))){
f(pg,n,p+n);
BOOST_UNORDERED_ADD_STATS(
this->get_cumulative_stats().successful_lookup,
(pb.length(),num_cmps));
this->cstats.successful_lookup,(pb.length(),num_cmps));
return 1;
}
}
Expand All @@ -1226,14 +1224,13 @@ class concurrent_table:
}
if(BOOST_LIKELY(pg->is_not_overflowed(hash))){
BOOST_UNORDERED_ADD_STATS(
this->get_cumulative_stats().unsuccessful_lookup,
(pb.length(),num_cmps));
this->cstats.unsuccessful_lookup,(pb.length(),num_cmps));
return 0;
}
}
while(BOOST_LIKELY(pb.next(this->arrays.groups_size_mask)));
BOOST_UNORDERED_ADD_STATS(
this->get_cumulative_stats().unsuccessful_lookup,(pb.length(),num_cmps));
this->cstats.unsuccessful_lookup,(pb.length(),num_cmps));
return 0;
}

Expand Down Expand Up @@ -1514,8 +1511,7 @@ class concurrent_table:
this->construct_element(p,std::forward<Args>(args)...);
rslot.commit();
rsize.commit();
BOOST_UNORDERED_ADD_STATS(
this->get_cumulative_stats().insertion,(pb.length()));
BOOST_UNORDERED_ADD_STATS(this->cstats.insertion,(pb.length()));
return 1;
}
pg->mark_overflow(hash);
Expand Down
14 changes: 4 additions & 10 deletions include/boost/unordered/detail/foa/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1719,21 +1719,21 @@ table_core:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,2>
auto n=unchecked_countr_zero(mask);
if(BOOST_LIKELY(bool(pred()(x,key_from(p[n]))))){
BOOST_UNORDERED_ADD_STATS(
get_cumulative_stats().successful_lookup,(pb.length(),num_cmps));
cstats.successful_lookup,(pb.length(),num_cmps));
return {pg,n,p+n};
}
mask&=mask-1;
}while(mask);
}
if(BOOST_LIKELY(pg->is_not_overflowed(hash))){
BOOST_UNORDERED_ADD_STATS(
get_cumulative_stats().unsuccessful_lookup,(pb.length(),num_cmps));
cstats.unsuccessful_lookup,(pb.length(),num_cmps));
return {};
}
}
while(BOOST_LIKELY(pb.next(arrays.groups_size_mask)));
BOOST_UNORDERED_ADD_STATS(
get_cumulative_stats().unsuccessful_lookup,(pb.length(),num_cmps));
cstats.unsuccessful_lookup,(pb.length(),num_cmps));
return {};
}

Expand Down Expand Up @@ -1842,11 +1842,6 @@ table_core:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,2>
};
}

cumulative_stats& get_cumulative_stats()const noexcept
{
return cstats;
}

void reset_stats()
{
cstats.insertion.reset();
Expand Down Expand Up @@ -2356,8 +2351,7 @@ table_core:empty_value<Hash,0>,empty_value<Pred,1>,empty_value<Allocator,2>
auto p=arrays_.elements()+pos*N+n;
construct_element(p,std::forward<Args>(args)...);
pg->set(n,hash);
BOOST_UNORDERED_ADD_STATS(
get_cumulative_stats().insertion,(pb.length()));
BOOST_UNORDERED_ADD_STATS(cstats.insertion,(pb.length()));
return {pg,n,p};
}
else pg->mark_overflow(hash);
Expand Down
3 changes: 1 addition & 2 deletions include/boost/unordered/detail/foa/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,7 @@ class table:table_core_impl<TypePolicy,Hash,Pred,Allocator>
x.arrays=ah.release();
x.size_ctrl.ml=x.initial_max_load();
x.size_ctrl.size=0;
BOOST_UNORDERED_SWAP_STATS(
this->get_cumulative_stats(),x.get_cumulative_stats());
BOOST_UNORDERED_SWAP_STATS(this->cstats,x.cstats);
}

template<typename ExclusiveLockGuard>
Expand Down

0 comments on commit c1317cb

Please sign in to comment.