- 29 Oct, 2014 25 commits
-
-
Dave Watson authored
Summary: Idle memory in IO threads. If loop is unused for a period of time, free associated memory, and call epoll again. Had to add a new list of callbacks that don't make the loop nonblocking (i.e. using runInLoop() instead would use the nonblocking version of epoll). Could bake this in to EventBase directly, but that seems like the wrong abstraction, since EventBase doesn't actually control the thread - for example, that approach would also free up memory for stack-allocated EventBases where they are used synchronously by clients. This diff doesn't change IO scheduling at all - current IO work is round robin, so this probably only helps if the whole server is idle (at least until we add smarter scheduling) Test Plan: Based on top of D1585087. fbconfig thrift/perf/cpp; fbmake dbg _bin/thrift/perf/cpp/ThriftServer _bin/thrift/perf/cpp/loadgen -num_threads=100 -weight_sendrecv=1 -cpp2 -async Ran loadgen for a while, watched res memory in top. Stopped loadgen. After ~5 sec, res memory was much reduced. Reviewed By: jsedgwick@fb.com Subscribers: trunkagent, doug, fugalh, njormrod, folly-diffs@ FB internal diff: D1641057 Tasks: 5002425
-
Viswanath Sivakumar authored
Summary: Test Plan: Reviewed By: cgheorghe@fb.com Subscribers: FB internal diff: D1642334 Blame Revision: D1587625
-
Adam Simpkins authored
Summary: Add an operator()(StringPiece) method to Appender, so it can be used directly with folly::Formatter objects. Also add printf() and vprintf() methods to Appender, for places that need to use existing printf-style formatting. This also includes versions of push() and pushAtMost() that accept ByteRange objects. Previously we only had push() implementations that took separate buffer and size arguments. Test Plan: Added new unit tests to IOBufCursorTest.cpp Reviewed By: davejwatson@fb.com Subscribers: trunkagent, doug, net-systems@, exa, njormrod FB internal diff: D1583684
-
Dave Watson authored
Summary: Jenkins ci build was broken for a while, so we missed these in contbuild results Test Plan: watch ci build for fbthrift Reviewed By: hans@fb.com Subscribers: doug, fugalh, njormrod, folly-diffs@ FB internal diff: D1641515
-
Dave Watson authored
Summary: Move async socket to folly. Changes: * Made an AsyncSocketException type instead of TTransportException: Some of the exceptions didn't fit nicely in to std::exception types (like TIMED_OUT). There are some wrappers in thrift/lib/cpp/async to convert back to TTransportException, so all existing code still compiles. * Moved read/write callbacks out of AsyncTransport: filters are going to want to do the read/write stuff separately (see revproxy/tunnel/filters, and discussions in D1483148). Test Plan: fbconfig -r thrift; fbmake runtests contbuild should catch everything else - exception types shouldn't change for existing code Reviewed By: dcsommer@fb.com Subscribers: mshneer, folly-diffs@, trunkagent, doug, alandau, bmatheny, njormrod, fugalh, jsedgwick FB internal diff: D1587625
-
Hans Fugal authored
Summary: In D1618240 I introduced a race condition in `detachOne()`, where `detached_` is incremented and then tested. If the promise and future are racing, they can both see `detached_ == 2` in the conditional, and then they'll both try to free the Core object. This fixes that. It also fixes a related problem (which actually showed up more often with the test I wrote), where we transition into the Done state before setting the value, and then `maybeCallback()` observes the state is Done (because we're just reading an atomic, not grabbing the lock, which is intentional), tries to execute the callback, but `folly::Optional` throws an exception because the value hasn't been set yet (at least in debug it does). I should have listened to my gut and kept the state assignment after the transition action in the first place. Test Plan: New unit test Reviewed By: jsedgwick@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, folly-diffs@, mnd FB internal diff: D1636490 Tasks: 5438209 Blame Revision: D1618240
-
Hans Fugal authored
Summary: Reverts D1633874. Companion to D1636490 which fixes the bug. Test Plan: git reverting code that was git reverted and hasn't changed in the interim Won't be checked in without the companion bugfix diff (D1636490) Reviewed By: davejwatson@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, folly-diffs@ FB internal diff: D1636487 Tasks: 5438209 Blame Revision: D1633874
-
Dave Watson authored
Summary: EventBaseManager was moved to folly, we shouldn't have deps on apache Test Plan: fbconfig -r folly/experimental/wangle/concurrency; fbmake runtests Reviewed By: hans@fb.com Subscribers: doug, fugalh, njormrod, folly-diffs@ FB internal diff: D1636006
-
Hans Fugal authored
Summary: Test Plan: Reviewed By: harishs@fb.com Subscribers: net-systems@, fugalh, exa, njormrod, folly-diffs@ FB internal diff: D1633874 Tasks: 5438209
-
Hans Fugal authored
Summary: I'm still a little mystified how one makes a Future<const T> (I tried to make one explicitly in a test and failed), but this is clearly the bug @reedriley sees in https://phabricator.fb.com/D1620805#21 Test Plan: fbconfig titan/cachius/test fbmake Reviewed By: reedriley@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, reedriley, folly-diffs@ FB internal diff: D1630378 Blame Revision: D1620805
-
Dave Watson authored
Summary: Changes: * namespace to folly * some std::chrono replacesments * Moves shutdownSocketSet stuff to thriftserver instead of in the socket itself. * Changes exception types. I don't see anywhere that uses the TAsync*SERVER*socket exceptions depending on the TTransport type, but I could be wrong? I don't really know what to do about the exception types unittests still postponed overnight. Test Plan: fbconfig -r thrift; fbmake runtests fbconfig -r proxygen; fbmake runtests Reviewed By: dcsommer@fb.com Subscribers: hphp-diffs@, ps, folly-diffs@, anca, trunkagent, jsedgwick, fugalh, doug, alandau, bmatheny, njormrod FB internal diff: D1579187
-
James Sedgwick authored
Summary: fix fbthrift build, broken in D1621717 I wonder if it'd be possible to lint against this somehow. The jenkins failures are easy to miss especially on folly diffs with lots of failure noise (in this case it was still postponed) Test Plan: wait for jenkins Reviewed By: davejwatson@fb.com Subscribers: njormrod, folly-diffs@ FB internal diff: D1630833
-
Andrii Grynenko authored
Summary: This makes it more likely that SingletonVaultDestructor won't be created after atexit calls. Test Plan: unit test Reviewed By: chip@fb.com Subscribers: hphp-diffs@, ps, njormrod, folly-diffs@ FB internal diff: D1629804 Tasks: 5353022
-
Hans Fugal authored
Summary: This would cause debug builds to do a bad thing (access the variable `this->detached_` within an assert, after `delete this`). Test Plan: unit tests Hopefully now that we have a dummy cpp file in `folly/wangle/detail` contbuild will pick it up and all the dependencies will also run their tests. Right now, we suspect maybe maelstrom (@wez) and adinvoicer and zookeeper (@jying) and probably others are seeing this in unit test failures (esp. if they use asan, which is rightly detecting read after free). Hoping contbuild will catch them. Reviewed By: davejwatson@fb.com Subscribers: net-systems@, fugalh, exa, njormrod, folly-diffs@, wez, dcapel, jying, cgheorghe FB internal diff: D1630301 Tasks: 5424546, 5435720 Blame Revision: D1618240
-
Hans Fugal authored
Summary: Fixing the race will take some more thought. Probably a condvar. For now, I'm turning waitFor into a spinlock instead. Test Plan: new unit test that deadlocks before the workaround Reviewed By: jsedgwick@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, folly-diffs@ FB internal diff: D1628015 Tasks: 5427828
-
Hans Fugal authored
Summary: If you try to include files in a weird (but not incorrect) order you get compilation errors. No longer! Test Plan: new dummy `cpp_binary` target Reviewed By: davejwatson@fb.com Subscribers: trunkagent, folly-diffs@, net-systems@, fugalh, exa, njormrod FB internal diff: D1621083
-
Hans Fugal authored
Summary: Modeled very closely after Finagle's interrupts. Compare with https://github.com/twitter/util/blob/master/util-core/src/main/scala/com/twitter/util/Promise.scala if you like. The basic idea is the promise holder can register an interrupt handler, and then interrupts will call that handler. A typical handler would fulfil the promise with an exception (or special value) indicating that it was interrupted (if it was interrupted in time). Raising an interrupt does not prevent setting a value or callbacks executing or any of that - it is only advisory to the promise holder. Test Plan: I wrote some unit tests. Reviewed By: davejwatson@fb.com Subscribers: folly-diffs@, net-systems@, fugalh, exa, hannesr, njormrod FB internal diff: D1620805 Tasks: 4618297
-
Hans Fugal authored
Summary: This is a refactor of the current functionality to use a state machine (inheriting from `FSM`). This will make it easier to extend to do cancellation and Future collapsing. Performance is the same, maybe slightly faster (abt 1%). (I might be a little conservative with the atomics, it might be worth going through and reasoning about whether they all need to be atomic). The state machine is two states, Waiting (no value), and Done (has a value). Transitioning to Done will execute the callback if it exists and we are active. Otherwise the callback will happen when it is set and active is true. There is a subjective balancing act in place here, between making a state for every single mutable bit of information (which results in an explosion of states: hasValue X hasCallback X isActive X isCancelled …), and finding a sweet spot of expressivity. This isn't too far from the way Twitter did it, though we don't (yet) have all the states they have (and they don't have the concept of hot/cold futures). But I got there by way of replacing the `mutex_` with the state, after changing all those variables to atomics so they didn't need mutex protection (resulting in only `callback_` and `result_` needing it). I expect the state machine will morph as the rest of the functionality is added, but hopefully it will be easier to understand and keep correct (that's the idea anyway). Test Plan: Tests still pass (and not by accident, I made several awesome mistakes along the way). Reviewed By: davejwatson@fb.com Subscribers: net-systems@, fugalh, exa, njormrod FB internal diff: D1618240 Tasks: 4618297
-
Hans Fugal authored
Summary: Just some cleaning hose in `detail::Core`. - rename `fulfil` to `setResult` - and `value_` to `result_` - remove unnecessary helper methods (I can be convinced to keep them if you like them) Test Plan: mechanical changes, tests still pass Reviewed By: davejwatson@fb.com Subscribers: trunkagent, folly-diffs@, net-systems@, fugalh, exa, njormrod FB internal diff: D1618161
-
Hans Fugal authored
Summary: Later is now superfluous. Just hold a deactivated future (e.g. one returned by `Future::via`), and then activate (or destruct) it when you're ready. ThreadGate has proven to be too rigid and too heavyweight to be really useful. And is superfluous now with `Future::via`. e.g. f.via(east).then(a1).then(a2).via(west).then(b1).then(b2); This is stage one of removing these: mark them deprecated. Stage two will be for me to change all existing usages in our code to not use them. Stage three will be to rip these out altogether. Test Plan: Everything still builds and works, but now with deprecation warnings. fbconfig -r \ common/smc/cpp/tests \ folly/wangle \ langtech/audiens \ messaging/avscan \ messaging/maelstrom \ neteng/traffic_manager \ notifications/nudge/service \ tao/client \ zeus/datashuttle fbmake runtests Reviewed By: jsedgwick@fb.com Subscribers: net-systems@, fugalh, exa, njormrod, folly-diffs@ FB internal diff: D1626412 Tasks: 5409538
-
Hans Fugal authored
Summary: It was deprecated, now is unused. Test Plan: fbgs check contbuild Reviewed By: hannesr@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, folly-diffs@ FB internal diff: D1624221
-
Hans Fugal authored
Summary: for great contbuild Test Plan: these projects still build. contbuild should start picking them up, based on discussion with @robbert Reviewed By: robbert@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, mwa, jgehring, fuegen, njormrod, folly-diffs@, robbert FB internal diff: D1624206 Tasks: 5399744
-
Hans Fugal authored
Summary: Like the magic macros. As it says in the comment, this can lead to nicer code. Also added/moved a couple examples to the top of `test/FSM.cpp`. Test Plan: new tests Reviewed By: davejwatson@fb.com Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod FB internal diff: D1618184
-
James Sedgwick authored
Summary: as above Test Plan: Reviewed By: davejwatson@fb.com Subscribers: fugalh, njormrod FB internal diff: D1589439
-
Sean Cannella authored
Summary: This is the last of the changes to make folly and thrift portable. The old thrift SpinLock implementation is exactly we want here so port this into folly. If someone later makes efficeint versions of MicroSpinLock for platforms other than x64 they can easily be plugged in without changing the calling code. Test Plan: compiled on multiple platforms Reviewed By: alandau@fb.com Subscribers: folly-diffs@, ldbrandy, trunkagent, alandau, bmatheny, njormrod, mshneer, shikong, benyluo, kmdent, fma, ranjeeth, subodh FB internal diff: D1621717 Tasks: 5183325
-
- 17 Oct, 2014 15 commits
-
-
dcsommer authored
-
Pavlo Kushnir authored
Summary: mcrouter now uses folly::Singleton. Test Plan: visual Reviewed By: andrii@fb.com Subscribers: njormrod FB internal diff: D1622647
-
Max Wang authored
Test Plan: yes Reviewed By: delong.j@fb.com
-
Sean Cannella authored
Summary: pthread_atfork isn't defined in the Android NDK (and therefore is not actually supported even though it's in bionic/libc) so don't call it there. Test Plan: compiled on Linux, Android Reviewed By: meyering@fb.com Subscribers: njormrod, shikong, kmdent, fma FB internal diff: D1620584 Tasks: 5183325
-
Tom Jackson authored
Summary: Buffer size calculation had fallen out of sync with the actual test code. Good thing we have ASAN! Test Plan: Run the test with address santizer. Reviewed By: mpawlowski@fb.com Subscribers: mpawlowski, trunkagent, njormrod FB internal diff: D1619472 Tasks: 5325399
-
Max Wang authored
Summary: I can see how {<,>}{,=} comparisons might be ambiguous, but equality should never be, so let's allow it. Test Plan: tests Reviewed By: tjackson@fb.com Subscribers: trunkagent, njormrod FB internal diff: D1618088
-
Dave Watson authored
Summary: Move shutdownsocketset to folly, since it is a dep of the asyncsockets Previoulsy tried moving it in to the server directly: D1583629, but had issues - close(fd) is called before the error callback, so we can't remove the fd before the close, which is essential to it working properly. Just move it to folly instead. Test Plan: fbconfig -r thrift/lib/cpp thrift/lib/cpp2; fbmake runtests Reviewed By: dcsommer@fb.com Subscribers: mshneer, trunkagent, fugalh, jsedgwick, doug, alandau, bmatheny, njormrod FB internal diff: D1594950
-
Sean Cannella authored
Summary: Conditional changes required to compile on iOS and Android. Test Plan: compiled on all platforms Reviewed By: meyering@fb.com Subscribers: kmccray, trunkagent, shilin, njormrod, ranjeeth, subodh, bmatheny FB internal diff: D1618028 Tasks: 5183325
-
Andrii Grynenko authored
Summary: This is a fix for situations where you know that something is keeping singleton alive (by getting a weak_ptr and locking it), and request a singleton instance via get() method (if e.g. it's hard to pass a pointer to singleton instance from a method which locked it). If shutdown was scheduled - an exception was previously thrown even though the object was not destroyed yet. This simplifies conversion of legacy code to folly::Singleton. Test Plan: fbconfig -r gatehouse/usersets/tests fbmake runtests Reviewed By: chip@fb.com Subscribers: trunkagent, njormrod FB internal diff: D1619311
-
Subodh Iyengar authored
Summary: Remove global initialization of ThreadLocal in Random See https://gcc.gnu.org/onlinedocs/gcc-4.8.3/gcc/Thread-Local.html Static initializers and thread locals don't mix well, and we're seeing some crashes which we think might be related to this. Test Plan: Unit tests Reviewed By: seanc@fb.com Subscribers: trunkagent, seanc, njormrod FB internal diff: D1617455
-
James Sedgwick authored
Summary: universal references and perfect forwarding to the rescue Test Plan: added demonstrative unit tests Reviewed By: hans@fb.com Subscribers: trunkagent, fugalh, njormrod, bmatheny FB internal diff: D1592032 Tasks: 5283342
-
James Sedgwick authored
Summary: the one in concurrent/ is a bit more generic, so I kept that as Executor and renamed the existing one ScheduledExecutor because Hans is surfing I took the liberty of renaming Action->Func as an alias for std::function<void()>, because I think it's more reflective also kept the version of add() that doesn't force rvalue-reference as it's more user friendly and probably not less performant in common cases (insert reference to "want speed? pass by value" here) Test Plan: compiled some major relevant bits, will let contbuild show me anything I missed Reviewed By: hans@fb.com Subscribers: trunkagent, rushix, fbcode-common-diffs@, fugalh, msk, njormrod FB internal diff: D1591237 Tasks: 5279196
-
Andrii Grynenko authored
Summary: Right now destroyInstances is scheduled when SingletonVault is requested. This may change singleton destruction order (folly::Singleton-managed vs unmanaged singletons) when new singleton is registered with folly::Singleton (no matter if it is even used). This diff changes it to be more stable. Test Plan: servicerouter unittests Reviewed By: chip@fb.com Subscribers: njormrod, mshneer FB internal diff: D1615213 Tasks: 5353022
-
Sean Cannella authored
Summary: While working on other code I noticed folly stopped compiling with clang. Fix that. Test Plan: fbmake runtests (clang and gcc) Reviewed By: lucian@fb.com Subscribers: mathieubaudet, njormrod, bmatheny FB internal diff: D1618189
-
Hans Fugal authored
Summary: For great speed Test Plan: Before ============================================================================ folly/wangle/test/Benchmark.cpp relative time/iter iters/s ============================================================================ constantFuture 241.19ns 4.15M promiseAndFuture 100.32% 240.42ns 4.16M withThen 44.63% 540.47ns 1.85M ---------------------------------------------------------------------------- oneThen 519.20ns 1.93M twoThens 62.83% 826.41ns 1.21M fourThens 36.80% 1.41us 708.75K hundredThens 1.79% 29.05us 34.42K ---------------------------------------------------------------------------- no_contention 4.82ms 207.27 contention 62.91% 7.67ms 130.39 ============================================================================ After ============================================================================ folly/wangle/test/Benchmark.cpp relative time/iter iters/s ============================================================================ constantFuture 159.79ns 6.26M promiseAndFuture 101.23% 157.84ns 6.34M withThen 41.78% 382.47ns 2.61M ---------------------------------------------------------------------------- oneThen 358.23ns 2.79M twoThens 63.07% 568.00ns 1.76M fourThens 36.89% 971.07ns 1.03M hundredThens 1.76% 20.34us 49.17K ---------------------------------------------------------------------------- no_contention 3.75ms 266.75 contention 59.83% 6.27ms 159.59 ============================================================================ That's a 150% speedup. Reviewed By: davejwatson@fb.com Subscribers: net-systems@, fugalh, exa, njormrod FB internal diff: D1617363 Tasks: 5278220
-