Sarang Masti [Mon, 29 Dec 2014 22:39:03 +0000 (14:39 -0800)]
Allow conversion from a type T to itself
Summary: same as title
Test Plan: - fbconfig -r folly && fbmake runtests
Reviewed By: andrei.alexandrescu@fb.com
Subscribers: folly-diffs@
FB internal diff:
D1754577
Signature: t1:
1754577:
1419618119:
4c1a59cd19b23de9a9f6574341944e5e80530d62
Dave Watson [Mon, 29 Dec 2014 20:18:39 +0000 (12:18 -0800)]
SharedThreadPool unittest
Summary: Add a test to check that the accept IOPool can be the same as the IO worker thread pool
Test Plan: unittest
Reviewed By: jsedgwick@fb.com
Subscribers: doug, fugalh, njormrod, folly-diffs@
FB internal diff:
D1710628
Signature: t1:
1710628:
1417469919:
6d81a9426b61e9f1b804114f895ed541e547110f
Keith Adams [Mon, 29 Dec 2014 18:46:01 +0000 (10:46 -0800)]
Add convenience functions to serialize to / deserialize from string
Summary: kma asked
Test Plan: tests added
Reviewed By: andrei.bajenov@fb.com
Subscribers: alandau, bmatheny, mshneer, folly-diffs@
FB internal diff:
D1756731
Signature: t1:
1756731:
1419442987:
afdccce166ef1f1e609d8894ea587915f6fea8e7
Dave Watson [Mon, 29 Dec 2014 18:40:59 +0000 (10:40 -0800)]
Bump version to 20:0
Dave Watson [Mon, 29 Dec 2014 17:58:29 +0000 (09:58 -0800)]
Kill fbthrift dep
Summary:
(almost) all the necessary code has been moved to folly. A couple last functions in SSLUtils, moved them to SSLContext
I think this is enough so that open source mcrouter doesn't need an fbthrift dep anymore - although stuff in mcrouter/facebook still uses thrift.
Test Plan:
fbconfig -r mcrouter; fbmake runtests_dev
contbuild will probably show some other projects to fix up for SSLUtils
Reviewed By: alikhtarov@fb.com
Subscribers: doug, ps, alandau, bmatheny, alikhtarov, mshneer, folly-diffs@
FB internal diff:
D1747133
Signature: t1:
1747133:
1418946064:
1c30a60e43f017213e5514d462f267f91761abbe
Hans Fugal [Sat, 27 Dec 2014 00:55:29 +0000 (16:55 -0800)]
Fix case of ThreadWheelTimekeeper.cpp in Makefile.am
Test Plan: jenkins
Reviewed By: ajitb@fb.com
Subscribers: exa, folly-diffs@
FB internal diff:
D1758358
Tasks:
5880251
Signature: t1:
1758358:
1419640865:
c9e9ea5922a602c44042c358777067e025800e6e
Hans Fugal [Sat, 27 Dec 2014 00:27:44 +0000 (16:27 -0800)]
(wangle) fix Makefile.am
Summary: Add some forgotten header and cpp files to `Makefile.am` for OSS build of folly.
Test Plan: jenkins
Reviewed By: ajitb@fb.com
Subscribers: exa, folly-diffs@
FB internal diff:
D1758318
Tasks:
5880251
Signature: t1:
1758318:
1419639812:
47f527fdb2b3d2c49e7557b4176c6ab2478091ae
Hans Fugal [Fri, 26 Dec 2014 23:18:11 +0000 (15:18 -0800)]
(wangle) Timeouts basic
Summary:
Add basic timeout functionality. This adds `futures::sleep` which makes an async Future that finishes after the given duration, and `Future::get` which blocks on the result and takes an optional timeout.
Introducing the folly::wangle::futures namespace (soon to be just folly::futures) which will hold our wangle utility functions, the things that live in the Future object in Twitter's scala code. We'll probably move when* and wait-ish methods in here too, and perhaps alias makeFuture-ish methods too, though James has me mostly convinced not to deprecate them at the folly::wangle level (because they're basically Future constructors and Future lives at folly::wangle)
`Future::delayed` after Twitter's helper of the same name
Test Plan: new and old unit tests
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, fugalh, exa, folly-diffs@
FB internal diff:
D1748894
Tasks:
4548494
Signature: t1:
1748894:
1419363496:
1f4a62ec8455989c1fcce845695ace1d01c101c8
Hans Fugal [Fri, 26 Dec 2014 23:18:08 +0000 (15:18 -0800)]
HHWheelTimer::cancelAll
Summary: Provide a way to massacre outstanding timers.
Test Plan: new test, and using in wangle (different diff)
Reviewed By: davejwatson@fb.com
Subscribers: jsedgwick, exa, folly-diffs@
FB internal diff:
D1753866
Tasks:
4548494
Signature: t1:
1753866:
1419361846:
58ff6ca4d01b0d546495b032b454c8bf0fdb0277
Nathan Bronson [Wed, 24 Dec 2014 04:46:39 +0000 (20:46 -0800)]
make futexWaitUntil tolerant of invalid time_point-s
Summary:
futexWaitUntil could generate an invalid timespec when presented
with a time_point from before the epoch, which resulted in an EINVAL from
the futex syscall. Debug builds crashed on this unexpected return value,
while release builds soldiered on. This path happened to be exercised
by the unit test. This diff fixes the unintentional deadline overflow
in the test, adds explicit testing of overflow behavior, and makes
futexWaitUntil handle invalid time_points in a sensible manner.
Test Plan:
1. new unit tests
2. fbmake runtests_dbg
Reviewed By: mssarang@fb.com
Subscribers: strager, njormrod, folly-diffs@
FB internal diff:
D1747972
Tasks:
5853949
Signature: t1:
1747972:
1419382193:
862c193a13428d96acb33c85f962f59203661f40
Tao Chen [Tue, 23 Dec 2014 22:49:20 +0000 (14:49 -0800)]
Revert "folly: AsyncServerSocket::getAddress: prefer IPv6"
Summary: This reverts commit
fc83e983e2376bccc80dc4b21890e3a41dbc211f.
Test Plan: none
Reviewed By: lucian@fb.com, robot9@fb.com
Subscribers: ps, bmatheny, folly-diffs@
FB internal diff:
D1756753
Tasks:
5883894,
5886688
Signature: t1:
1756753:
1419374764:
977160379cfa49530babb38022b9d4cc80573a7d
Viswanath Sivakumar [Tue, 23 Dec 2014 20:16:48 +0000 (12:16 -0800)]
Allow unregistering connect callback in AsyncSocket
Summary:
Sometimes when the socket is destroyed from a destructor, we wouldn't
want further callbacks on shutdown. We can unregister the readCallback_
by calling setReadCB(nullptr), but if the state is CONNECTING, we can
still get connectErr() callback. I found an ASAN trace (https://phabricator.fb.com/P18837265)
that turned out to be because of this inability to cancel this callback.
This provides a way to unregister the connect callback as well.
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: afrind@fb.com
Subscribers: folly-diffs@
FB internal diff:
D1751778
Tasks:
5852935
Signature: t1:
1751778:
1419363638:
26967c2d4fc5819e4d65ae706d217a954dfd784f
Chip Turner [Tue, 23 Dec 2014 18:40:17 +0000 (10:40 -0800)]
Fix incorrect 'test' statement in unit test
Summary:
The 'test' command uses one equal sign for string equality, not
two. bash apparently is okay with two, but zsh isn't, causing this test
to pass if your shell was bash and fail if it was zsh. The test now
passes with bash, bash in sh mode, zsh, and even dash.
Test Plan:
runtests, also, these pass (zsh failed before):
SHELL=/bin/bash _build/dbg/folly/test/subprocess_test
SHELL=/bin/sh _build/dbg/folly/test/subprocess_test
SHELL=/bin/zsh _build/dbg/folly/test/subprocess_test
SHELL=/bin/dash _build/dbg/folly/test/subprocess_test
Reviewed By: njormrod@fb.com
Subscribers: lins, anca, folly-diffs@
FB internal diff:
D1756090
Signature: t1:
1756090:
1419360674:
8576e61a6e0ee102612c5eae0e1fbd79cc397bfa
Chip Turner [Tue, 23 Dec 2014 18:19:39 +0000 (10:19 -0800)]
Fix Dwarf path handling to fix broken test
Summary:
Simplify the logic slightly to better handle joining paths.
This makes DwarfTest.cpp pass.
Test Plan: runtests
Reviewed By: njormrod@fb.com
Subscribers: lins, anca, folly-diffs@
FB internal diff:
D1756036
Tasks:
5871014
Signature: t1:
1756036:
1419359254:
123cc508b8836ea0b1485abe361b1c158538aa08
Mike Kolupaev [Tue, 23 Dec 2014 12:28:32 +0000 (04:28 -0800)]
folly::AtomicHashMap: fixed race between erase() and find()
Summary: advancePastEmpty() was called for all created iterators. It only makes sense for begin(). For find() it's harmful: find() shouldn't return an iterator to the next element if the key was removed. I suspect that the same race condition was possible for insert(), but I haven't tried to reproduce it.
Test Plan: Added a test for it. It fails without these changes.
Reviewed By: delong.j@fb.com
Subscribers: folly-diffs@, lovro
FB internal diff:
D1751280
Tasks:
5841499
Signature: t1:
1751280:
1419107193:
71311ff68d92d0a4dcf1941dacdfdc23c25255cc
Lucian Grijincu [Tue, 23 Dec 2014 10:19:34 +0000 (02:19 -0800)]
folly: AsyncServerSocket::getAddress: prefer IPv6
Summary: Can't connect from ipv6-only cluster to ipv4/ipv6 service which uses different ports.
Test Plan:
```
./fastcopy_server --dir . &
# netstat -atnlp | grep LISTEN | grep fastc
tcp 0 0 0.0.0.0:65478 0.0.0.0:* LISTEN 9348/./fastcopy_ser
tcp 0 0 :::52793 :::* LISTEN 9348/./fastcopy_ser
```
Reviewed By: philipp@fb.com, sdoroshenko@fb.com
Subscribers: ps, bmatheny, folly-diffs@
FB internal diff:
D1752846
Tasks:
5868818
Signature: t1:
1752846:
1419043494:
7cc0646882249f17258ade5ce7ae5619b13148a0
Andrei Alexandrescu [Wed, 17 Dec 2014 21:16:07 +0000 (13:16 -0800)]
Bring fbstring::operator+ to date with C++11
Summary: Some overloads, particularly with rvalue references, were missing. Also this fixes https://our.intern.facebook.com/intern/tasks/?t=
5849579
Test Plan: unittests
Reviewed By: simpkins@fb.com
Subscribers: trunkagent, las, net-systems@, njormrod, folly-diffs@
FB internal diff:
D1746319
Tasks:
5849579
Signature: t1:
1746319:
1418875228:
febb965cf52710a5e76b7c1cce5aec601086ad90
Sarang Masti [Sat, 20 Dec 2014 00:44:37 +0000 (16:44 -0800)]
Allow conversion from StringPiece to StringPiece
Summary: Allow conversion from folly::StringPiece to folly::StringPiece
Test Plan: - fbconfig -r folly && fbmake runtests
Reviewed By: mpawlowski@fb.com
Subscribers: folly-diffs@
FB internal diff:
D1752609
Signature: t1:
1752609:
1419037172:
04846f658901306b53fb60c9eafbdf0f4d4d7005
Kai Wang [Sat, 20 Dec 2014 06:24:54 +0000 (22:24 -0800)]
Print linux TID while crashing
Summary:
For servers using GLOG, all thread ID are get from gettid system call. So it
is very useful if we print this ID so during debugging I can find the log
of crashing thread.
I'm not sure who should review this diff. Just found you guys from previous
diffs touched this file :)
Test Plan:
See the crash log.
*** Aborted at
1419029404 (Unix time, try 'date -d @
1419029404') ***
*** Signal 11 (SIGSEGV) (0x18) received by PID 18852 (pthread TID 0x7f52a1fff700) (linux TID 27908), stack trace: ***
Reviewed By: tudorb@fb.com
Subscribers: seanc, folly-diffs@
FB internal diff:
D1752301
Signature: t1:
1752301:
1419032887:
e43c2ace6914e54812149a8b8e84eaffaf42a09c
Andrew Gallagher [Sat, 20 Dec 2014 05:56:23 +0000 (21:56 -0800)]
Various Dwarf::Path fixes
Summary:
- Allow both `baseDir` and `subDir` to be empty. This can happen
if DW_AT_comp_dir is `.` and gets simplified to the empty string.
(The DWARF standard doesn't appear to disallow relative dirs here,
but I couldn't find anthing definitive).
- Fix `./` prefix stripping to avoid making paths like `.///hello` absolute.
- Fix `/` suffix stripping to avoid making the root dir reference (`/`) empty.
- Do `baseDir` and `subDir` swapping after simplification.
Test Plan: Added unittests.
Reviewed By: njormrod@fb.com
Subscribers: trunkagent, sdwilsh, folly-diffs@
FB internal diff:
D1747978
Signature: t1:
1747978:
1419014942:
87f14cb31b8c19b524d7a95b14d63cf5661a8634
Tudor Bosman [Sat, 20 Dec 2014 02:33:14 +0000 (18:33 -0800)]
Add comment explaining that RWTicketSpinLock<..., true> is not reentrant
Test Plan: no, it's a comment
Reviewed By: zanfur@fb.com
Subscribers: folly-diffs@
FB internal diff:
D1752850
Tasks:
5823969
Signature: t1:
1752850:
1419043661:
673c68c0daad28b3fde9709e767b528b0dec8ad1
Mike Kolupaev [Fri, 19 Dec 2014 20:17:41 +0000 (12:17 -0800)]
Fixed folly::AtomicHashMap::iterator not advancing past empty submaps
Summary: A potential "real life" scenario that maybe can hit this bug is if we erase almost all elements and then iterate over the whole map.
Test Plan: Added a test for it.
Reviewed By: mwilliams@fb.com
Subscribers: folly-diffs@, lovro
FB internal diff:
D1751455
Tasks:
5866368
Signature: t1:
1751455:
1419016611:
b44c41d348f54397844460cb38002ad0d9704972
Giuseppe Ottaviano [Fri, 19 Dec 2014 17:50:57 +0000 (09:50 -0800)]
Remove unnecessary constraint from Range subpiece constructor
Summary:
D1746899 enforced the constraint (previously in a comment) on the
constructor `Range(const Range&, size_t, size_t)` that `Iter` is a
`const char*`. There is however no reason for this constraint.
This patch generalizes and simplifies the constructor, and since it
has the same semantics as `subpiece`, the latter is implemented in
terms of the constructor.
Test Plan:
fbconfig -r folly && fbmake runtests_opt
Reviewed By: soren@fb.com
Subscribers: trunkagent, folly-diffs@
FB internal diff:
D1747958
Signature: t1:
1747958:
1418930360:
fcd6beeda34e64ec8a34b9491a57674ae2265596
Dave Watson [Fri, 19 Dec 2014 17:24:38 +0000 (09:24 -0800)]
Move TAsyncTransport to folly as AsyncTransportWrapper
Summary:
This temporary class will be useful to cut dependencies on thrift
while (roughly) maintaining the old interface.
Fixup various test classes that depend on the interface. Next diff will be to cut fbthrift dep in proxygen/mcrouter
Test Plan: unit tests, jenkins
Reviewed By: hans@fb.com
Subscribers: fbcode-common-diffs@, andrewcox, alandau, bmatheny, alikhtarov, mshneer, trunkagent, doug, njormrod, folly-diffs@, davejwatson
FB internal diff:
D1696094
Signature: t1:
1696094:
1418762312:
6028815cce2845ac5f8e754132a038fabf5fd957
James Sedgwick [Fri, 19 Dec 2014 00:11:50 +0000 (16:11 -0800)]
onError callbacks
Summary:
We've discussed these a bunch and here they are. I stole a bunch of Hannes' magic from https://www.facebook.com/groups/
715931878455430/permalink/
772854686096482/ to make this easier
Test Plan: added lots of unit tests
Reviewed By: hans@fb.com
Subscribers: fugalh, folly-diffs@, hannesr
FB internal diff:
D1748418
Signature: t1:
1748418:
1418945606:
e14c7d6a31245e222bc6a0d259d0e2b9ddd5a830
JoelMarcey [Thu, 18 Dec 2014 20:29:54 +0000 (12:29 -0800)]
Bump version to 19:0
James Sedgwick [Thu, 18 Dec 2014 20:20:26 +0000 (12:20 -0800)]
codemod: merge folly/wangle and folly/experimental/wangle
Summary:
Various TARGETS could definitely use some rearranging but I'd rather wait until we're cut over to the new repo
Test Plan: wait for contbuild
Reviewed By: davejwatson@fb.com
Subscribers: ptarjan, joelm, trunkagent, hphp-diffs@, ps, fbcode-common-diffs@, fugalh, alandau, bmatheny, everstore-dev@, mwa, jgehring, fuegen, mshneer, folly-diffs@, hannesr
FB internal diff:
D1740858
Tasks:
5802833
Signature: t1:
1740858:
1418752569:
4d7d9c5b955e4d9fab4b322cf08a3d285e3db7ce
Dave Watson [Thu, 18 Dec 2014 19:13:55 +0000 (11:13 -0800)]
fix make test
Summary: autotools is fun. rule name has to match
Test Plan: No contbuild for this, only a jenkins hourly build: https://ci-builds.fb.com/job/folly/
Reviewed By: noamler@fb.com
Subscribers: doug, net-systems@, folly-diffs@
FB internal diff:
D1747221
Signature: t1:
1747221:
1418929497:
a29320b5e21a657fe7e0221d2bea8b332626627b
Dave Watson [Thu, 18 Dec 2014 17:48:05 +0000 (09:48 -0800)]
remove Cpp2WorkerFactory
Summary:
In preparation for a global IOThreadPoolExecutor - we can't override the workerFactory if we are using a global one.
Instead, add a new getEventBases() to IOTHreadPoolExecutro and just run code on each eventBase. For shutdown, explicitly add a stop(), instead of doing the work after loop() as exited
Cpp2Worker required minor changes to be able to use EventBaseManager's eventbase vs. their own
Test Plan: fbconfig -r thrift/lib/cpp2; fbmake runtests
Reviewed By: jsedgwick@fb.com
Subscribers: trunkagent, andrewcox, doug, fugalh, alandau, bmatheny, mshneer, folly-diffs@
FB internal diff:
D1734795
Signature: t1:
1734795:
1418759367:
b45f419e5cbc482a64a5873d9e00e3bcb071db5a
Giuseppe Ottaviano [Thu, 18 Dec 2014 02:19:00 +0000 (18:19 -0800)]
Disable implicit conversions from std::string for non-char* Range
Summary:
`Range<Iter>` has an implicit constructors from strings for any
`Iter`, however such constructors are invalid (compilation fails)
if `Iter` is not `[const] char *`.
This can be an issue for overload resolution: for example
struct IsString {
bool operator()(folly::Range<int*>) { return false; }
bool operator()(folly::StringPiece) { return true; }
};
IsString()(std::string());
fails to compile because the overload is ambiguous, even if the
conversion to `ByteRange` is invalid.
This patch disables all the invalid constructors from
`[const] char*`, `std::string`, and `fbstring`.
Test Plan:
fbconfig -r folly && fbmake runtests_opt
Reviewed By: philipp@fb.com
Subscribers: folly-diffs@
FB internal diff:
D1746899
Signature: t1:
1746899:
1418868361:
50784c4993df0bd96eeb62c09c659d5e53964d9b
James Sedgwick [Wed, 17 Dec 2014 23:57:16 +0000 (15:57 -0800)]
stabilize IOFuturePool test
Summary: see attached task. concurrency is hard.
Test Plan: stress ran the hell out of it, induced failures before, can't after
Reviewed By: hans@fb.com
Subscribers: fugalh, folly-diffs@
FB internal diff:
D1746879
Tasks:
5589311
Signature: t1:
1746879:
1418860467:
0ec3f51a398eee8a836532770682a4c58758ce93
Adam Simpkins [Wed, 17 Dec 2014 18:31:50 +0000 (10:31 -0800)]
fix the open source build
Summary: Fix the path to detail/SpinLockImpl.h in Makefile.am
Test Plan: Will confirm the Jenkins builds pass for fbthrift and proxygen.
Reviewed By: davejwatson@fb.com
Subscribers: doug, net-systems@, exa, folly-diffs@
FB internal diff:
D1745795
Signature: t1:
1745795:
1418841636:
8a861275a62b018a8181541c7d70ba0890d7129f
Laurent Demailly [Wed, 17 Dec 2014 01:56:51 +0000 (17:56 -0800)]
fix bug with elf object left with file open upon error causing Entered fatal signal handler recursively later
Summary: fix bug with elf object left with file open upon error causing Entered fatal signal handler recursively later
Test Plan: run publisher at the limit
Reviewed By: tudorb@fb.com
Subscribers: trunkagent, chip, folly-diffs@
FB internal diff:
D1743052
Tasks:
5752190
Signature: t1:
1743052:
1418780889:
ad2ee0e6999cf417c2b9fd1ef6bc82d2086774a1
Adam Simpkins [Fri, 12 Dec 2014 02:22:37 +0000 (18:22 -0800)]
SpinLock improvements
Summary:
This makes several improvements to the SpinLock code:
- Add a SpinLock implementation using pthread_spinlock_t. On non-x86_64
platforms this is preferred over the pthread_mutex_t implementation
when available.
- For the pthread implementations, throw std::system_error on error,
rather than completely aborting the program using glog's CHECK()
macros.
- Update the pthread_mutex_t implementation to call
pthread_mutex_destroy() on destruction.
- Always unit test all implementations that can be compiled on the
current build platform, even though only a single implementation will
be selected as folly::SpinLock. This way x86_64 builds will still
unit test the pthread-based implementations.
Test Plan: Ran the unit tests.
Reviewed By: seanc@fb.com
Subscribers: trunkagent, doug, net-systems@, exa, folly-diffs@
FB internal diff:
D1735770
Signature: t1:
1735770:
1418445953:
b238aa8fb835a8d55e6e98e20c4615ae1938b98f
Adam Simpkins [Thu, 11 Dec 2014 21:40:27 +0000 (13:40 -0800)]
remove PortableSpinLock.h
Summary:
Remove the PortableSpinLock header file now that all call sites have
been migrated to the new SpinLock name.
Test Plan: Built and ran unit tests for folly, thrift, and proxygen.
Reviewed By: seanc@fb.com
Subscribers: trunkagent, doug, net-systems@, exa, folly-diffs@
FB internal diff:
D1734685
Signature: t1:
1734685:
1418335405:
e834f64d7282393e942a1de3638f4cf67410eaab
Adam Simpkins [Thu, 11 Dec 2014 21:23:05 +0000 (13:23 -0800)]
update call sites to use SpinLock
Summary:
Update call sites to use the new folly::SpinLock name, instead of
folly::io::PortableSpinLock.
Test Plan: Built and ran the folly unit tests.
Reviewed By: davejwatson@fb.com
Subscribers: doug, net-systems@, exa, folly-diffs@
FB internal diff:
D1734647
Signature: t1:
1734647:
1418334925:
1bbcffccd06907224de2a102f8d4bfbe1bd62fd1
Adam Simpkins [Thu, 11 Dec 2014 20:23:34 +0000 (12:23 -0800)]
rename io::PortableSpinLock to SpinLock
Summary:
folly::io::PortableSpinLock seems generally useful outside of the io
code. This moves it into the base folly namespace, and renames it from
PortableSpinLock to just SpinLock.
For most users, the main difference between MicroSpinLock and SpinLock
is that SpinLock provides a constructor that does the right thing, while
MicroSpinLock has to be explicitly initialized.
Test Plan:
Added some new unit tests, and tested both the MicroSpinLock and
pthread_spinlock_t implementations. I didn't test the Mac OS version,
although that code remains unchanged.
Reviewed By: seanc@fb.com
Subscribers: trunkagent, doug, net-systems@, exa, folly-diffs@
FB internal diff:
D1734632
Signature: t1:
1734632:
1418394033:
99f6fbe73b485a1d631a2ef7d1b39ea6f49ecb0b
Andrii Grynenko [Tue, 16 Dec 2014 04:36:43 +0000 (20:36 -0800)]
get_fast/get_weak_fast API for folly::Singleton
Summary: This adds API which makes folly::Singleton as performant as Meyers/static-object singletons.
Test Plan:
unit test + benchmark
============================================================================
folly/experimental/test/SingletonTest.cpp relative time/iter iters/s
============================================================================
NormalSingleton 333.32ps 3.00G
MeyersSingleton 100.00% 333.33ps 3.00G
FollySingletonSlow 0.35% 94.36ns 10.60M
FollySingletonFast 99.43% 335.24ps 2.98G
FollySingletonFastWeak 0.62% 53.74ns 18.61M
============================================================================
Reviewed By: alikhtarov@fb.com
Subscribers: trunkagent, folly-diffs@
FB internal diff:
D1741961
Signature: t1:
1741961:
1418765462:
d9806f1bf5275bfbe2c4c53a41b735bda93753fe
Cameron Pickett [Tue, 16 Dec 2014 21:02:26 +0000 (13:02 -0800)]
Add specific multi-bind to AsyncServerSocket
Summary:
Add a bind api similar to binding by port across all interfaces.
However, this bind will only attempt to bind sockets to the supplied
IP addresses. I'd like to add this to aid in moving TURN to IPv6.
TURN will use two specified addresses, one for IPv4, and one for IPv6, to
handle incoming connections from clients. In order to avoid duplicating
workers, we'd like to take advantage of the multi-socket implementation
of AsyncServerSocket. However, we don't want to bind to all interfaces,
especially for port 443.
Test Plan:
Plan to test by adapting TurnTcpListener to use this new API. See that
1. using one address still works as expected,
2. using zero addesses will cause exception
3. using multiple addresses works as expected
Will write unit tests if needed
Reviewed By: davejwatson@fb.com
Subscribers: hannesr, trunkagent, net-systems@, folly-diffs@, naizhi
FB internal diff:
D1729442
Tasks:
3633642
Signature: t1:
1729442:
1418752467:
22a60da4ec9009ea0b7fe28a8a436a179e0449aa
Nathan Bronson [Tue, 16 Dec 2014 18:34:47 +0000 (10:34 -0800)]
fix Futex when steady_clock and system_clock precisions differ
Summary:
To handle the strange relationship between steady_clock and
system_clock (on some platforms these represent only one type, on some
platforms they are separate) Futex::futexWaitUntil converts the deadline
to a duration and back. On Xcode 6 system_clock is measured in
microseconds and steady_clock in nanoseconds, resulting in a compilation
failure. This diff fixes it.
Test Plan:
1. compile snippet manually using Xcode
2. new unit test that causes the same implicit conversion failure in a slightly different way
Reviewed By: mssarang@fb.com
Subscribers: trunkagent, folly-diffs@
FB internal diff:
D1740903
Tasks:
5831196
Signature: t1:
1740903:
1418754770:
32c999abf1dc87415ffebf45083a903abbded9f2
James Sedgwick [Tue, 16 Dec 2014 18:26:24 +0000 (10:26 -0800)]
codemod: folly/wangle/ -> folly/wangle/futures
Summary: Last thing before moving experimental/wangle here. Once everything is in the same directory I'm probably going to consolidate experimental/wangle/concurrent with the executors in this directory into wangle/executors/. And probably rename some of these targets. For now, a dumb move is enough.
Test Plan: waiting for contbuild
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, lars, ruibalp, hero-diffs@, zeus-diffs@, vikas, danielg, mcduff, cold-storage-diffs@, unicorn-diffs@, ldbrandy, targeting-diff-backend@, netego-diffs@, fugalh, adamsyta, atlas2-eng@, alandau, bmatheny, adityab, everstore-dev@, zhuohuang, sweeney, mwa, jgehring, smarlow, akr, bnitka, jcoens, luk, zhguo, jying, apodsiadlo, alikhtarov, fuegen, dzhulgakov, mshneer, folly-diffs@, wch, tingy, hannesr
FB internal diff:
D1740327
Tasks:
5802833
Signature: t1:
1740327:
1418752541:
82d7486293b0a12938730ae66d480c120aded4dc
Andrii Grynenko [Fri, 5 Dec 2014 22:17:50 +0000 (14:17 -0800)]
Remove locking when getting ptr to Singleton
Summary: This removes one layer on locking on the fast path, when ptr to singleton object is read from SingletonEntry.
Test Plan:
unit test
Before:
============================================================================
folly/experimental/test/SingletonTest.cpp relative time/iter iters/s
============================================================================
NormalSingleton 335.26ps 2.98G
MeyersSingleton 99.50% 336.96ps 2.97G
FollySingleton 0.28% 120.64ns 8.29M
============================================================================
After:
============================================================================
folly/experimental/test/SingletonTest.cpp relative time/iter iters/s
============================================================================
NormalSingleton 336.76ps 2.97G
MeyersSingleton 99.91% 337.07ps 2.97G
FollySingleton 0.36% 92.69ns 10.79M
============================================================================
Reviewed By: alikhtarov@fb.com
Subscribers: trunkagent, folly-diffs@
FB internal diff:
D1727604
Signature: t1:
1727604:
1418701171:
1728b516191a8ec4439e981d78634370b4bcf7a1
James Sedgwick [Mon, 15 Dec 2014 21:09:47 +0000 (13:09 -0800)]
global io executor
Summary:
This is something we've talked about for a while. It's also an alternative to the mechanism in
D1714645.
If we like it, I'll do something similar for a global cpu executor. That functionality should probably just be
baked into Executor itself instead of a separate subclass, which is why the IOExecutor stuff is in Executor.h/.cpp,
because it'll be pretty similar. The main exception is that for getCPUExecutor() you could return a default global
InlineExecutor instead of exploding as in getIOExecutor()
Test Plan: wangle unit, will start plumbing this into the services in #
5003045 if we like it
Reviewed By: davejwatson@fb.com
Subscribers: hannesr, trunkagent, fugalh, alandau, mshneer, folly-diffs@, bmatheny
FB internal diff:
D1727894
Tasks:
5002442
Signature: t1:
1727894:
1418344077:
9e54088a6acb3f78e53011a32fd1dfe8b3214c1d
James Sedgwick [Mon, 15 Dec 2014 19:43:32 +0000 (11:43 -0800)]
move wangle/Executor.h to folly/ root
Summary:
this removes the dep EventBase has on wangle as we prepare to split off wangle
also changes namespace from folly::wangle to folly
Test Plan: just a couple of codemods so waiting for contbuild
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, zeus-diffs@, nli, cold-storage-diffs@, unicorn-diffs@, targeting-diff-backend@, hannesr, vighnesh, fugalh, alandau, bmatheny, adityab, zhuohuang, luk, darshan, gunjan, hdoshi, dzhulgakov, alihussains, panin, ves, mshneer, folly-diffs@, lins, nimishshah
FB internal diff:
D1737376
Tasks:
5802833
Signature: t1:
1737376:
1418423430:
82d219c34fcc50218c380a17435e5880e53db6bd
Chip Turner [Thu, 11 Dec 2014 06:14:09 +0000 (22:14 -0800)]
Improve performance of stringPrintf and related functions
Summary:
It turned out at least one optimization we were doing for
stringPrintf (using the tail of the input buffer) was causing a
performance degradation in some cases -- if the string was already
pre-sized, our resize() call would end up memset'ing the tail. In some
instances, this could cause significant performance penalties, such as
when multiple stringAppendf calls were made.
So, this diff removes the "optimization" around using the tail of the input
buffer and instead uses a standalone stack buffer. If vsnprintf deems
that buffer too small, a heap buffer is instead used.
As there is no std::string method that resizes the string to fill the
underlying buffer without setting the values to a default, and as it is
not legal to write past the end of the data buffer (even if capacity()
says there is enough), let's just abandon that optimization. It turns
out this doesn't have a major performance loss for most cases since,
with this diff, most small strings will fit on-stack and then hopefully
in the string's tail anyway.
Test Plan: runtests
Reviewed By: simpkins@fb.com
Subscribers: trunkagent, net-systems@, lins, anca, folly-diffs@
FB internal diff:
D1733774
Tasks:
5735468
Signature: t1:
1733774:
1418323943:
ec47007c9756aca6cf0466bce92722ac4c7e89b2
Andrew Chalfant [Fri, 12 Dec 2014 02:18:26 +0000 (18:18 -0800)]
Add convenience method for folly::join
Summary: While folly has join methods that return a string (and thus don't need a string referenced passed), it does not support this idiom with iterators. This diff adds support for calls like folly::join("/", itr.begin(), itr.end() - 1).
Test Plan: Unit test
Reviewed By: njormrod@fb.com
Subscribers: philipp, trunkagent, njormrod, folly-diffs@, yfeldblum
FB internal diff:
D1702892
Tasks:
5691439
Signature: t1:
1702892:
1418344206:
9c1736f5d8e41be1df71a415e3803fe846b387b7
Dave Watson [Tue, 25 Nov 2014 16:13:37 +0000 (08:13 -0800)]
AsyncUDPSocket
Summary:
Move AsyncUDPSocket to folly.
There is also one under realtime/voip/async that looks functionaly equivalent? I think this one is only used in gangplank currently.
Test Plan: contbuild
Reviewed By: hans@fb.com
Subscribers: trunkagent, doug, alandau, bmatheny, njormrod, mshneer, folly-diffs@
FB internal diff:
D1710675
Tasks:
5788116
Signature: t1:
1710675:
1417477000:
9aebb466757554a5fa49d7c36cb504b4d8711b68
Chip Turner [Thu, 11 Dec 2014 05:00:02 +0000 (21:00 -0800)]
Improve benchmarking around stringPrintf functions
Summary:
Before optimizing this code, it is better to measure different
aspects of it to ensure improvements are worth it and don'tintroduce
other regressions.
This adds a new benchmark as well as parameterizes an old one.
Test Plan: run it
Reviewed By: lovro@fb.com
Subscribers: lins, anca, folly-diffs@
FB internal diff:
D1733760
Tasks:
5735468
Signature: t1:
1733760:
1418313479:
9f572d5a4cf014bd266d91d0f7a75407d1514f65
Dave Watson [Thu, 11 Dec 2014 16:02:41 +0000 (08:02 -0800)]
Bump version to 18:0
James Sedgwick [Thu, 11 Dec 2014 15:41:44 +0000 (07:41 -0800)]
formatting nits in Executor.h
Summary:
sorry this was bothering me
also remove extra include
Test Plan: OK
Reviewed By: davejwatson@fb.com
Subscribers: fugalh, folly-diffs@
FB internal diff:
D1733723
Signature: t1:
1733723:
1418312030:
088eb084f69e2bd7703724464b2f3e71abc2607a
James Sedgwick [Thu, 11 Dec 2014 03:23:24 +0000 (19:23 -0800)]
future_* callbacks in ThreadManager thread
Summary:
This is a squashed diff consisting of the following approved diffs
D1714007
D1714645
D1715686
D1719963
D1720725
D1721838
D1721856
D1721920
D1721956
D1724910
D1728289
- execute future_* handlers in TM thread
- call async thrift clients from any thread, not just EB thread
- store a request's EventBase in the RequestContext for easier client management
* this last one will change in favor of using a global IO executor but this should still land as an intermediate step. See
D1727894
Test Plan: see component diff test plans. otherwise, contbuild.
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, ruibalp, targeting-diff-backend@, hannesr, alandau, prometheus-diffs@, jeremyfein, mshneer, folly-diffs@, bmatheny, tingy
FB internal diff:
D1732289
Tasks:
5003045,
5645785
Signature: t1:
1732289:
1418253508:
30b724a91717cf7fe21029e0a1eaf239db1650be
Nicholas Ormrod [Thu, 11 Dec 2014 01:41:17 +0000 (17:41 -0800)]
ConcurrentSkipList Bug
Summary:
Bug reported by Yan Lin (not a facebook employee) through @robbert.
@philipp and @jdelong: you are the only two remaining facebookers to have
made non-trivial changes to this code.
Description of bug: layer 0 is 1->4, and we're looking for 3. We pass
over 4, and see that 1 is less than 3 in the for loop. Now a race
condition: another thread inserts 2, so layer 0 is now 1->2->3. Then,
since ht==0, we return pred->skip(0), which is now 2 instead of 4.
Why this is bad: it really breaks the lower_bound function (lower_bound
calls findNode calls findNodeDownRight), since it returns an element
that is lesser.
This patch doesn't change the behavior of the code in the normal case;
it just recycles previously-computed values so that this race condition
doesn't crash and burn.
Patch based off of Yan Lin's in-email suggestion.
Test Plan:
fbconfig -r folly && fbmake runtests
Reviewed By: philipp@fb.com
Subscribers: sdwilsh, folly-diffs@, jdelong, robbert, philipp
FB internal diff:
D1732434
Signature: t1:
1732434:
1418260198:
8c707435825cfa2a1093b681e066f320193e98f2
Brian Watling [Wed, 10 Dec 2014 22:39:53 +0000 (14:39 -0800)]
Fix clang compilation
Summary: Fix shadowed variable name
Test Plan: compile
Reviewed By: mmandal@fb.com
Subscribers: fugalh, mathieubaudet, folly-diffs@
FB internal diff:
D1732033
Signature: t1:
1732033:
1418250864:
d460fea376ac93c05b86977629b95dac60b8b916
Dave Watson [Wed, 10 Dec 2014 22:34:00 +0000 (14:34 -0800)]
Only test multi accept if reuse port supported
Summary: Some contbuild machines aren't on 3.10 yet.
Test Plan:
fbconfig folly/experimental/wangle/bootstrap; fbmake runtests
tested on 3.2 and 3.10
Reviewed By: jsedgwick@fb.com
Subscribers: doug, fugalh, folly-diffs@
FB internal diff:
D1732040
Tasks:
5800250
Signature: t1:
1732040:
1418250452:
a3203ab5769494594f2bf0b50f1c62052ddeb24c
Sean Cannella [Wed, 10 Dec 2014 21:15:55 +0000 (13:15 -0800)]
Support -Wsign-compare compilation
Summary:
Due to how Conv.h uses the less_than template inside
not-actually-static static ifs clang still ends up validating generated
code inside a FOLLY_RANGE_CHECK which is never executed due to the
templated types. This code however still generates -Wsign-compare issues
so suppress that in order to allow includers to use this flag.
A simple example will illustrate this:
uint64_t foo = 1;
int bar = folly::to<int>(foo);
Test Plan: fbmake runtests
Reviewed By: meyering@fb.com, njormrod@fb.com
Subscribers: trunkagent, folly-diffs@, bmatheny, ranjeeth, subodh, kmdent, fma, shikong, pgriess, jdelong
FB internal diff:
D1731411
Signature: t1:
1731411:
1418243200:
ed1f34a1485669c9cb18f9f6029aca70e498953c
Brian Watling [Wed, 10 Dec 2014 19:04:28 +0000 (11:04 -0800)]
Use an IO thread pool executor by default
Summary:
Remove member variable name shadowing
Facebook: This diff adds a default executor for async requests which do not specify one. This ensures we don't run request callbacks on the event threads (which in turn ensures we don't make blocking tcc calls from the event threads)
Test Plan: fbconfig tao/client; fbmake runtests
Reviewed By: hannesr@fb.com
Subscribers: hannesr, fugalh, zhuohuang, folly-diffs@, tao-eng@
FB internal diff:
D1731078
Tasks:
5752037
Signature: t1:
1731078:
1418237801:
5b9bbe74c288292d5e7c7e6a38e67be864627d89
Adrian Hamza [Wed, 10 Dec 2014 17:43:25 +0000 (09:43 -0800)]
Add mock singleton injection support to folly/experimental Singleton (t5653148).
Summary: Add mock singleton injection support to folly/experimental Singleton (t5653148).
Test Plan:
Added unit tests for MockSingleton, all unit tests passed.
Validated this works for my scenario.
Reviewed By: andrii@fb.com
Subscribers: trunkagent, njormrod, folly-diffs@
FB internal diff:
D1690946
Tasks:
5653148
Signature: t1:
1690946:
1418080331:
948d7051a5e5a2653dc393c123f188c56072c6db
davejwatson [Wed, 10 Dec 2014 15:58:27 +0000 (07:58 -0800)]
Multi accept
Summary: Use acceptor pool instead of current thread for accepts. Use reuse_port option to support multiple threads
Test Plan: Updated unittests
Reviewed By: hans@fb.com
Subscribers: doug, fugalh, njormrod, folly-diffs@
FB internal diff:
D1710619
Tasks:
5788110
Signature: t1:
1710619:
1417477350:
eee5063186e582ef74c4802b8149563af029b3de
Philip Pronin [Tue, 9 Dec 2014 21:43:33 +0000 (13:43 -0800)]
fix Cursor::skipAtMostSlow bug introduced in
D1724111
Test Plan: fbconfig -r folly/io/test && fbmake runtests_opt -j32
Reviewed By: viswanath@fb.com
Subscribers: folly-diffs@
FB internal diff:
D1728927
Tasks:
5788015
Signature: t1:
1728927:
1418161580:
9ed66412e35c62486a56e19aa9bf119863b5f1a1
Blame Revision:
D1724111
Dave Watson [Mon, 1 Dec 2014 20:52:35 +0000 (12:52 -0800)]
Add REUSEPORT option to AsyncServerSocket
Summary:
Adds a reuse port option to AsyncServerSocket, so multiple sockets can bind to the same accept port. Allows for multiple accept threads, so accepts can be greater, since there is no longer a single accept lock.
reuse port option is ifdefd, since this wouldn't build with some of the older kernels otherwise.
Postponed overnight
Test Plan: Builds. Used in an upcoming diff.
Reviewed By: jsedgwick@fb.com
Subscribers: benj, trunkagent, doug, njormrod, folly-diffs@
FB internal diff:
D1710600
Tasks:
5488516,
5788110
Signature: t1:
1710600:
1418066966:
627e03857f9b5ff831f2922add08e90cc525c95c
Sean Cannella [Tue, 9 Dec 2014 00:25:48 +0000 (16:25 -0800)]
TransportInfo size mismatches
Summary:
The code that uses TransportInfo assumes these byte counts are
compatible with size_t so make them so.
Test Plan: compiled
Reviewed By: davejwatson@fb.com
Subscribers: fugalh, bmatheny, njormrod, folly-diffs@, benyluo, ranjeeth, fma, kmdent
FB internal diff:
D1725026
Tasks:
5538843
Signature: t1:
1725026:
1418061933:
b4072ca926e792716776ddc00d79db9376510859
Dave Watson [Mon, 24 Nov 2014 20:36:30 +0000 (12:36 -0800)]
set internal thread factory
Summary: Fix up a TODO
Test Plan: ?? Should I bother with a test?
Reviewed By: jsedgwick@fb.com
Subscribers: doug, fugalh, njormrod, folly-diffs@
FB internal diff:
D1710633
Signature: t1:
1710633:
1417469890:
9e8513140bae79da384c9d5418d4ea0840efbe6c
Dave Watson [Mon, 8 Dec 2014 18:25:14 +0000 (10:25 -0800)]
Set a better default for maxReadsPerEvent
Summary:
0 (infinity) seems like a bad default for this. Just found a 2~5% latency win in thrift by setting this to something more reasonable. Any reason not to set a better default globally?
Since this is already on for mcrouter/proxygen/thrift, the biggest change would probably be service router
tests postponed longer than 20 minutes
Test Plan:
thrift perf test, multifeed canary
Canary URL: https://our.intern.facebook.com/intern/feedtools/mycanary?id=davejwatson_20141208-102635_local.1418063194_d201eceec04e5e097a6dffb645a424d502db8742_
Reviewed By: afrind@fb.com
Subscribers: doug, net-systems@, njormrod, folly-diffs@, jsedgwick, haijunz, andrewcox, alandau, fugalh
FB internal diff:
D1725142
Signature: t1:
1725142:
1418066284:
c2e1cbf27b0c7a98cf2395f369683bbcce4cdce4
Dave Watson [Mon, 1 Dec 2014 20:55:49 +0000 (12:55 -0800)]
Bump up log level
Summary: This log was getting annoying in tests, bump up the logging level
Test Plan: contbuild
Reviewed By: afrind@fb.com
Subscribers: trunkagent, doug, fugalh, njormrod, folly-diffs@
FB internal diff:
D1710608
Signature: t1:
1710608:
1417468546:
770dfb7201ff6477b349c01e638f704a2ef1b7ce
Shijin Kong [Mon, 8 Dec 2014 18:03:30 +0000 (10:03 -0800)]
fix local variable shadow
Summary:
D1720014 line 183 in HHWheelTimer.h broke proxygen/facebook/httpclient clang build:
./folly/io/async/HHWheelTimer.h:183:17: error: declaration shadows a local variable [-Werror,-Wshadow]
Wrapper(F fn) : fn_(std::move(fn)) {}
^
./folly/io/async/HHWheelTimer.h:181:28: note: previous declaration is here
void scheduleTimeoutFn(F fn, std::chrono::milliseconds timeout) {
I renamed the `fn` in `Wrapper` to `f`.
Test Plan: pass
Reviewed By: seanc@fb.com
Subscribers: njormrod, folly-diffs@, subodh, seanc, kmdent, fma
FB internal diff:
D1724835
Signature: t1:
1724835:
1418052896:
d9a72230d4fd1a4a734a33142966fe796f4fd362
Philip Pronin [Sun, 7 Dec 2014 00:49:11 +0000 (16:49 -0800)]
improve io::Cursor read() performance for small sizeof(T)
Summary:
I just found that gcc (4.8.2) failed to unroll the loop in
`pullAtMost()`, so it didn't replace `memcpy` with a simple load
for small `len`.
Test Plan:
fbconfig -r folly/io/test thrift/lib/cpp2/test && fbmake runtests_opt -j32
Ran unicorn-specific thrift deserialization benchmark from
D1724070, verified 50% improvement in `SearchRequest` deserialization
performance.
`thrift/lib/cpp2/test/ProtocolBench` results:
```
|---- before -----| |---- after -----|
================================================================================================
thrift/lib/cpp2/test/ProtocolBench.cpp relative time/iter iters/s time/iter iters/s
================================================================================================
BinaryProtocol_read_Empty 21.72ns 46.04M 17.58ns 56.89M
BinaryProtocol_read_SmallInt 43.03ns 23.24M 23.64ns 42.30M
BinaryProtocol_read_BigInt 43.72ns 22.87M 22.03ns 45.38M
BinaryProtocol_read_SmallString 88.57ns 11.29M 47.01ns 21.27M
BinaryProtocol_read_BigString 365.76ns 2.73M 323.58ns 3.09M
BinaryProtocol_read_BigBinary 207.78ns 4.81M 169.09ns 5.91M
BinaryProtocol_read_LargeBinary 187.81ns 5.32M 172.09ns 5.81M
BinaryProtocol_read_Mixed 161.18ns 6.20M 68.41ns 14.62M
BinaryProtocol_read_SmallListInt 177.32ns 5.64M 96.91ns 10.32M
BinaryProtocol_read_BigListInt 77.03us 12.98K 15.88us 62.97K
BinaryProtocol_read_BigListMixed 1.79ms 557.79 923.99us 1.08K
BinaryProtocol_read_LargeListMixed 195.01ms 5.13 103.78ms 9.64
================================================================================================
```
Reviewed By: soren@fb.com
Subscribers: alandau, bmatheny, mshneer, trunkagent, njormrod, folly-diffs@
FB internal diff:
D1724111
Tasks:
5770136
Signature: t1:
1724111:
1417977810:
b7d643d0c819a0bbac77fa0048206153929e50a8
Sean Cannella [Sat, 6 Dec 2014 01:14:52 +0000 (17:14 -0800)]
Make ThreadLocal identifiers consistent
Summary:
Implicitly bouncing between size_t and int for identifiers
causes problems when building on 64-bit iOS. Fix this.
Test Plan: fbmake runtests
Reviewed By: meyering@fb.com, njormrod@fb.com
Subscribers: trunkagent, njormrod, folly-diffs@, fma, kmdent, shikong, pgriess
FB internal diff:
D1722061
Signature: t1:
1722061:
1417819039:
8e3938cf8d4d241551ed3dd3978c1b11f57398c5
Andrii Grynenko [Fri, 5 Dec 2014 22:28:30 +0000 (14:28 -0800)]
Revert "Revert "Make folly::Singleton's destruction happen earlier""
Summary:
This reverts commit
7871df125fc1fbe5d8030a41e21b8241b25d4e62.
As explained in t5763478, I don't see good reason for a revert.
Also the errors under question shouldn't show up after
D1720841.
Test Plan: revert-hammer
Reviewed By: stepan@fb.com
Subscribers: njormrod, folly-diffs@
FB internal diff:
D1722928
Tasks:
5763478
Signature: t1:
1722928:
1417818663:
1fe402d14c0cf389fb3611355db270c5f2c33738
Hans Fugal [Fri, 5 Dec 2014 17:46:56 +0000 (09:46 -0800)]
More logging in HHWheelTimer::scheduleTimeoutFn
Summary:
This was supposed to be an update to
D1720014 but I screwed up with arc.
Test Plan: run the test by hand and see the output
Reviewed By: jsedgwick@fb.com
Subscribers: exa, njormrod, folly-diffs@
FB internal diff:
D1721951
Signature: t1:
1721951:
1417801009:
72a27ec2ca473a996785ff9cae48bd51a43d9045
Hans Fugal [Fri, 5 Dec 2014 17:33:35 +0000 (09:33 -0800)]
s/makeFuture().via/via/
Summary:
codemod to replace all `makeFuture().via` with just `via`.
Test Plan: contbuild
Reviewed By: jsedgwick@fb.com
Subscribers: trunkagent, zeus-diffs@, targeting-diff-backend@, abirchall, fugalh, msk, exa, benj, njormrod, folly-diffs@
FB internal diff:
D1715876
Signature: t1:
1715876:
1417712302:
b882916d394f90caa23bd73fa68b8f786af649e3
Hans Fugal [Fri, 5 Dec 2014 17:33:30 +0000 (09:33 -0800)]
via and activate/deactivate chaining
Summary:
Better support and test chaining of `via` and `activate`/`deactivate`.
The real problem is that without the ref qualifier a multiple chain of lvalue references can end up with a destructed object being referenced after.
https://akrzemi1.wordpress.com/2014/06/02/ref-qualifiers/
Test Plan:
This is mostly new tests that would fail and now pass.
I think maybe the tests are a bit weak, it would be good to find a way to ensure we aren't going to see the access-after-free bugs in these tests.
Reviewed By: jsedgwick@fb.com
Subscribers: trunkagent, fugalh, exa, njormrod, folly-diffs@
FB internal diff:
D1714873
Tasks:
5489801
Signature: t1:
1714873:
1417628538:
9e610c5ba5e0a22c19a11d53aa956be45d585058
Hans Fugal [Fri, 5 Dec 2014 17:33:25 +0000 (09:33 -0800)]
Remove Later
Summary: dalek-exterminate
Test Plan:
Moved `Later` tests to `via` tests.
fbgs
contbuild
Reviewed By: jsedgwick@fb.com
Subscribers: fbcode-common-diffs@, adityab, lins, trunkagent, fugalh, exa, njormrod, folly-diffs@, hannesr
FB internal diff:
D1714862
Tasks:
5409538
Signature: t1:
1714862:
1417621949:
f63f49e1093a021170d2346e8e673db042d2bc56
Hans Fugal [Fri, 5 Dec 2014 17:29:04 +0000 (09:29 -0800)]
HHWheelTimer::scheduleTimeoutFn
Summary:
cpp11ify
I'm gonna use this for Wangle timeouts.
Test Plan:
new unit test
_bin/folly/io/async/test/HHWheelTimerTest
Reviewed By: jsedgwick@fb.com
Subscribers: trunkagent, exa, njormrod, folly-diffs@
FB internal diff:
D1720014
Tasks:
5002969
Signature: t1:
1720014:
1417732753:
ddcad431b6c305c9ba27f6b9e3454ab158c13f4b
Bartosz Nitka [Fri, 5 Dec 2014 13:30:32 +0000 (05:30 -0800)]
Revert "Make folly::Singleton's destruction happen earlier"
Summary: This reverts commit
6584412293cc5b9aad2004e99d550e3478df1e5d.
Test Plan: thisisrevert
Reviewed By: smarlow@fb.com
Subscribers: njormrod, folly-diffs@
FB internal diff:
D1721739
Signature: t1:
1721739:
1417786147:
01aaaf50b679da7942b2a30ad039eb0ac1031430
Nicholas Ormrod [Thu, 4 Dec 2014 22:08:43 +0000 (14:08 -0800)]
include gflags header in SSLSessionCacheManager
Summary:
SSLSessionCacheManager uses glfags but doesn't include it. This
breaks on some systems.
Test Plan: fbconfig -r folly && fbmake runtests
Reviewed By: robbert@fb.com
Subscribers: trunkagent, sdwilsh, fugalh, ssl-diffs@, njormrod, folly-diffs@
FB internal diff:
D1716997
Signature: t1:
1716997:
1417720032:
548c2ad8f54e41d42585c331324f2065733595c1
Andrii Grynenko [Thu, 4 Dec 2014 01:26:45 +0000 (17:26 -0800)]
Make folly::Singleton's destruction happen earlier
Summary: Schedule destroyInstances to be executed via atexit in registrationComplete. registrationComplete is called from main(), so this makes sure folly::Singleton's will be destoyed before all singletons constructed before main() (which should cover all third-party libraries' singletons).
Test Plan: unit test
Reviewed By: chip@fb.com
Subscribers: trunkagent, njormrod, folly-diffs@
FB internal diff:
D1717963
Tasks:
5666654
Signature: t1:
1717963:
1417659478:
c50c271d1786be75499565f6ab9c0a1a6f6f347d
Andre Pinto [Thu, 4 Dec 2014 19:52:53 +0000 (11:52 -0800)]
Correct getsockopt call made by AsyncSocket
Summary:
The getsockopt's last parameter (optlen) is a value-result parameter
and AsyncSocket::getSockOpt was passing a value as argument.
Test Plan: Unit tests
Reviewed By: alikhtarov@fb.com
Subscribers: trunkagent, njormrod, folly-diffs@
FB internal diff:
D1717463
Tasks:
4867290
Signature: t1:
1717463:
1417664828:
6c7a74ff31725121f892ce1adba2653e70728192
James Sedgwick [Thu, 4 Dec 2014 18:29:24 +0000 (10:29 -0800)]
add consumeUntilDrained API to NotificationQueue::Consumer
Summary:
... and employ it in EventBase's destructor to stop leaking memory from unexecuted NotificationQueue-variety runInEventBaseThread() callbacks
in addition to the attached task, this should also fix the root cause of the already-worked-around #
5564342
Test Plan:
test no longer leaks.* on the other hand, IOThreadPoolExecutor::stop() no longer actually stops, it joins. I added comments to stop() in headers indicating that it should be treated as best-effort.
* hilariously, this actually isn't true - there's a new leak of a thread local inside the io pool because callbacks can outlive the pool now. i'll leave a full explanation for the upcoming patch.
Reviewed By: davejwatson@fb.com
Subscribers: alandau, bmatheny, mshneer, trunkagent, fugalh, njormrod, folly-diffs@
FB internal diff:
D1682860
Tasks:
5336655
Signature: t1:
1682860:
1416347774:
ac5f31fb72373992f425c93ac284a0cd27608db4
Hans Fugal [Wed, 3 Dec 2014 17:38:47 +0000 (09:38 -0800)]
Replace Later in tcc
Summary:
s/`sendAsyncLater`/`sendAsyncVia`/ and change it to return a cold future with equivalent semantics. We have to call `via` twice in the implementation—once to gate the result and again to make sure the caller will get a future that executes in that executor's context also.
NB this is a slight semantic change - if the executor is, say, a threadpool then now it will go through the threadpool queue (and maybe execute in two different threads) whereas before the whole later chain would execute in the same thread. I don't *think* this is a problem, but something to think about.
Test Plan:
stuff we fbconfig'd builds
contbuild
unit tests
thinking really hard
Reviewed By: hannesr@fb.com
Subscribers: trunkagent, fbcode-common-diffs@, net-systems@, ldbrandy, hannesr, fugalh, zhuohuang, exa, watashi, smarlow, akr, bnitka, jcoens, darshan, njormrod, anfarmer, folly-diffs@
FB internal diff:
D1644012
Tasks:
5409538
Signature: t1:
1644012:
1417625401:
99b1b7df6de4cfcdd945eed7104d4c82e8c0b78f
Maxim Sokolov [Tue, 2 Dec 2014 00:03:36 +0000 (16:03 -0800)]
Fixing static initilize fiasco in Benchmark.cpp
Summary:
Benchmark.cpp code is dependent on initialization order, which leads
to benchmarks not running. The root cause is that on some linkers the code which
adds benchmarks to the benchmarks vector is run before the vector initialization.
The original bug report: https://github.com/facebook/folly/issues/18
See: http://www.parashift.com/c++-faq-lite/static-init-order.html
Test Plan: run benchmark_test and compare result with master output
Reviewed By: andrei.alexandrescu@fb.com, njormrod@fb.com
Subscribers: trunkagent, sdwilsh, folly-diffs@
FB internal diff:
D1710588
Signature: t1:
1710588:
1417468175:
fd2705a573cef5c4ff020b60c6aec3d83bcdbbab
Andrei Bajenov [Mon, 1 Dec 2014 21:52:38 +0000 (13:52 -0800)]
Readd unit test
Summary:
Description:
Last time a merge error broke stuff, fixing and readding
Test Plan:
Ran unit test
This reverts commit
1075ab9d6f62cad36a228bd3fc7203a75fdf5baf.
Reviewed By: davejwatson@fb.com
Subscribers: njormrod, folly-diffs@, wstefancik
FB internal diff:
D1695920
Signature: t1:
1695920:
1416529609:
3f726ac5df4e33f254075738ea6655a6fc01bb7f
Pavlo Kushnir [Thu, 27 Nov 2014 03:28:18 +0000 (19:28 -0800)]
Fix dynamic::insert
Summary: folly::dynamic::insert is broken. When we try to insert an rvalue and the key already exists in dynamic, insert will replace the value with empty dynamic.
Test Plan: unit test attached
Reviewed By: stepan@fb.com
Subscribers: trunkagent, njormrod, folly-diffs@
FB internal diff:
D1704995
Signature: t1:
1704995:
1417053631:
8e0163693df721c54b016f8c27e81e7bf60194cb
Mainak Mandal [Wed, 26 Nov 2014 02:27:13 +0000 (18:27 -0800)]
fix varint decoding in case the first buffer is smaller than encoded varint
Summary: This is not a super clean solution, given that I have just copied the code over form Varint.h. Another way would be to add a peek(IOBuf&, size_t) method to CursorBase and use that to peek deeper into the chain.
Test Plan: unit tests
Reviewed By: tulloch@fb.com
Subscribers: trunkagent, njormrod, dcapel, benr, folly-diffs@
FB internal diff:
D1689872
Signature: t1:
1689872:
1416964989:
b7f12a2686233f161401288ffcb8c51926b01fdf
Nicholas Ormrod [Wed, 26 Nov 2014 01:42:05 +0000 (17:42 -0800)]
IOBuf::moveToFbString legacy 4GiB limit
Summary:
IOBufs now support larger than 4GiB chunks. One of the checks
was not removed. Tracing through the capacity, its use if all 64-bit
compatible.
Test Plan: moveToFbString a 4GiB+ IOBuf element.
Reviewed By: maxim@fb.com
Subscribers: net-systems@, sdwilsh, njormrod, folly-diffs@
FB internal diff:
D1705316
Tasks:
5648445
Signature: t1:
1705316:
1416965241:
d9d064bbde53e033d32bfe872b3445ee59005f5e
Nicholas Ormrod [Wed, 26 Nov 2014 00:36:20 +0000 (16:36 -0800)]
zlib compression fails on large IOBufs
Summary:
If a single IOBuf has size exceeding 2^32, then our zlib
compression algorithm fails. Specifically, zlib z_stream.avail_in is
only 32 bytes (I think it's a long?
http://www.gzip.org/zlib/zlib_faq.html#faq32), and so a too-big IOBuf
will overflow the z_stream and cause data loss.
This diff breaks up large IOBufs into smaller chunks.
Test Plan:
fbconfig -r folly && fbmake runtests
Also compressed biggrep's configerator blob, which is how this bug was
caught. It now works. See the associated task.
Reviewed By: robbert@fb.com
Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@
FB internal diff:
D1702925
Tasks:
5648445
Signature: t1:
1702925:
1416958232:
459d498ff1db13e1a20766855e6f2f97da8cde8c
Subodh Iyengar [Tue, 25 Nov 2014 21:07:16 +0000 (13:07 -0800)]
Make SSLContext's exit() handling more graceful
Summary:
Some platforms that SSLContext run on call exit() despite best practices.
This cause the static structures to be destructed and cause race conditions
and crashes.
This new's the static structures so that they won't be destructed on exit()
Test Plan: Unit tests
Reviewed By: seanc@fb.com
Subscribers: trunkagent, ssl-diffs@, seanc, njormrod, folly-diffs@
FB internal diff:
D1702186
Tasks:
5572637
Signature: t1:
1702186:
1416941649:
c5bdfd8cc604fc3618f51bdb8b910b5b2cf350ad
James Sedgwick [Fri, 21 Nov 2014 23:23:56 +0000 (15:23 -0800)]
fix Makefile.am
Summary: also kill duplicated test file
Test Plan: run all exp/wangle tests
Reviewed By: davejwatson@fb.com
Subscribers: fugalh, njormrod, folly-diffs@
FB internal diff:
D1698503
Signature: t1:
1698503:
1416612139:
7139c6aa2ca79eabdaec6c33192194df984af348
Dave Watson [Fri, 21 Nov 2014 23:06:53 +0000 (15:06 -0800)]
fix build
Summary: bad merge with
D1661169 caused a unittest to fail. Update unittest
Test Plan: fbconfig -r folly/experimental/wangle; fbmake runtests
Reviewed By: jsedgwick@fb.com
Subscribers: doug, fugalh, njormrod, folly-diffs@
FB internal diff:
D1698435
Signature: t1:
1698435:
1416611458:
555b6b50baa1bc5850b10e19c9c94978f93f2a5a
James Sedgwick [Fri, 21 Nov 2014 21:06:05 +0000 (13:06 -0800)]
ChannelPipeline tests and fixes
Summary: As above. This paid off with a couple bugfixes.
Test Plan: run em all
Reviewed By: hans@fb.com
Subscribers: fugalh, njormrod, folly-diffs@
FB internal diff:
D1695106
Signature: t1:
1695106:
1416522038:
0c3345aadf954bf346d35b99877e7f8dfcf3ceff
James Sedgwick [Fri, 21 Nov 2014 20:59:49 +0000 (12:59 -0800)]
AsyncSocketHandler
Summary:
mostly copypasta from TAsyncTransportHandler
Test Plan: compiles
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, fugalh, njormrod, folly-diffs@
FB internal diff:
D1690973
Signature: t1:
1690973:
1416529528:
4feb187a68ad5405662b9b0efb160edd253a2977
James Sedgwick [Fri, 21 Nov 2014 19:55:49 +0000 (11:55 -0800)]
test for OutputBufferingHandler
Summary:
MLE: my first custom matcher
revealed some include issues, also fixed
Test Plan: guess
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, fugalh, njormrod, folly-diffs@
FB internal diff:
D1686223
Signature: t1:
1686223:
1416334120:
41bce88d56dd9ca107f3ddc3927c6be9419370cf
James Sedgwick [Fri, 21 Nov 2014 19:30:14 +0000 (11:30 -0800)]
modifiable channel pipelines
Summary:
Basically the same interface as before, but you must specify the read and write types for the ends of pipeline. Implementation is cleaner as well; there's fewer levels of indirection
This dynamic casts shit all over the place and is less typesafe then the previous iteration, but I think with some carefully placed static_asserts, could be just as safe (in the case where you don't do any modification, anyway)
Right now you can only add to the front or back of the pipeline but the way it's set up you could add any number of mutations, including ones that are triggered by handlers. But this should (might?) be enough for Tunnel, which was the motivation.
Test Plan: basic test compiles, thrift2 diff still works with a one line change
Reviewed By: hans@fb.com
Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, bmatheny
FB internal diff:
D1661169
Tasks:
5002299
Signature: t1:
1661169:
1416521727:
1f126279796c0b09d1905b9f7dbc48a9e5540271
Alexey Spiridonov [Tue, 12 Aug 2014 19:24:40 +0000 (12:24 -0700)]
Add process group leader option
Summary: Now a subprocess can be reliably made a group leader -- good for job control.
Test Plan:
unit test, checked that the pgid test worked in bash, too (only OKAY_XXX is printed)
==> XXX.sh <==
#!/bin/sh
test $(cut -d ' ' -f 5 /proc/$$/stat) == $$ && echo OKAY_XXX
./YYY.sh
==> YYY.sh <==
#!/bin/sh
test $(cut -d ' ' -f 5 /proc/$$/stat) == $$ && echo OKAY_YYY
./ZZZ.sh
==> ZZZ.sh <==
#!/bin/sh
test $(cut -d ' ' -f 5 /proc/$$/stat) == $$ && echo OKAY_ZZZ
Reviewed By: simpkins@fb.com
Subscribers: net-systems@, njormrod, folly-diffs@, simpkins
FB internal diff:
D1492526
Signature: t1:
1492526:
1416528620:
3cf98b1c1e334a7d551b2c2f3e76b1c70f07ad7c
Nicholas Ormrod [Thu, 20 Nov 2014 19:06:39 +0000 (11:06 -0800)]
Fix build break
Summary: Diff that had @override-unit-failures broke the build
Test Plan: fbconfig -r folly && fbmake dbg && fbmake runtests
Reviewed By: robbert@fb.com
Subscribers: sdwilsh, njormrod, folly-diffs@
FB internal diff:
D1694388
Tasks:
5662947
Signature: t1:
1694388:
1416510278:
d50f4896814a34d73d55be292961f5ecd74b1bb4
Blame Revision:
D1680735
James Sedgwick [Thu, 20 Nov 2014 18:02:13 +0000 (10:02 -0800)]
merge event base tests
Summary: someone made another event base test while the big set still lived in thrift. merge it now that the old tests have been moved.
Test Plan: fbconfig folly/io/async/test && fbmake runtests --extended-tests
Reviewed By: davejwatson@fb.com
Subscribers: njormrod, folly-diffs@
FB internal diff:
D1690764
Signature: t1:
1690764:
1416413748:
f3ae64d509432844bb2e1b689a75d66825269d15
Dave Watson [Thu, 20 Nov 2014 17:32:17 +0000 (09:32 -0800)]
Bump version to 17:0
Dave Watson [Wed, 19 Nov 2014 17:41:06 +0000 (09:41 -0800)]
folly/io/async documentation
Summary: Documentation brain-dump. The sources already have pretty good doxygen-style comments, but could use a good high-level overview.
Test Plan: Reviewers get to edit
Reviewed By: jsedgwick@fb.com, afrind@fb.com, dcsommer@fb.com, alandau@fb.com
Subscribers: fugalh, subodh, kmdent, seanc, vloh, sjenkins, kparton, doug, net-systems@, njormrod, folly-diffs@, sgolemon, alikhtarov, andrii, tudorb
FB internal diff:
D1690976
Tasks:
5648428
Signature: t1:
1690976:
1416419706:
3894976c32904f040d518b9a4ce26ccb40d7ed80
Andrei Bajenov [Thu, 20 Nov 2014 01:47:07 +0000 (17:47 -0800)]
HHWheelTimer - fix scheduling timeouts within callbacks
Summary:
This one is a little tricky, but it explains what happened in t5388156. Basically what we observed in the stack traces is that the HHWheelTimer count_ is 0, but there is still a timeout scheduled on the AsyncTimeout.
How I can see this happening is the following:
- SASL times out
- We fall back to insecure mode in the callback and schedule a send of a real message to the server. Here we schedule another timeout on the same HHWheelTimer object. Since count_ is 0 at this point, we schedule a timeout in AsyncTimeout.
- Now the initial SASL timeout was late, so the HHWheelTimer is in a catchup state. This means that it's possible for the callback on the timeout that was just scheduled to fire on the same "tick".
- This callback invokes SR's callbacks which try to detach the event base from the channel. But it can't detach because we have something scheduled on the AsyncTimeout.
- We crash.
Test Plan:
- will wait for contbuild
- Something like this repros the problem: https://phabricator.fb.com/P17220063. Note I hacked the catchup part to get it to work. Now running loadgen with security = permitted causes the crash.
// hphp tests are stalled, have to do this...
Reviewed By: mshneer@fb.com
Subscribers: bmatheny, mshneer, sandeepkk, trunkagent, njormrod, folly-diffs@, alandau, mhorowitz, srenfro, hitesh, wstefancik
FB internal diff:
D1680735
Tasks:
5388156
Signature: t1:
1680735:
1416252123:
e76668860ccda9380a87996b4fa3de957e129404
Dave Watson [Wed, 19 Nov 2014 20:54:03 +0000 (12:54 -0800)]
Bump version to 16:0
Dave Watson [Mon, 10 Nov 2014 18:14:41 +0000 (10:14 -0800)]
OS merges
Summary:
All pretty trivial:
https://github.com/facebook/folly/issues/99
https://github.com/facebook/folly/issues/98
https://github.com/facebook/folly/issues/45
Test Plan: Will watch jenkins fbthrift build
Reviewed By: dcsommer@fb.com
Subscribers: doug, njormrod, folly-diffs@
FB internal diff:
D1669952
Signature: t1:
1669952:
1415643677:
906234f0a89f38645b0072d3c88762d8fa2729dc