Tudor Bosman [Wed, 14 Nov 2012 01:51:55 +0000 (17:51 -0800)]
one more
Test Plan: build
Reviewed By: tjackson@fb.com
FB internal diff:
D630280
Tudor Bosman [Wed, 14 Nov 2012 00:57:22 +0000 (16:57 -0800)]
fix ~File crash in debug mode
Test Plan: test added
Reviewed By: tjackson@fb.com
FB internal diff:
D630163
Tudor Bosman [Wed, 14 Nov 2012 01:43:31 +0000 (17:43 -0800)]
unbreak build
Test Plan: build
Reviewed By: tjackson@fb.com
FB internal diff:
D630266
Tudor Bosman [Tue, 13 Nov 2012 21:19:17 +0000 (13:19 -0800)]
Remove Stream
Summary:
Switch existing code to gen::byLine. Also fix namespaces in
folly/experimental/(symbolizer|exception_tracer).
Test Plan:
fbconfig -r folly && fbmake runtests_opt, ran non-test folly
binaries by hand, fbgs for other uses (there aren't any)
Reviewed By: tjackson@fb.com
FB internal diff:
D629576
Tom Jackson [Tue, 13 Nov 2012 23:12:04 +0000 (15:12 -0800)]
split()
Summary: Normal split to complement resplit, and it's a bit faster than folly::split().
Test Plan: Unit tests, Benchmarks (result in code comment)
Reviewed By: tudorb@fb.com
FB internal diff:
D629998
Tudor Bosman [Tue, 13 Nov 2012 20:45:51 +0000 (12:45 -0800)]
fix comments
Test Plan: no
Reviewed By: tjackson@fb.com
FB internal diff:
D629502
Tudor Bosman [Tue, 13 Nov 2012 03:46:41 +0000 (19:46 -0800)]
add split operator
Summary:
Also added eachAs (cast each value as a given type) and eachTo (use folly::to
on each value)
Test Plan: test added
Reviewed By: tjackson@fb.com
FB internal diff:
D628868
Tudor Bosman [Tue, 13 Nov 2012 00:42:43 +0000 (16:42 -0800)]
movify generators (but mostly operators)
Summary: Make things work with non-copyable generators.
Test Plan: folly/experimental/test
Reviewed By: tjackson@fb.com
FB internal diff:
D628520
Philip Pronin [Sun, 11 Nov 2012 01:56:51 +0000 (17:56 -0800)]
constexpr-ize folly/Bits.h
Summary:
Want to be able to call them from other constexpr functions
and from within static_assert()s.
Test Plan: compiled and ran folly tests
Reviewed By: tudorb@fb.com
FB internal diff:
D627413
Chao Yang [Wed, 31 Oct 2012 01:27:19 +0000 (18:27 -0700)]
Fix example for folly::format
Summary: That's all.
Test Plan: .
Reviewed By: tjackson@fb.com
FB internal diff:
D618824
Tom Jackson [Thu, 1 Nov 2012 00:58:37 +0000 (17:58 -0700)]
Composed, for lightweight operator composition
Summary:
Sometimes it'll be handy to have a custom operator which is little more than the
composition of a few base operators. This makes that really easy to do, as shown
in examples, tests, and benchmarks.
Test Plan: Unit tests, benchmarks
Reviewed By: rsagula@fb.com
FB internal diff:
D617152
Tom Jackson [Thu, 8 Nov 2012 23:32:13 +0000 (15:32 -0800)]
Adding support for printing arbitrary pointers
Summary: We should be able to print ##Foo*##, even if we can't print ##Foo##.
Test Plan: Unit Tests.
Reviewed By: tudorb@fb.com
FB internal diff:
D625977
Tom Jackson [Thu, 8 Nov 2012 22:59:20 +0000 (14:59 -0800)]
Enabling format("{}", format(...))
Summary:
If your format string ends up being conditional, it's handy to be able to chain
together formatters.
Test Plan: Unit tests
Reviewed By: tudorb@fb.com
FB internal diff:
D625502
Tudor Bosman [Mon, 5 Nov 2012 23:35:16 +0000 (15:35 -0800)]
add IOBuf::moveToFbString
Summary:
Convert a IOBuf chain into a fbstring, with zero copies in the common case
(unshared, unchained, no headroom) and one copy in all other cases.
Test Plan: tests added
Reviewed By: simpkins@fb.com
FB internal diff:
D621210
Marcelo Juchem [Tue, 6 Nov 2012 01:32:28 +0000 (17:32 -0800)]
Clang complains about errors in folly String-inl.h and FBString.h (P1825995)
Summary: fixing clang errors (used clang 3.1)
Test Plan: doh
Reviewed By: tudorb@fb.com
FB internal diff:
D622593
Marcelo Juchem [Tue, 6 Nov 2012 23:16:05 +0000 (15:16 -0800)]
Adding usage example for BENCHMARK_DRAW_LINE()
Summary:
Yes, I admit, I was dumb enough to try it in a benchmark's
body.
Test Plan: review
Reviewed By: tudorb@fb.com
FB internal diff:
D622613
Nicholas Ormrod [Tue, 6 Nov 2012 17:22:57 +0000 (09:22 -0800)]
Augment DynamicConverter's is_container check
Summary:
DynamicConverter uses some simple heuristics to determine if a
class is a container. One of those tests was to check that the
constructor 'template <class Iterator> [container-name](Iterator first,
Iterator last)' was present. That test was performed by checking if the
class could be constructed by two parameters of some dummy class.
However, it is possible to restrict the template parameter such that it
only accepts iterators, and not any arbitrary dummy class. This would be
useful, for example, to solve overload ambiguity with constructors like
'vector(const T& val, size_type n)', where T and size_type are the same
(see N3337 23.2.3 item 14). It also (I believe) produces more meaningful
compiler errors when a non-iterator is supplied, since it errors at the
function callsite instead of inside the constructor itself.
The new FBVector implementation uses such a feature, and so checking for
[container-name](dummy, dummy) will fail. Hence the dummy class has been
upgraded to reverse_iterator<T*>, a valid iterator class which almost
certainly does not have a specialized contructor in any class (and hence
will not cause any visible change in class_is_container's value).
Test Plan:
Run DynamicConverterTest; it has tests for the correctness of
class_is_container.
Reviewed By: delong.j@fb.com
FB internal diff:
D620607
Tudor Bosman [Sun, 4 Nov 2012 03:03:23 +0000 (20:03 -0700)]
ints used as flags (bitwise): so C
Summary:
Changed communicate() flags from int to a class.
Made Options and CommunicateFlags composable with |
Simplified API so you don't have to type Subprocess::Options().stdout(Subprocess::PIPE)
Test Plan: subprocess_test
Reviewed By: chip@fb.com
FB internal diff:
D620186
Tudor Bosman [Sat, 3 Nov 2012 00:04:57 +0000 (17:04 -0700)]
Retry wait() on EINTR; clean up signal handling
Test Plan: subprocess_test
Reviewed By: delong.j@fb.com
FB internal diff:
D619713
Tudor Bosman [Fri, 2 Nov 2012 20:38:36 +0000 (13:38 -0700)]
fix typos in comment; RV_* do not have to be public
Test Plan: subprocess_test
Reviewed By: chip@fb.com
FB internal diff:
D619189
Tudor Bosman [Mon, 29 Oct 2012 22:37:49 +0000 (15:37 -0700)]
Subprocess library, modeled after python's subprocess module
Summary:
Surprised we don't have one. The API is modeled after Python's
subprocess module, http://docs.python.org/2/library/subprocess.html
Inspired by
https://www.facebook.com/groups/fbcode/permalink/
445399858830192/, plus
I needed this functionality now.
Test Plan: test added
Reviewed By: chip@fb.com
FB internal diff:
D614056
Misha Shneerson [Fri, 2 Nov 2012 00:58:27 +0000 (17:58 -0700)]
[Conv] Remove __int128 overload
Summary: parseInt128 is only available for GCC 4.7 and above.
Test Plan: .
Reviewed By: igorzi@fb.com
FB internal diff:
D618456
Blame Revision: rFBCODEeaec97e2991f
Adam Simpkins [Wed, 31 Oct 2012 19:29:04 +0000 (12:29 -0700)]
update function_benchmark to test exception handling
Summary:
Add benchmarks for throwing an exception versus returning
std::exception_ptr or other types of return values.
Throwing an exception is very expensive. Calling std::make_exception_ptr()
without ever throwing is nearly as bad.
The exc_ptr_param_return tests were the ones I was most interested in.
(Accepting a std::exception_ptr* argument so the caller can indicate if they
want to receive an exception or not.) This is fast if the caller doesn't care
about the exception value, but very slow if an error occurs and an
exception_ptr is required.
Test Plan:
======================================================================
folly/test/function_benchmark/main.cpp relative time/iter iters/s
======================================================================
throw_exception 3.90us 256.25K
catch_no_exception 1.88ns 533.25M
return_exc_ptr 2.79us 357.85K
exc_ptr_param_return 2.83us 353.25K
exc_ptr_param_return_null 2.25ns 444.38M
return_string 69.39ns 14.41M
return_string_noexcept 69.39ns 14.41M
return_code 1.50ns 666.54M
return_code_noexcept 1.50ns 666.54M
Reviewed By: rajat@fb.com
FB internal diff:
D616474
Misha Shneerson [Sun, 28 Oct 2012 07:07:38 +0000 (00:07 -0700)]
[Conv] MaxString specialization for __int128
Summary: Just that.
Test Plan: .
Reviewed By: igorzi@fb.com
FB internal diff:
D613291
Hari Manikarnika [Fri, 26 Oct 2012 23:05:01 +0000 (16:05 -0700)]
make folly::toJson retain non-ascii chars if encode_non_ascii is disabled
Summary:
folly::toJson as demonstrated by the test cases was wrongly encoding utf8 strings.
specifically, a utf8 char made up of x bytes was encodeded into x unicode chars.
for example, the char:
\u2665
which is made of 3 bytes:
\xe2\x99\xa5
was encoded correctly when using encode_non_ascii = true:
"\u2665"
but when encode_non_ascii = false, the json value was wrongly set as:
"\u00e2\u0099\u00a5"
because we use an signed char that wrongly detects non-readable chars with
ascii value > 127 as control chars with ascii value < 32 (\t, \n, etc.)
Test Plan: run the test
Reviewed By: delong.j@fb.com
FB internal diff:
D612782
Tom Jackson [Thu, 25 Oct 2012 07:03:35 +0000 (00:03 -0700)]
Optional bugfixes
Summary: Tests were run in 'opt', which masked issues alterted by asserts.
Test Plan: Unit tests
Reviewed By: delong.j@fb.com
FB internal diff:
D611957
Xin Liu [Fri, 26 Oct 2012 18:44:41 +0000 (11:44 -0700)]
fixing double destruction of CSL::data_type
Summary:
the currently code calls both ~SkipListNode() and node->data_.~value_type()
causes double destructing the object.
Test Plan: adding dihde's testing code to a test case
Reviewed By: emailweixu@fb.com
FB internal diff:
D612289
Marcelo Juchem [Fri, 26 Oct 2012 02:00:59 +0000 (19:00 -0700)]
fix Benchmark docs
Summary: fix Benchmark docs
Test Plan: read
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D611820
Tom Jackson [Fri, 22 Jun 2012 06:27:23 +0000 (23:27 -0700)]
folly::gen, or Comprehensions->Folly
Summary:
Moving Comprehensions library into Folly and refactoring its interface to be much more modular and composable. There are now two core abstractions:
# Generators: Standalone classes supporting ##apply()## and optionally ##foreach()##. These all inherit from ##GenImpl<T, Self>##.
# Operators: Standalone classes which, when composed with a generator, produce a new generator. These all inherit from ##OperatorImpl<Self>##.
These generators may be composed with ##operator|## overloads which only match ##const GenImpl<T, Self>&## on the left like ##gen | op##. Additionally, generator may be consumed inline with ##gen | lambda## like ##gen | [](int x) { cout << x << endl; };##.
With this design, new operators may be added very simply without modifying the core library and templates are instantiated only exactly as needed.
Example:
```lang=cpp
auto sum = seq(1, 10) | filter(isPrime) | sum;
seq(1, 10) | [](int i) {
cout << i << endl;
};
```
Test Plan: Unit tests
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D542215
Andrei Alexandrescu [Mon, 22 Oct 2012 21:42:05 +0000 (14:42 -0700)]
fbstring's front() and back() return by reference
Summary: C++11 added front() and back() that return by reference. fbstring also added front() and back() as non-standard convenience functions, which returned by value. This diff aligns fbstring with the standard.
Test Plan: added and ran unittest
Reviewed By: delong.j@fb.com
FB internal diff:
D607574
Tom Jackson [Sat, 22 Sep 2012 00:19:01 +0000 (17:19 -0700)]
Optional
Summary: Optional, like boost::optional, but with full rvalue support.
Test Plan: Unit tests
Reviewed By: delong.j@fb.com
FB internal diff:
D571810
Tudor Bosman [Sun, 14 Oct 2012 01:33:17 +0000 (18:33 -0700)]
Add a folly::exceptionStr overload
Summary: For std::exception_ptr.
Test Plan: .
Reviewed By: davejwatson@fb.com
FB internal diff:
D600345
Sumeet Ungratwar [Mon, 13 Aug 2012 13:48:55 +0000 (06:48 -0700)]
Adding a general doc for traits provided in folly/Traits.h
Summary:
Understood how traits are implemented in folly/Traits.h and added
examples on how to use them.
Test Plan: no specific tests
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D546631
Tudor Bosman [Wed, 10 Oct 2012 21:11:25 +0000 (14:11 -0700)]
Add SpookyHashV2
Summary:
SpookyHashV2 is backwards incompatible with V1. I renamed the existing
SpookyHash class to SpookyHashV1 (and fixed all uses); the new class is
called SpookyHashV2.
From http://burtleburtle.net/bob/hash/spooky.html:
Both V1 and V2 pass all the tests. V2 corrects two oversights in V1:
In the short hash, there was a d = length that should have been d += length,
which means some entropy got dropped on the floor. It passed the tests anyhow,
but fixing this probably means more distinct info from the message makes it
into the result.
The long hash always ended in mix()+end(), but only end() was needed. Removing
the extra call to mix() makes all long hashes faster by a small constant
amount.
Test Plan: test added; unicorn compiles
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D597173
Wei Xu [Tue, 9 Oct 2012 04:39:44 +0000 (21:39 -0700)]
Fix fbstring hash
Summary: '\0' may actually be part of string. We cannot assume its null terminated and should use another form of fnv32.
Test Plan: FBStringTest
Reviewed By: xliux@fb.com
FB internal diff:
D595287
Rajat Goel [Sat, 22 Sep 2012 10:31:51 +0000 (03:31 -0700)]
Just trying out one more combination
Summary:
It seems it is not std::bind which is slow but the construction of
std::function from std::bind that is slow.
Test Plan: ran benchmarks
Reviewed By: delong.j@fb.com
FB internal diff:
D581967
Jonathan Coens [Wed, 19 Sep 2012 23:20:01 +0000 (16:20 -0700)]
Get total memory currently allocated by an Arena allocator
Summary: The Arena allocator knows how much memory it's using up, so create a function that allows clients to figure out how much it's using. Also create a unit test to sanity check this stuff.
Test Plan: folly/test/ArenaTest.cpp
Reviewed By: tudorb@fb.com
FB internal diff:
D579399
Anton Likhtarov [Wed, 26 Sep 2012 18:09:18 +0000 (11:09 -0700)]
folly/json: serialize \r and \n as \r and \n
Summary:
Background: we want to use folly::json but not change the way data is represented.
Since we need to store \r and \n in strings and the library we're currently using does this,
let's do it in folly too.
Test Plan: unit tests pass
Reviewed By: delong.j@fb.com
FB internal diff:
D584960
Ashoat Tevosyan [Mon, 24 Sep 2012 13:07:29 +0000 (06:07 -0700)]
Add DynamicConverters for const strings.
Summary: These are necessary for string-keyed maps, since maps const their keys.
Test Plan: I wrote a test.
Reviewed By: njormrod@fb.com
FB internal diff:
D582283
Andrew Tulloch [Mon, 24 Sep 2012 22:26:03 +0000 (15:26 -0700)]
Update folly/docs/Synchronized.md
Summary:
Fixed escaping bug where the `>` in `operator->` was
interpreted as starting a code block. Folly github pull #15.
Test Plan: no
Reviewed By: njormrod@fb.com
FB internal diff:
D582873
Jordan DeLong [Mon, 24 Sep 2012 20:58:28 +0000 (13:58 -0700)]
Add a FAQ item about dynamic strings
Summary:
After a conversation with njormrod I remembered why we didn't
do this. Let's document it.
Test Plan: It's docs.
Reviewed By: njormrod@fb.com
FB internal diff:
D582651
Philip Pronin [Sun, 23 Sep 2012 20:12:28 +0000 (13:12 -0700)]
SpinLockArray
Summary:
Array of spinlocks where each one is padded to prevent false
sharing.
Useful for shard-based locking implementations in environments where
contention is unlikely.
Test Plan: ran tests in 'common'
Reviewed By: soren@fb.com
FB internal diff:
D582149
Andrei Alexandrescu [Tue, 10 Jul 2012 18:42:34 +0000 (11:42 -0700)]
Better unsigned to string conversion
Summary:
In https://phabricator.fb.com/
D511928 Brian mentioned the current API for string append is insufficient for appending to a buffer. That made me curious about the relative performance of classic and table-based number to ASCII conversions.
The results were interesting as on the average (over all digit lengths) the table-based conversion was faster, but performance was lackluster (in the worst case half as fast as the classic implementation) for large numbers, I presume due to the cache misses incurred by the tables.
This diff proposes an improved unsigned-to-ASCII primitive that is much faster than both table-based (previous Folly) and classic primitive. The key is a fast digits10() implementation that precomputes the space required by the conversion. After that, the digits are issued in place, no more reverse required. The new routine is up to 14x faster than the classic implementation, depending on the number of digits (benchmarks in comments).
Adding a few people who may be interested in the matter. Brian, thanks for bringing this matter up; if this gets in you may want to use the folly routine in proxygen.
Test Plan: unittest and benchmarks.
Reviewed By: simpkins@fb.com
FB internal diff:
D515572
Jeremy Lilley [Thu, 20 Sep 2012 22:04:54 +0000 (15:04 -0700)]
Fix push_back() to shared fbstring bug.
Summary:
The following asserts:
fbstring str(1337, 'f');
fbstring cp = str;
cp.push_back('f');
This is problematic since ml_.capacity() != capacity() inside fbstring_core
for shared strings, which causes us not to un-share prior to push_back.
Test Plan: Existing tests, add unittest case.
Reviewed By: tudorb@fb.com
FB internal diff:
D580267
Lucian Grijincu [Tue, 18 Sep 2012 07:55:16 +0000 (00:55 -0700)]
folly: Range: implement find_first_of and optimize qfind(Range, char)
Summary:
implement ##find_first_of## and optimize ##Range.find(char)##
============================================================================
folly/test/RangeBenchmark.cpp relative time/iter iters/s
============================================================================
LongFindSingleCharDirect 2.76ms 362.63
LongFindSingleCharRange 15.88% 17.37ms 57.58
ShortFindSingleCharDirect 53.41fs 18.72T
ShortFindSingleCharRange 0.00% 29.22ns 34.22M
============================================================================
Test Plan:
- added new tests
- ran all folly tests
fbconfig -r folly/ && mkk runtests_opt
Reviewed By: tudorb@fb.com
FB internal diff:
D576720
Rajat Goel [Mon, 17 Sep 2012 19:20:14 +0000 (12:20 -0700)]
Syntactic sugar
Summary: This makes code easy to read for eyes used to unique/shared ptrs.
Test Plan: unit-tests
Reviewed By: delong.j@fb.com
FB internal diff:
D575997
John Fremlin VII [Mon, 17 Sep 2012 18:14:26 +0000 (11:14 -0700)]
add pop_back to arrays
Summary: Add a pop_back() function to dynamic arrays.
Test Plan: - used it
Reviewed By: delong.j@fb.com
FB internal diff:
D569440
Anton Likhtarov [Fri, 14 Sep 2012 00:01:29 +0000 (17:01 -0700)]
folly/SmallLocks.h compiler warning
Summary: Couldn't get an HPHP extension to compile against this
Test Plan: compiled HPHP including folly/dynamic.h
Reviewed By: delong.j@fb.com
FB internal diff:
D574364
Tudor Bosman [Mon, 10 Sep 2012 20:45:25 +0000 (13:45 -0700)]
Verbosify exception tracer dumps
Test Plan: by hand
Reviewed By: philipp@fb.com
FB internal diff:
D570233
Fan Guo [Mon, 10 Sep 2012 17:08:46 +0000 (10:08 -0700)]
support -nan in conversion
Summary:
Folly supports -inf and nan but not -nan, instead it raised unexpected exceptions not handled in the upstream.
This diff is separated out from
D569816 -- Diff1.
Test Plan: std::isnan(folly::to<double>(-nan))
Reviewed By: tudorb@fb.com
FB internal diff:
D569939
Tudor Bosman [Sat, 8 Sep 2012 04:46:58 +0000 (21:46 -0700)]
Fix InpuByteStreamSplitter in debug mode.
Test Plan: stream_test, exception_tracer_test
Reviewed By: soren@fb.com
FB internal diff:
D569476
Philip Pronin [Sat, 1 Sep 2012 08:03:07 +0000 (01:03 -0700)]
Histogram function to write tab-separated values.
Summary: Export histograms in a tab-separated format.
Test Plan: Used it.
Reviewed By: lucian@fb.com
Tudor Bosman [Sat, 1 Sep 2012 02:39:12 +0000 (19:39 -0700)]
Minor huge pages library changes
Summary:
Moved to separate library instead of :io
Got rid of the mode argument when creating files -- umask is your friend
Separated getSize interface from create
Added FsUtil.h for some fs::path operations
Switched some interfaces to fs::path instead of string / StringPiece
Canonicalize paths so we don't care whether paths are absolute or
relative
Test Plan: fs_util_test, by hand
Reviewed By: philipp@fb.com
FB internal diff:
D564465
Tudor Bosman [Wed, 22 Aug 2012 00:16:02 +0000 (17:16 -0700)]
Huge page library.
Test Plan: by hand
Reviewed By: lucian@fb.com
FB internal diff:
D555164
Lucian Grijincu [Thu, 30 Aug 2012 03:19:19 +0000 (20:19 -0700)]
fix build on: define own version of ALLOCM_LG_ALIGN
Summary:
On --platform=gcc-4.6.2-glibc-2.13-fb the build would fail because
fbcode/third-party/gcc-4.6.2-glibc-2.13-fb/libgcc/libgcc-4.6.2/
b4e37bb/include/c++/4.6.2/bits/basic_fbstring_malloc.h
defines it's own version of ALLOCM_SUCCESS & co., but not ALLOCM_LG_ALIGN :(
The '#ifdef ALLOCM_SUCCESS' check in 'folly/Malloc.h' would pass even
though we didn't include jemalloc.
Test Plan: build it
Reviewed By: philipp@fb.com
FB internal diff:
D562273
Tudor Bosman [Thu, 30 Aug 2012 02:20:04 +0000 (19:20 -0700)]
Unbreak build.
Summary: I'll pretend you reviewed this.
Test Plan: build
Reviewed By: simpkins@fb.com
FB internal diff:
D562255
Tudor Bosman [Thu, 30 Aug 2012 01:20:27 +0000 (18:20 -0700)]
Move exception tracer library to folly/experimental
Summary:
This change is mostly mechanical (moving files, changing include paths,
etc). I made some changes to TARGETS to make it easier for the library
to be linked in (instead of LD_PRELOADed)
Test Plan: by hand
Reviewed By: simpkins@fb.com
FB internal diff:
D562196
Lucian Grijincu [Wed, 29 Aug 2012 23:59:36 +0000 (16:59 -0700)]
Add ALLOCM_LG_ALIGN to Malloc.h
Test Plan: .
Reviewed By: soren@fb.com
Tudor Bosman [Wed, 2 May 2012 23:42:35 +0000 (16:42 -0700)]
Stream operations: file access, iteration, splitting.
Summary: Intended to complement and replace strings::byLine.
Test Plan: stream_test
Reviewed By: delong.j@fb.com
FB internal diff:
D463341
Tudor Bosman [Sun, 26 Aug 2012 18:04:37 +0000 (11:04 -0700)]
Fix fedora / ubuntu build
Test Plan: yes
Reviewed By: andrewjcg@fb.com
FB internal diff:
D558628
Adam Simpkins [Wed, 22 Aug 2012 03:56:09 +0000 (20:56 -0700)]
folly: simplify the stats avgHelper() function
Summary:
When the input type is a long double, perform division using long
double. In all other cases, divide using double precision.
Also fix the EXPECT_EQ() usage in the test case.
Test Plan: fbconfig -r common/stats folly && fbmake runtests
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D555433
Adam Simpkins [Mon, 20 Aug 2012 21:58:25 +0000 (14:58 -0700)]
BucketedTimeSeries: fix type converison issues computing avg()
Summary:
D527040 had a bug in the code to compute the average: it incorrectly
performed unsigned division when ValueType was a signed integer type.
As a result, the average was reported incorrectly for stats with
negative values.
This makes the average code more intelligent when handling type
conversions: if the caller wants a floating point value, or if the input
type is floating point, floating point division is always returned.
Otherwise, if the input is a signed type, signed integer division is
performed. Otherwise, unsigned integer division is performed.
Test Plan: beholdunittests
Reviewed By: lars@fb.com
FB internal diff:
D553583
Adam Simpkins [Sun, 19 Aug 2012 19:29:15 +0000 (12:29 -0700)]
folly: add a simple benchmark for Histogram::addValue()
Summary:
I wrote this an an example for the BENCHMARK_NAMED_PARAM() comments in
D527040, and figured I might as well check it in as a real benchmark.
Test Plan:
Here's the output:
======================================================================
folly/test/HistogramBenchmark.cpp relative time/iter iters/s
======================================================================
addValue(0_to_100) 15.43ns 64.81M
addValue(0_to_1000) 15.45ns 64.70M
addValue(5k_to_20k) 15.46ns 64.67M
======================================================================
Reviewed By: rajat@fb.com
FB internal diff:
D552875
Shuai Ding [Thu, 16 Aug 2012 22:00:15 +0000 (15:00 -0700)]
change shared_ptr<>* to raw pointer
Summary:
change shared_ptr<>* to raw pointer in
forwardIndex in RTIndex. This saves 16 bytes per
forward list (decrease from 88 to 72) and translates
to about 4-5% memory saving for RTIndex in ff tier.
Test Plan: unit test
Reviewed By: xliux@fb.com
FB internal diff:
D551191
Adam Simpkins [Sun, 22 Jul 2012 05:40:46 +0000 (22:40 -0700)]
Add BucketedTimeSeries to folly
Summary:
Add the BucketedTimeSeries class to folly. This tracks time series
counter data, using a circular buffer of buckets to expire old data
points as time progresses.
It supports querying the overall sum, count, average, and rate for the
duration of the time series, as well as estimating these values for
portions of the overall duration.
Test Plan: Unit tests included.
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D527040
Philip Pronin [Fri, 17 Aug 2012 23:21:26 +0000 (16:21 -0700)]
one more simple folly::join optimization
Summary:
Before:
_bin/folly/test/string_test --benchmark --bm_regex=join --bm_min_usec=
1000000
============================================================================
folly/test/StringTest.cpp relative time/iter iters/s
============================================================================
joinCharStr 3.59us 278.29K
joinStrStr 4.44us 225.09K
joinInt 10.55us 94.76K
============================================================================
And after:
_bin/folly/test/string_test --benchmark --bm_regex=join --bm_min_usec=
1000000
============================================================================
folly/test/StringTest.cpp relative time/iter iters/s
============================================================================
joinCharStr 3.61us 277.01K
joinStrStr 3.77us 264.97K
joinInt 9.92us 100.81K
============================================================================
Test Plan: unittests, benchmark
Reviewed By: tudorb@fb.com
FB internal diff:
D552364
Tudor Bosman [Wed, 15 Aug 2012 21:26:31 +0000 (14:26 -0700)]
Add Bob Jenkins's SpookyHash to folly.
Summary:
http://burtleburtle.net/bob/hash/spooky.html
The code is in the public domain, so republishing it as such is fine.
The code needed modifications (the test was designed to run on Windows
only; removed unhygienic typedefs; moved to folly::hash namespace)
Also updated Makefile.am files.
Test Plan: test added
Reviewed By: soren@fb.com
FB internal diff:
D549572
Michael Curtiss [Fri, 17 Aug 2012 05:31:16 +0000 (22:31 -0700)]
isPowTwo
Summary:
a la Hacker's Delight.
Also, fix nonsensical nextPowTwo benchmark.
Test Plan: Added test and benchmark.
Reviewed By: tudorb@fb.com
FB internal diff:
D551510
Philip Pronin [Wed, 15 Aug 2012 20:52:40 +0000 (13:52 -0700)]
one more folly::join overload
Summary: To allow codemod changes.
Test Plan: ran test
Reviewed By: tudorb@fb.com
FB internal diff:
D549516
Lee Hwa [Mon, 6 Aug 2012 20:42:49 +0000 (13:42 -0700)]
Task #906853: Implement ThreadLocalServiceData and reduce lock contentions during channel counter update
Summary:
Cache the counter updates on thread local data structures and aggregate/publish
the data from a separate thread periodically. The ThreadLocalServiceData is
implemented on top of the TLStats data structures.
I am plannig to deploy a private build to production tomorrow to test this
change in production, but figured it might be better to send the diff out first
and get code review feedbacks at the same time.
Test Plan: Run and pass unit tests. Run end-to-end testings on sandbox. (TBD)
Deploy a private build to a production server and make sure the thrift call
latency is reduced.
Reviewed By: xin@fb.com
FB internal diff:
D540239
Sergey Doroshenko [Tue, 14 Aug 2012 19:54:49 +0000 (12:54 -0700)]
folly: randomNumberSeed should be random wrt multiple threads
Summary:
Right now, it relies on process id rather than on thread id. Thus, it can
return the same seed when called from multiple threads over really short
period of time, and these unlucky threads will end up with identical "random"
sequences.
Test Plan: newly added test fails against trunk, passes against changes in the diff
Reviewed By: tudorb@fb.com
FB internal diff:
D548129
Philip Pronin [Wed, 15 Aug 2012 01:55:35 +0000 (18:55 -0700)]
strings join
Summary: The same interface as ##facebook::strings::join##, but few times faster.
Test Plan: folly/test/StringTest.cpp
Reviewed By: tudorb@fb.com
FB internal diff:
D548863
Nicholas Ormrod [Tue, 14 Aug 2012 23:11:03 +0000 (16:11 -0700)]
Added dynamic::convertTo<Type> method
Summary: convert a dynamic to a well-typed object
Test Plan: run test file
Reviewed By: delong.j@fb.com
FB internal diff:
D517021
Nitay Joffe [Tue, 14 Aug 2012 00:36:55 +0000 (17:36 -0700)]
Add exception_tracer
Summary: script to wrap gateway to run it with exception tracer.
Test Plan: deploy
Reviewed By: rajat@fb.com
FB internal diff:
D548147
Adam Simpkins [Sat, 11 Aug 2012 02:15:08 +0000 (19:15 -0700)]
folly: print nice time suffixes in benchmark output
Summary: Print the times using "ms" for milliseconds, "us" for microseconds, etc.
Test Plan:
$ ./_bin/folly/test/benchmark_test
======================================================================
folly/test/BenchmarkTest.cpp relative time/iter iters/s
======================================================================
bmFun 3.36ns 298.01M
bmRepeatedFun 1.76ns 569.38M
----------------------------------------------------------------------
gun 1.70ns 589.82M
----------------------------------------------------------------------
baselinevector 3.08us 324.87K
bmVector 13.64% 22.56us 44.32K
----------------------------------------------------------------------
superslow 1.00s 999.82m
======================================================================
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D546209
Andrei Alexandrescu [Sat, 11 Aug 2012 19:08:51 +0000 (12:08 -0700)]
Fix debug build.
Summary: Only tested in release mode, sigh. Fixed a failing asserd.
Test Plan: tested in dbg mode
Reviewed By: tudorb@fb.com
FB internal diff:
D546318
Andrei Alexandrescu [Fri, 10 Aug 2012 16:50:15 +0000 (09:50 -0700)]
Faster repeated append (particularly for short strings)
Summary:
https://phabricator.fb.com/
D544159 reveals a large performance gap between
fbstring and std::string for repeated appends of short strings, which I
consider a relatively urgent matter (as much of our code uses such patterns).
This diff attempts to fix the issue in a principled manner by first appending
the first character with exponential reallocation, after which the rest of the
characters are appended normally.
With the proposed fix the benchmarks are much faster than the previous fbstring
and also than std::string (numbers to follow in comments).
Test Plan: unittested and benchmarked
Reviewed By: soren@fb.com
FB internal diff:
D545416
Tudor Bosman [Fri, 10 Aug 2012 21:22:05 +0000 (14:22 -0700)]
sizeof works just as well as numeric_limits<T>::digits
Summary: ... and is shorter and more readable
Test Plan: folly/test
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D545774
Nicholas Ormrod [Fri, 10 Aug 2012 21:04:43 +0000 (14:04 -0700)]
Increased std::vector compatibility of fbvector
Summary:
fbvector was not accepting move_iterators for
InputIterator-templated construct, assign, and insert. The root cause
was the check '(b_ <= &*first && &*first < e_)', used to check if the
assignment was from internal data. This addressof check does not compile
with rvalue-references, and causes the first iterator to be dereferenced
more than once; both against the contract of std::vector. The standard
allows for undefined behaviour in the self-iterator case, so there are
no contractual barriers to removing this check.
Test Plan:
run fbvector test and benchmark. An fbgs for 'assign' turns
up few matches; the seem to be normal use-case. Test fbvector assign
with self-iterators in order (i.e. fbv.assign(fbv.begin(), fbv.end()));
this seems to work fine.
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D535012
Tom Jackson [Wed, 8 Aug 2012 23:47:01 +0000 (16:47 -0700)]
Removing broken specialization of std::hash<std::tuple>
Summary: ^
Test Plan: Unit tests
Reviewed By: delong.j@fb.com
FB internal diff:
D543586
Jeremy Lilley [Thu, 9 Aug 2012 16:57:22 +0000 (09:57 -0700)]
Add "short append" benchmark to fbstring benchmark suite.
Summary:
Appending many small strings to fbstring appears much slower (~3x) vs.
std::string. Adding benchmark case to illustrate.
[If this isn't wanted, I can revert]
Test Plan: This is a benchmark.
Reviewed By: soren@fb.com
FB internal diff:
D544159
Andrew Gallagher [Thu, 9 Aug 2012 01:11:40 +0000 (18:11 -0700)]
folly::dynamic: comment about std::vector const-iter erase issue
Test Plan: none
Reviewed By: delong.j@fb.com
FB internal diff:
D543196
Tudor Bosman [Wed, 8 Aug 2012 21:13:44 +0000 (14:13 -0700)]
Unbreak folly build on fedora / ubuntu
Test Plan: built
Reviewed By: delong.j@fb.com
FB internal diff:
D543320
Tudor Bosman [Wed, 8 Aug 2012 21:32:27 +0000 (14:32 -0700)]
Use gcc builtins instead of library functions for ffs*
Summary:
because, shockingly, glibc doesn't divert to the gcc builtins which are
inlined and fast
Test Plan: folly/test
Reviewed By: sding@fb.com
FB internal diff:
D543363
Tudor Bosman [Wed, 8 Aug 2012 21:08:03 +0000 (14:08 -0700)]
Remove 1 instruction from popcount
Summary:
by removing the unnecessary constraint that the input and output be in
the same register (copypasta from https://phabricator.fb.com/
D542718)
Test Plan: folly/test
Reviewed By: soren@fb.com
FB internal diff:
D543310
Tudor Bosman [Wed, 8 Aug 2012 17:39:47 +0000 (10:39 -0700)]
Detect popcnt instruction at runtime, use it if available.
Summary:
If compiled for a popcnt-supporting target (-march=corei7, for example),
use __builtin_popcount, as it's presumably inlined. Otherwise, detect
on startup (in the same way as glibc dispatches to one of the many
flavors of memcpy): GCC allows us to add a resolver function which the
dynamic loader will call on startup to resolve a function to one of
various alternatives; we check (using the cpuid instruction) whether
popcnt is supported, and use it if available.
Test Plan: tests added
Reviewed By: soren@fb.com
FB internal diff:
D542977
Andrew Gallagher [Wed, 8 Aug 2012 19:05:18 +0000 (12:05 -0700)]
folly::dynamic: use std::vector instead of folly::fbvector
Summary:
It appears that std::unordered_map is no longer relocatable in
gcc-4.7. Use std::vector instead, until fbvector supports non-
relocatable types.
Test Plan: Built and ran facebar tests under gcc-4.7. Also ran folly unittests.
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D543099
Xiaoyang Gao [Tue, 7 Aug 2012 01:53:02 +0000 (18:53 -0700)]
Add operator== and operator!= to folly::StlAllocator
Summary: Add operator== and operator!= to folly::StlAllocator, which are required by some other libraries.
Test Plan: Tested by running with recursive_wrapper in boost::variant, and unit tests in folly/test.
Reviewed By: delong.j@fb.com
FB internal diff:
D541237
James Sharpe [Mon, 6 Aug 2012 15:29:27 +0000 (16:29 +0100)]
Remove unused logging header
Test Plan: Compiled.
Reviewed By: andrewjcg@fb.com
FB internal diff:
D541226
Daniel Wu [Wed, 4 Jul 2012 15:34:49 +0000 (08:34 -0700)]
Minor typo in comments
Summary: github pull #11
Test Plan: None.
Reviewed By: andrewjcg@fb.com
FB internal diff:
D541230
Andrew Gallagher [Wed, 8 Aug 2012 05:49:39 +0000 (22:49 -0700)]
fbstring: mute uninitialized warnings in fbstring code
Summary:
fbstring generates some apparently false positive uninitialized warnings
under gcc-4.7.1. This diff disables the '-Wuninitialized' flag for
fbstring.
Test Plan: build
Reviewed By: ldemailly@fb.com
FB internal diff:
D542722
Tudor Bosman [Fri, 3 Aug 2012 01:23:23 +0000 (18:23 -0700)]
Add inverses for jenkins_rev_mix32, twang_mix64
Test Plan: test added
Reviewed By: soren@fb.com
FB internal diff:
D538703
Abhijeet Joglekar [Wed, 1 Aug 2012 17:36:14 +0000 (10:36 -0700)]
Allow capacity and length to be different for user buffers
Summary:
Currently, takeOwnership lets a user pass in a data buffer and wraps it in an
IOBuffer. However, the capacity and length of the user buffer are required to
be same.
Added a new API to allow buffers where the capacity and length can be different.
Users of existing API should not be affected.
Test Plan:
1) Added new test case to IOBufTest that checks buffers with length
different from capacity
2) Run existing IOBuf test cases to verify no regressions
Reviewed By: brianp@fb.com
FB internal diff:
D536575
Wei Wu [Mon, 23 Jul 2012 16:20:41 +0000 (09:20 -0700)]
Make AtomicHashMap support move constructible types
Summary: modified AtomicHashArray and AtomicHashMap to support move constructible types
Test Plan: tested with fbcode/folly/test/AtomicHashArrayTest.cpp and fbcode/folly/test/AtomicHashMapTest.cpp
Reviewed By: philipp@fb.com
FB internal diff:
D527270
Rajat Goel [Thu, 26 Jul 2012 20:24:32 +0000 (13:24 -0700)]
Moving some more benchmarks to fbcode benchmark system
Summary: The format benchmark that was ported some time back has few data points to show - http://fburl.com/
3545876
Test Plan: fbmake --log-to-rfe runbenchmarks_opt
Reviewed By: andrei.alexandrescu@fb.com
FB internal diff:
D524306
Tudor Bosman [Sun, 22 Jul 2012 02:13:21 +0000 (19:13 -0700)]
Add IEC binary unit prefixes
Summary: KiB, MiB, GiB, TiB, etc
Test Plan: by hand in a program using them
Reviewed By: philipp@fb.com
FB internal diff:
D527001
Nathan Bronson [Thu, 19 Jul 2012 20:33:29 +0000 (13:33 -0700)]
add sched_yield in RWTicketSpinLock
Summary:
This diff makes RWTicketSpinLock eventually start calling
sched_yield() during shared and aggressive exclusive lock access, to
avoid pathologies that can arise when the number of threads far
exceeds the number of actual cores.
Test Plan:
1. unit tests
2. benchmark w/o + w/ diff
Reviewed By: nathan@fb.com
FB internal diff:
D524897
Jordan DeLong [Sat, 14 Jul 2012 22:57:32 +0000 (15:57 -0700)]
Add folly::applyTuple utility
Summary: Applies a function to a std::tuple of arguments.
Test Plan: Unit test.
Reviewed By: tjackson@fb.com
FB internal diff:
D520190
Tudor Bosman [Sat, 14 Jul 2012 05:56:13 +0000 (22:56 -0700)]
Fix an issue in IOBufQueue::move
Summary: That's all.
Test Plan: .
Reviewed By: philipp@fb.com
FB internal diff:
D520116
Tudor Bosman [Mon, 16 Jul 2012 03:13:19 +0000 (20:13 -0700)]
Add wrapper macros for "final" and "override"
Summary:
... which are supported in gcc 4.7, but not 4.6, and they enable useful
optimizations. As long as we're planning to support both 4.6 and 4.7 in
our code base, we should write code using these macros.
Test Plan:
test added, compiled with both 4.6 and 4.7, verified the
assertion in the test comment by looking at dissassembly output in the
4.7 version
Reviewed By: delong.j@fb.com
FB internal diff:
D520343