proxygen
folly::f14 Namespace Reference

Namespaces

 detail
 

Classes

struct  Counts
 
class  GenericAlloc
 
class  GenericEqual
 
class  GenericHasher
 
struct  Histo
 
struct  MoveOnlyTestInt
 
class  SwapTrackingAlloc
 
struct  Tracked
 
struct  TransparentTrackedEqual
 
struct  TransparentTrackedHash
 

Typedefs

template<typename T >
using DefaultHasher = HeterogeneousAccessHash< T >
 
template<typename T >
using DefaultKeyEqual = HeterogeneousAccessEqualTo< T >
 
template<typename T >
using DefaultAlloc = std::allocator< T >
 

Functions

std::ostream & operator<< (std::ostream &xo, Histo const &histo)
 
void accumulate (std::vector< std::size_t > &a, std::vector< std::size_t > const &d)
 
double expectedProbe (std::vector< std::size_t > const &probeLengths)
 
std::size_t p99Probe (std::vector< std::size_t > const &probeLengths)
 
std::ostream & operator<< (std::ostream &xo, Counts const &counts)
 
void limitTestAllocations (std::size_t allocationsBeforeException=0)
 
void unlimitTestAllocations ()
 
void resetTracking ()
 
template<class T >
void swap (SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
 
template<class T1 , class T2 >
bool operator== (SwapTrackingAlloc< T1 > const &, SwapTrackingAlloc< T2 > const &)
 
template<class T1 , class T2 >
bool operator!= (SwapTrackingAlloc< T1 > const &, SwapTrackingAlloc< T2 > const &)
 
std::ostream & operator<< (std::ostream &xo, F14TableStats const &stats)
 

Variables

thread_local Counts sumCounts {}
 
thread_local size_t testAllocatedMemorySize {0}
 
thread_local size_t testAllocatedBlockCount {0}
 
thread_local size_t testAllocationCount {0}
 
thread_local size_t testAllocationMaxCount
 

Typedef Documentation

template<typename T >
using folly::f14::DefaultAlloc = typedef std::allocator<T>

Definition at line 32 of file F14Defaults.h.

template<typename T >
using folly::f14::DefaultHasher = typedef HeterogeneousAccessHash<T>

Definition at line 26 of file F14Defaults.h.

template<typename T >
using folly::f14::DefaultKeyEqual = typedef HeterogeneousAccessEqualTo<T>

Definition at line 29 of file F14Defaults.h.

Function Documentation

void folly::f14::accumulate ( std::vector< std::size_t > &  a,
std::vector< std::size_t > const &  d 
)

Definition at line 58 of file F14TestUtil.h.

References i.

Referenced by BENCHMARK(), TestData::checkIn(), TestData::checkOut(), folly::dynamic::hash(), main(), runFairness(), and TestData::TestData().

60  {
61  if (a.size() < d.size()) {
62  a.resize(d.size());
63  }
64  for (std::size_t i = 0; i < d.size(); ++i) {
65  a[i] += d[i];
66  }
67 }
double folly::f14::expectedProbe ( std::vector< std::size_t > const &  probeLengths)

Definition at line 69 of file F14TestUtil.h.

References count, i, and sum().

69  {
70  std::size_t sum = 0;
71  std::size_t count = 0;
72  for (std::size_t i = 1; i < probeLengths.size(); ++i) {
73  sum += i * probeLengths[i];
74  count += probeLengths[i];
75  }
76  return static_cast<double>(sum) / static_cast<double>(count);
77 }
std::atomic< int64_t > sum(0)
int * count
void folly::f14::limitTestAllocations ( std::size_t  allocationsBeforeException = 0)
inline

Definition at line 328 of file F14TestUtil.h.

References testAllocationCount, and testAllocationMaxCount.

Referenced by TEST().

328  {
329  testAllocationMaxCount = testAllocationCount + allocationsBeforeException;
330 }
thread_local size_t testAllocationCount
Definition: F14TestUtil.h:324
thread_local size_t testAllocationMaxCount
Definition: F14TestUtil.h:325
template<class T1 , class T2 >
bool folly::f14::operator!= ( SwapTrackingAlloc< T1 > const &  ,
SwapTrackingAlloc< T2 > const &   
)
std::ostream& folly::f14::operator<< ( std::ostream &  xo,
Histo const &  histo 
)

Definition at line 37 of file F14TestUtil.h.

References folly::f14::Histo::data, i, folly::partial(), sum(), and v.

37  {
38  xo << "[";
39  size_t sum = 0;
40  for (auto v : histo.data) {
41  sum += v;
42  }
43  size_t partial = 0;
44  for (size_t i = 0; i < histo.data.size(); ++i) {
45  if (i > 0) {
46  xo << ", ";
47  }
48  partial += histo.data[i];
49  if (histo.data[i] > 0) {
50  xo << i << ": " << histo.data[i] << " ("
51  << (static_cast<double>(partial) * 100.0 / sum) << "%)";
52  }
53  }
54  xo << "]";
55  return xo;
56 }
std::atomic< int64_t > sum(0)
auto v
auto partial(F &&f, Args &&...args) -> detail::partial::Partial< typename std::decay< F >::type, std::tuple< typename std::decay< Args >::type... >>
Definition: Partial.h:119
std::ostream& folly::f14::operator<< ( std::ostream &  xo,
Counts const &  counts 
)

Definition at line 173 of file F14TestUtil.h.

References folly::f14::Counts::copyAssign, folly::f14::Counts::copyConstruct, folly::f14::Counts::copyConvert, folly::f14::Counts::defaultConstruct, folly::f14::Counts::destroyed, folly::f14::Counts::moveAssign, folly::f14::Counts::moveConstruct, folly::f14::Counts::moveConvert, and string.

173  {
174  xo << "[";
175  std::string glue = "";
176  if (counts.copyConstruct > 0) {
177  xo << glue << counts.copyConstruct << " copy";
178  glue = ", ";
179  }
180  if (counts.moveConstruct > 0) {
181  xo << glue << counts.moveConstruct << " move";
182  glue = ", ";
183  }
184  if (counts.copyConvert > 0) {
185  xo << glue << counts.copyConvert << " copy convert";
186  glue = ", ";
187  }
188  if (counts.moveConvert > 0) {
189  xo << glue << counts.moveConvert << " move convert";
190  glue = ", ";
191  }
192  if (counts.copyAssign > 0) {
193  xo << glue << counts.copyAssign << " copy assign";
194  glue = ", ";
195  }
196  if (counts.moveAssign > 0) {
197  xo << glue << counts.moveAssign << " move assign";
198  glue = ", ";
199  }
200  if (counts.defaultConstruct > 0) {
201  xo << glue << counts.defaultConstruct << " default construct";
202  glue = ", ";
203  }
204  if (counts.destroyed > 0) {
205  xo << glue << counts.destroyed << " destroyed";
206  glue = ", ";
207  }
208  xo << "]";
209  return xo;
210 }
const char * string
Definition: Conv.cpp:212
std::ostream& folly::f14::operator<< ( std::ostream &  xo,
F14TableStats const &  stats 
)

Definition at line 431 of file F14TestUtil.h.

References folly::F14TableStats::bucketCount, folly::F14TableStats::chunkCount, folly::F14TableStats::chunkHostedOverflowHisto, folly::F14TableStats::chunkOccupancyHisto, folly::F14TableStats::chunkOutboundOverflowHisto, folly::demangle(), folly::F14TableStats::keyProbeLengthHisto, folly::F14TableStats::missProbeLengthHisto, folly::F14TableStats::overheadBytes, folly::F14TableStats::policy, folly::F14TableStats::size, folly::F14TableStats::totalBytes, and folly::F14TableStats::valueSize.

431  {
432  using f14::Histo;
433 
434  xo << "{ " << std::endl;
435  xo << " policy: "
436 #if FOLLY_HAS_RTTI
437  << folly::demangle(stats.policy)
438 #else
439  << "unknown (RTTI not availabe)"
440 #endif
441  << std::endl;
442  xo << " size: " << stats.size << std::endl;
443  xo << " valueSize: " << stats.valueSize << std::endl;
444  xo << " bucketCount: " << stats.bucketCount << std::endl;
445  xo << " chunkCount: " << stats.chunkCount << std::endl;
446  xo << " chunkOccupancyHisto" << Histo{stats.chunkOccupancyHisto}
447  << std::endl;
448  xo << " chunkOutboundOverflowHisto"
449  << Histo{stats.chunkOutboundOverflowHisto} << std::endl;
450  xo << " chunkHostedOverflowHisto" << Histo{stats.chunkHostedOverflowHisto}
451  << std::endl;
452  xo << " keyProbeLengthHisto" << Histo{stats.keyProbeLengthHisto}
453  << std::endl;
454  xo << " missProbeLengthHisto" << Histo{stats.missProbeLengthHisto}
455  << std::endl;
456  xo << " totalBytes: " << stats.totalBytes << std::endl;
457  xo << " valueBytes: " << (stats.size * stats.valueSize) << std::endl;
458  xo << " overheadBytes: " << stats.overheadBytes << std::endl;
459  if (stats.size > 0) {
460  xo << " overheadBytesPerKey: "
461  << (static_cast<double>(stats.overheadBytes) /
462  static_cast<double>(stats.size))
463  << std::endl;
464  }
465  xo << "}";
466  return xo;
467 }
size_type size() const
Definition: FBString.h:1337
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
template<class T1 , class T2 >
bool folly::f14::operator== ( SwapTrackingAlloc< T1 > const &  ,
SwapTrackingAlloc< T2 > const &   
)
std::size_t folly::f14::p99Probe ( std::vector< std::size_t > const &  probeLengths)

Definition at line 81 of file F14TestUtil.h.

References count, i, and suffix.

81  {
82  std::size_t count = 0;
83  for (std::size_t i = 1; i < probeLengths.size(); ++i) {
84  count += probeLengths[i];
85  }
86  std::size_t rv = probeLengths.size();
87  std::size_t suffix = 0;
88  while ((suffix + probeLengths[rv - 1]) * 100 <= count) {
89  --rv;
90  }
91  return rv;
92 }
const char * suffix
Definition: String.cpp:272
int * count
void folly::f14::resetTracking ( )
inline

Definition at line 336 of file F14TestUtil.h.

References max, sumCounts, testAllocatedBlockCount, testAllocatedMemorySize, testAllocationCount, and testAllocationMaxCount.

Referenced by std::hash< TestStruct >::operator()(), TEST(), and testCustomSwap().

336  {
337  sumCounts = Counts{};
338  Tracked<0>::counts = Counts{};
339  Tracked<1>::counts = Counts{};
340  Tracked<2>::counts = Counts{};
341  Tracked<3>::counts = Counts{};
342  Tracked<4>::counts = Counts{};
343  Tracked<5>::counts = Counts{};
348 }
LogLevel max
Definition: LogLevel.cpp:31
thread_local Counts sumCounts
Definition: F14TestUtil.h:212
thread_local size_t testAllocationCount
Definition: F14TestUtil.h:324
thread_local size_t testAllocatedBlockCount
Definition: F14TestUtil.h:323
thread_local size_t testAllocatedMemorySize
Definition: F14TestUtil.h:322
static thread_local Counts counts
Definition: F14TestUtil.h:216
thread_local size_t testAllocationMaxCount
Definition: F14TestUtil.h:325
template<class T >
void folly::f14::swap ( SwapTrackingAlloc< T > &  ,
SwapTrackingAlloc< T > &   
)

Definition at line 414 of file F14TestUtil.h.

Referenced by proxygen::HTTP2PriorityQueue::Node::addChildren(), folly::pushmi::any_constrained_single_sender< E, TP, VN... >::any_constrained_single_sender(), folly::pushmi::any_flow_many_sender< PE, PV, E, VN >::any_flow_many_sender(), folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver(), folly::pushmi::any_flow_single_sender< PE, E, VN >::any_flow_single_sender(), folly::pushmi::any_many_sender< E, VN >::any_many_sender(), folly::pushmi::any_receiver< E, folly::pushmi::any_executor_ref< E > >::any_receiver(), folly::pushmi::any_single_sender< E, VN >::any_single_sender(), testing::AssertionResult::AppendMessage(), folly::HHWheelTimer::cancelAll(), folly::StringKeyedMap< Value, Compare, Alloc >::clear(), folly::HazptrSWMRSet< T, Atom >::contains(), folly::ThreadedExecutor::controlJoinFinishedThreads(), folly::ThreadedExecutor::controlLaunchEnqueuedTasks(), proxygen::HTTP2PriorityQueue::Node::emplaceNode(), proxygen::HTTP2PriorityQueue::Node::flattenSubtree(), List< T, Atom >::hand_over_hand(), proxygen::HTTP2PriorityQueue::iterateBFS(), folly::detail::distributed_mutex::DistributedMutex< Atomic, TimePublishing >::lock(), folly::fibers::FiberManager::loopUntilNoReadyImpl(), main(), proxygen::HTTP2PriorityQueue::nextEgress(), proxygen::HPACKHeader::operator=(), folly::fibers::Promise< T, BatonT >::operator=(), folly::SharedPromise< T >::operator=(), folly::DelayedDestructionBase::DestructorGuard::operator=(), folly::ReadMostlyMainPtr< T >::operator=(), folly::SocketAddress::operator=(), folly::F14VectorSet< Key, Hasher, KeyEqual, Alloc >::operator=(), folly::F14VectorMap< Key, Mapped, Hasher, KeyEqual, Alloc >::operator=(), folly::ReadMostlyWeakPtr< T >::operator=(), testing::AssertionResult::operator=(), folly::ReadMostlySharedPtr< T >::operator=(), folly::RWSpinLock::ReadHolder::operator=(), folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::operator=(), folly::RWSpinLock::UpgradedHolder::operator=(), folly::RWSpinLock::WriteHolder::operator=(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::ReadHolder::operator=(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::UpgradeHolder::operator=(), folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::WriteHolder::operator=(), folly::symbolizer::Dwarf::Path::Path(), folly::observer_detail::ObserverManager::DependencyRecorder::release(), folly::observer_detail::Core::removeStaleDependents(), folly::threadlocal_detail::StaticMetaBase::reserve(), folly::threadlocal_detail::StaticMetaBase::reserveHeadUnlocked(), run_queue_moving(), wangle::OutputBufferingHandler::runLoopCallback(), runMultiScopeTest(), folly::RequestContext::setShallowCopyContext(), testing::internal::ShouldRunTestCase(), folly::test::UniformSubset::shufflePrefix(), testing::internal::ShuffleRange(), proxygen::compress::SimStreamingCallback::SimStreamingCallback(), folly::coro::detail::ViaCoroutine::swap(), folly::StringKeyedSetBase< Compare, Alloc >::swap(), folly::coro::TaskWithExecutor< T >::swap(), folly::coro::Task< T >::swap(), testing::AssertionResult::swap(), folly::RWSpinLock::ReadHolder::swap(), folly::RWSpinLock::UpgradedHolder::swap(), folly::padded::Adaptor< IntNodeVec >::swap(), folly::RWSpinLock::WriteHolder::swap(), folly::Replaceable< T >::swap(), swap_test(), TEST(), folly::TEST(), TEST_F(), test_nonmemberSwappable3(), testCustomSwap(), testRandom(), proxygen::DanglingQueueTestBase::tick(), u64ToAsciiClassic(), and testing::internal::GTestFlagSaver::~GTestFlagSaver().

414  {
415  // For argument dependent lookup:
416  // This function will be called if the custom swap functions of F14 containers
417  // are used. Otherwise, std::swap() will do 1 move construct and 2 move
418  // assigns which will get tracked by t_.
419 }
void folly::f14::unlimitTestAllocations ( )
inline

Definition at line 332 of file F14TestUtil.h.

References max, and testAllocationMaxCount.

Referenced by TEST().

332  {
334 }
LogLevel max
Definition: LogLevel.cpp:31
thread_local size_t testAllocationMaxCount
Definition: F14TestUtil.h:325

Variable Documentation

thread_local size_t folly::f14::testAllocatedBlockCount {0}
thread_local size_t folly::f14::testAllocatedMemorySize {0}
thread_local size_t folly::f14::testAllocationCount {0}
thread_local size_t folly::f14::testAllocationMaxCount