Skip to content

Commit

Permalink
Fix build and test.
Browse files Browse the repository at this point in the history
Summary:
Fix bug in FBStringTest (don't reuse the same file name)

Don't use VLOG, as that requires that glog is compiled with gflags
support, which it isn't always.

Add other targets and tests, make all tests pass.

Test Plan: tests

Reviewed By: delong.j@fb.com

FB internal diff: D493018
  • Loading branch information
tudor committed Jun 12, 2012
1 parent 987da6d commit 9660004
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 101 deletions.
130 changes: 82 additions & 48 deletions folly/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,118 @@ SUBDIRS = . test

ACLOCAL_AMFLAGS = -I m4

noinst_PROGRAMS = generate_fingerprint_tables
generate_fingerprint_tables_SOURCES = build/GenerateFingerprintTables.cpp
generate_fingerprint_tables_LDADD = libfolly.la

lib_LTLIBRARIES = \
libfolly.la \
libfollybenchmark.la \
libfollytimeout_queue.la
libfollytimeout_queue.la \
libfollyfingerprint.la

follyincludedir = $(includedir)/folly

nobase_follyinclude_HEADERS = \
FBVector.h \
detail/ThreadLocalDetail.h \
detail/DiscriminatedPtrDetail.h \
Arena.h \
Arena-inl.h \
AtomicHashArray.h \
AtomicHashArray-inl.h \
AtomicHashMap.h \
AtomicHashMap-inl.h \
Benchmark.h \
Bits.h \
ConcurrentSkipList.h \
ConcurrentSkipList-inl.h \
Conv.h \
detail/AtomicHashUtils.h \
detail/BitIteratorDetail.h \
detail/DiscriminatedPtrDetail.h \
detail/FingerprintPolynomial.h \
detail/GroupVarintDetail.h \
IntrusiveList.h \
TimeoutQueue.h \
String.h \
PackedSyncPtr.h \
Conv.h \
ThreadLocal.h \
ProducerConsumerQueue.h \
Histogram-inl.h \
ThreadCachedInt.h \
ConcurrentSkipList.h \
json.h \
folly-config.h \
FBString.h \
Unicode.h \
test/function_benchmark/test_functions.h \
test/function_benchmark/benchmark_impl.h \
test/FBStringTestBenchmarks.cpp.h \
test/SynchronizedTestLib.h \
test/FBVectorTestBenchmarks.cpp.h \
test/SynchronizedTestLib-inl.h \
Synchronized.h \
Malloc.h \
detail/SlowFingerprint.h \
detail/ThreadLocalDetail.h \
DiscriminatedPtr.h \
dynamic.h \
AtomicHashArray.h \
dynamic-inl.h \
Bits.h \
sorted_vector_types.h \
Hash.h \
DiscriminatedPtr.h \
ConcurrentSkipList-inl.h \
Random.h \
eventfd.h \
FBString.h \
FBVector.h \
Fingerprint.h \
folly-config.h \
Foreach.h \
FormatArg.h \
Format.h \
Format-inl.h \
GroupVarint.h \
Range.h \
Benchmark.h \
Likely.h \
Hash.h \
Histogram.h \
AtomicHashMap.h \
Histogram-inl.h \
IntrusiveList.h \
json.h \
Likely.h \
Malloc.h \
MapUtil.h \
PackedSyncPtr.h \
Portability.h \
AtomicHashArray-inl.h \
eventfd.h \
SmallLocks.h \
ScopeGuard.h \
Traits.h \
Preprocessor.h \
ProducerConsumerQueue.h \
Random.h \
Range.h \
RWSpinLock.h \
ScopeGuard.h \
SmallLocks.h \
small_vector.h \
Foreach.h \
AtomicHashMap-inl.h \
MapUtil.h
sorted_vector_types.h \
StlAllocator.h \
String.h \
String-inl.h \
Synchronized.h \
test/FBStringTestBenchmarks.cpp.h \
test/FBVectorTestBenchmarks.cpp.h \
test/function_benchmark/benchmark_impl.h \
test/function_benchmark/test_functions.h \
test/SynchronizedTestLib.h \
test/SynchronizedTestLib-inl.h \
ThreadCachedArena.h \
ThreadCachedInt.h \
ThreadLocal.h \
TimeoutQueue.h \
Traits.h \
Unicode.h

FormatTables.cpp: build/generate_format_tables.py
build/generate_format_tables.py

EscapeTables.cpp: build/generate_escape_tables.py
build/generate_escape_tables.py

GroupVarintTables.cpp: build/generate_varint_tables.py
build/generate_varint_tables.py

libfolly_la_SOURCES = \
Random.cpp \
Range.cpp \
Unicode.cpp \
Conv.cpp \
Format.cpp \
FormatTables.cpp \
String.cpp \
json.cpp \
dynamic.cpp \
GroupVarint.cpp \
GroupVarintTables.cpp \
EscapeTables.cpp \
ThreadCachedArena.cpp \
Format.cpp \
FormatTables.cpp \
String.cpp

libfolly_la_LIBADD = $(BOOST_THREAD_LIBS) -lpthread

FingerprintTables.cpp: generate_fingerprint_tables
./generate_fingerprint_tables

libfollyfingerprint_la_SOURCES = \
FingerprintTables.cpp

libfollybenchmark_la_SOURCES = Benchmark.cpp
libfollybenchmark_la_LIBADD = -lboost_regex -lpthread -lrt

Expand Down
32 changes: 16 additions & 16 deletions folly/test/ConcurrentSkipListBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#include <map>
#include <set>
#include <thread>

#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>

#include <gflags/gflags.h>
#include <glog/logging.h>
Expand Down Expand Up @@ -77,7 +77,7 @@ void BM_IterateOverSet(int iters, int size) {
if (iter == a_set.end()) iter = a_set.begin();
}
BENCHMARK_SUSPEND {
VLOG(20) << "sum = " << sum;
// VLOG(20) << "sum = " << sum;
}
}

Expand All @@ -98,7 +98,7 @@ void BM_IterateSkipList(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << "sum = " << sum;
// VLOG(20) << "sum = " << sum;
}
}

Expand All @@ -119,7 +119,7 @@ void BM_SetMerge(int iters, int size) {
if (b_set.find(*it) != b_set.end()) mergedSum += *it;
}
BENCHMARK_SUSPEND {
VLOG(20) << mergedSum;
// VLOG(20) << mergedSum;
}
}

Expand All @@ -143,7 +143,7 @@ void BM_CSLMergeLookup(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << mergedSum;
// VLOG(20) << mergedSum;
}
}

Expand Down Expand Up @@ -180,7 +180,7 @@ void BM_CSLMergeIntersection(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << mergedSum;
// VLOG(20) << mergedSum;
}
}

Expand All @@ -199,7 +199,7 @@ void BM_SetContainsNotFound(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << sum;
// VLOG(20) << sum;
}
}

Expand All @@ -224,7 +224,7 @@ void BM_SetContainsFound(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << sum;
// VLOG(20) << sum;
}
}

Expand All @@ -248,7 +248,7 @@ void BM_CSLContainsFound(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << sum;
// VLOG(20) << sum;
}
}

Expand All @@ -268,7 +268,7 @@ void BM_CSLContainsNotFound(int iters, int size) {
}

BENCHMARK_SUSPEND {
VLOG(20) << sum;
// VLOG(20) << sum;
}
}

Expand Down Expand Up @@ -410,15 +410,15 @@ class ConcurrentAccessData {
for (int i = 0; i < iters; ++i) {
sum += accessSkipList(id, i);
}
VLOG(20) << sum;
// VLOG(20) << sum;
}

void runSet(int id, int iters) {
int sum = 0;
for (int i = 0; i < iters; ++i) {
sum += accessSet(id, i);
}
VLOG(20) << sum;
// VLOG(20) << sum;
}

bool accessSkipList(int64_t id, int t) {
Expand Down Expand Up @@ -484,11 +484,11 @@ static ConcurrentAccessData *mayInitTestData(int size) {
void BM_ContentionCSL(int iters, int size) {
BenchmarkSuspender susp;
auto data = mayInitTestData(size);
std::vector<boost::thread> threads;
std::vector<std::thread> threads;
susp.dismiss();

for (int i = 0; i < FLAGS_num_threads; ++i) {
threads.push_back(boost::thread(
threads.push_back(std::thread(
&ConcurrentAccessData::runSkipList, data, i, iters));
}
FOR_EACH(t, threads) {
Expand All @@ -499,11 +499,11 @@ void BM_ContentionCSL(int iters, int size) {
void BM_ContentionStdSet(int iters, int size) {
BenchmarkSuspender susp;
auto data = mayInitTestData(size);
std::vector<boost::thread> threads;
std::vector<std::thread> threads;
susp.dismiss();

for (int i = 0; i < FLAGS_num_threads; ++i) {
threads.push_back(boost::thread(
threads.push_back(std::thread(
&ConcurrentAccessData::runSet, data, i, iters));
}
FOR_EACH(t, threads) {
Expand Down
20 changes: 10 additions & 10 deletions folly/test/ConcurrentSkipListTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <set>
#include <vector>
#include <boost/thread.hpp>
#include <thread>

#include <glog/logging.h>
#include <gflags/gflags.h>
Expand Down Expand Up @@ -208,10 +208,10 @@ TEST(ConcurrentSkipList, SequentialAccess) {
void testConcurrentAdd(int numThreads) {
auto skipList(SkipListType::create(kHeadHeight));

vector<boost::thread> threads;
vector<std::thread> threads;
vector<SetType> verifiers(numThreads);
for (int i = 0; i < numThreads; ++i) {
threads.push_back(boost::thread(
threads.push_back(std::thread(
&randomAdding, 100, skipList, &verifiers[i], kMaxValue));
}
for (int i = 0; i < threads.size(); ++i) {
Expand All @@ -238,10 +238,10 @@ void testConcurrentRemoval(int numThreads, int maxValue) {
skipList.add(i);
}

vector<boost::thread> threads;
vector<std::thread> threads;
vector<SetType > verifiers(numThreads);
for (int i = 0; i < numThreads; ++i) {
threads.push_back(boost::thread(
threads.push_back(std::thread(
&randomRemoval, 100, skipList, &verifiers[i], maxValue));
}
FOR_EACH(t, threads) {
Expand Down Expand Up @@ -284,24 +284,24 @@ static void testConcurrentAccess(
std::sort(skipValues[i].begin(), skipValues[i].end());
}

vector<boost::thread> threads;
vector<std::thread> threads;
for (int i = 0; i < FLAGS_num_threads; ++i) {
switch (i % 8) {
case 0:
case 1:
threads.push_back(boost::thread(
threads.push_back(std::thread(
randomAdding, numInsertions, skipList, &verifiers[i], maxValue));
break;
case 2:
threads.push_back(boost::thread(
threads.push_back(std::thread(
randomRemoval, numDeletions, skipList, &verifiers[i], maxValue));
break;
case 3:
threads.push_back(boost::thread(
threads.push_back(std::thread(
concurrentSkip, &skipValues[i], skipList));
break;
default:
threads.push_back(boost::thread(sumAllValues, skipList, &sums[i]));
threads.push_back(std::thread(sumAllValues, skipList, &sums[i]));
break;
}
}
Expand Down
Loading

0 comments on commit 9660004

Please sign in to comment.