folly.git
8 years agoFix "reference to 'thread' is ambiguous"
Hans Fugal [Tue, 21 Jul 2015 00:46:42 +0000 (17:46 -0700)]
Fix "reference to 'thread' is ambiguous"

Summary: This fixes github issue https://github.com/facebook/folly/issues/243

I don't understand why this is broken on osx, but the solution is to just `#include <thread>` in the header instead of trying to forward declare `std::thread`.

Reviewed By: @yfeldblum

Differential Revision: D2255026

8 years agofixing compiler errors when compiling with Wunused-parameter
Ondrej Lehecka [Mon, 20 Jul 2015 23:37:52 +0000 (16:37 -0700)]
fixing compiler errors when compiling with Wunused-parameter

Summary: fixing C++ compiler warnings for the -Wunused-parameter warning switch on.
This is fixing only the header files, not the library cpp files.

Reviewed By: @yfeldblum

Differential Revision: D2259957

8 years agoFix logspew in DelayedDestruction
Viswanath Sivakumar [Mon, 20 Jul 2015 23:07:03 +0000 (16:07 -0700)]
Fix logspew in DelayedDestruction

Summary: This is causing a log of spew in proxygen logs

Reviewed By: @afrind

Differential Revision: D2262006

8 years agoRemove EmptySequence exception in favor of optional returns
Tom Jackson [Mon, 20 Jul 2015 21:05:59 +0000 (14:05 -0700)]
Remove EmptySequence exception in favor of optional returns

Summary: Forces consumers to handle the empty sequence case instead of cumbersome exceptions.

Reviewed By: @​jrichey, @yfeldblum

Differential Revision: D2219505

8 years agoFix a namespace nit in folly/futures/Future.cpp.
Yedidya Feldblum [Mon, 20 Jul 2015 19:26:32 +0000 (12:26 -0700)]
Fix a namespace nit in folly/futures/Future.cpp.

Summary: [Folly] Fix a namespace nit in folly/futures/Future.cpp.

As soon as someone introduces a namespace `folly::futures::detail` this will blow up. Fix it so it won't blow up when that happens.

Reviewed By: @​hannesr

Differential Revision: D2258799

8 years agoBump version to 51:0 v0.51.0
Sara Golemon [Mon, 20 Jul 2015 19:26:38 +0000 (12:26 -0700)]
Bump version to 51:0

8 years agoAllow access to a FiberManager's currently running fiber
Brian Watling [Mon, 20 Jul 2015 18:46:02 +0000 (11:46 -0700)]
Allow access to a FiberManager's currently running fiber

Summary: Allow access to a FiberManager's currently running fiber

Reviewed By: @alikhtarov, @andriigrynenko

Differential Revision: D2257201

8 years agoOverload Optional::value() on object reference type.
Nick Terrell [Mon, 20 Jul 2015 16:03:11 +0000 (09:03 -0700)]
Overload Optional::value() on object reference type.

Summary: `folly::Optional` returns the stored value by reference when the object
is an rvalue.  This causes three issues:

  * If the user calls `value()` on an rvalue `Optional`, and assigns the result
    to a new variable, the copy constructor gets called, instead of the move
    constructor.  This causes the added test `value_move` to not compile.
  * If the user calls `value()` on an rvalue `Optional`, and assigns the result
    to a const lvalue reference, they might expect the lifetime to be extended
    when it isn't. See the added test `value_life_extention`.
  * Assigning the results of `value()` on an rvalue `Optional` to a mutable
    lvalue reference compiled in the old code, when it shouldn't, because that
    is always a dangling reference as far as I can tell.

I'm not sure how strict `folly` is with compatibility, but I believe the
breakage would be minimal, and any code that gets broken probably deserves it.

I'm not exactly sure who I should add as a reviewer, so hopefully herald has got
my back.

Reviewed By: @yfeldblum

Differential Revision: D2249548

8 years agofolly Singleton: clear some state if creator function fails
Steve O'Brien [Sun, 19 Jul 2015 16:22:34 +0000 (09:22 -0700)]
folly Singleton: clear some state if creator function fails

Summary: The creator thread ID is saved to indicate the singleton is already being built (to help detect dependency cycles).  However if the creation function throws an error, that thread ID persists, and then if the same thread tries again to build the singleton it will be falsely detected as a dependency cycle.  This clears that state in the case of failure.

Reviewed By: @chipturner

Differential Revision: D2256441

8 years agoRevert: (Wangle) within should raise TimedOut()
Hannes Roth [Sat, 18 Jul 2015 18:58:52 +0000 (11:58 -0700)]
Revert: (Wangle) within should raise TimedOut()

Summary: This reverts commit 956351018a495af89575526536af7e7c0bb285aa.

Reviewed By: @​labrams

Differential Revision: D2258219

8 years agofolly HHWheelTimer: fix loop variable
Steve O'Brien [Fri, 17 Jul 2015 19:41:02 +0000 (12:41 -0700)]
folly HHWheelTimer: fix loop variable

Summary: In nested loop, loop condition is incorrect.  Fixed var (should be `ii` not `i`)

Reviewed By: @pgriess

Differential Revision: D2255702

8 years agoMaking Optional throw exceptions instead of assert
Tom Jackson [Thu, 16 Jul 2015 20:59:07 +0000 (13:59 -0700)]
Making Optional throw exceptions instead of assert

Summary: I'm upgrading assertions to throws, since these are fatal in all circumstances. If something is explicitly `Optional`, it makes sense to fail loudly if it is misused in this manner.

Reviewed By: @yfeldblum

Differential Revision: D2247612

8 years agoadd SocketPair.h/.cpp to Makefile
James Sedgwick [Thu, 16 Jul 2015 17:16:45 +0000 (10:16 -0700)]
add SocketPair.h/.cpp to Makefile

Summary: to unbreak OSS wangle tests build

Reviewed By: @bugok

Differential Revision: D2240264

8 years agofolly::Future-istic barrier
Tudor Bosman [Thu, 16 Jul 2015 16:50:03 +0000 (09:50 -0700)]
folly::Future-istic barrier

Summary: What it says on the tin.

Reviewed By: @fugalh

Differential Revision: D2230390

8 years agoAdd an option to disable guard pages for fiber stacks
Pavlo Kushnir [Thu, 16 Jul 2015 04:06:29 +0000 (21:06 -0700)]
Add an option to disable guard pages for fiber stacks

Summary: guard pages may make debugging more painful. For example, in some cases they increased "perf" initialization time.

Reviewed By: @alikhtarov

Differential Revision: D2247188

8 years ago(Wangle) within should raise TimedOut()
Hannes Roth [Wed, 15 Jul 2015 23:39:48 +0000 (16:39 -0700)]
(Wangle) within should raise TimedOut()

Summary: I figured it out. This works. The two extra futures are a small overhead
(just two pointers). The `Core`s are allocated anyway, so this is pretty
much optimal.

A timeout now raises on the current Future, and a fulfilled promise
cancels the timeout Future.

Reviewed By: @yfeldblum

Differential Revision: D2232463

8 years agoOnly try to use F_SETPIPE_SZ if it's available
Sara Golemon [Wed, 15 Jul 2015 16:44:05 +0000 (09:44 -0700)]
Only try to use F_SETPIPE_SZ if it's available

Summary: As the comment says, we can ignore errors in setting the size.
So it stands to reason we can ignore setting the size as well.

Reviewed By: @yfeldblum

Differential Revision: D2242882

8 years agoMake DestructorGuard inherit from a base
Sophia Wang [Wed, 15 Jul 2015 00:18:18 +0000 (17:18 -0700)]
Make DestructorGuard inherit from a base

Summary: There are more use cases that the Destruction/Guard pattern can be
used than current DelayedDestruction provides. This diff makes the pattern more
general (remove self destruct) and lets DelayedDestruction derive from that.
The functionalities of DelayedDestruction is kept unchanged.

I leave destroy(), Destructor class, and destroyPending_ in DelayedDestruction
since they are not required by our CallbackGuard in proxygen.

I add a shouldDestruct() function to allow customized conditions on when to
call destructor.

I haven't made destroyNow() a std::function since I only need it to be set at
instatiation time. If there is any other use case that needs destroyNow() to be
a std::function, I can do that as well.

Reviewed By: @afrind

Differential Revision: D2202575

8 years agoActually denote when we have infinite generators
Joe Richey [Tue, 14 Jul 2015 20:50:31 +0000 (13:50 -0700)]
Actually denote when we have infinite generators

Summary: Before we didn't do anything at all with the ::infinite value for our
generators, now all the sources operators and sinks are properly notated. The
one signifcant change regarding what is allowed concerns 'cycle' which now (when
called with no arguments) always produces an infinite generator. This is fine
for all but the weirdest of generators fed into cycle.

Reviewed By: @ddrcoder

Differential Revision: D2240328

8 years agoChanging behavior of 'any' and 'all' sinks, adding in 'isEmpty' and 'notEmpty' sinks
Joe Richey [Tue, 14 Jul 2015 20:50:24 +0000 (13:50 -0700)]
Changing behavior of 'any' and 'all' sinks, adding in 'isEmpty' and 'notEmpty' sinks

Summary: When adding in the 'filter()' default behavior, I considered adding in similar
behavior for 'any' and 'all'. However, we had 'any' with no funciton call
basically check if anything was present, not testing a predicate. This can
create a confusing senario, so I removed this behavior from 'any' and added in
the 'isEmpty' and 'notEmpty' sinks. Now the calls 'any()' and 'all()' (called
with parens, so old uses won't compile) check for truthy values simlar to
'filter()'.

I also added some unit tests and changed 'static const' objects to 'constexpr'.

Reviewed By: @ddrcoder

Differential Revision: D2234637

8 years agoRequestContext support
Andrii Grynenko [Tue, 14 Jul 2015 17:29:36 +0000 (10:29 -0700)]
RequestContext support

Summary: Integrating RequestContext into fibers library. RequestContext is saved for every task, when that task is created. If RequestContext is overriden when a task is being run (within fiber, in runInMainContext, within function passed to await call) the new context will continue to be used for the task.

Reviewed By: @alikhtarov

Differential Revision: D2240152

8 years agofolly: AsyncIOOp: improve logging message: add strerror
Lucian Grijincu [Tue, 14 Jul 2015 17:31:26 +0000 (10:31 -0700)]
folly: AsyncIOOp: improve logging message: add strerror

Reviewed By: @philippv

Differential Revision: D2240628

8 years agoFix Build: folly/io/async/test/ScopedEventBasedThreadTest.cpp
Yedidya Feldblum [Tue, 14 Jul 2015 00:18:23 +0000 (17:18 -0700)]
Fix Build: folly/io/async/test/ScopedEventBasedThreadTest.cpp

Summary: [Folly] Fix Build: folly/io/async/test/ScopedEventBasedThreadTest.cpp

Failure with latest clang:

    folly/io/async/test/ScopedEventBaseThreadTest.cpp:72:8: error: explicitly moving variable of type 'folly::ScopedEventBaseThread' to itself [-Werror,-Wself-move]
      sebt = std::move(sebt);

Reviewed By: @markisaa

Differential Revision: D2238762

8 years agoFile ctor should take StringPiece.
Yedidya Feldblum [Mon, 13 Jul 2015 20:25:25 +0000 (13:25 -0700)]
File ctor should take StringPiece.

Summary: [Folly] File ctor should take StringPiece.

This way we can use it with `std::string` and `folly::fbstring` a touch more easily.

Reviewed By: @luciang

Differential Revision: D2235870

8 years agoBump version to 50:0 v0.50.0
Sara Golemon [Mon, 13 Jul 2015 18:17:36 +0000 (11:17 -0700)]
Bump version to 50:0

8 years agoFix examples in folly::Singleton code
Andrii Grynenko [Mon, 13 Jul 2015 17:39:32 +0000 (10:39 -0700)]
Fix examples in folly::Singleton code

Reviewed By: @chipturner

Differential Revision: D2235232

8 years agosplit SmallLocks.h to get a larger portion of folly compiled on 32bit platforms
Kjell Schubert [Sat, 11 Jul 2015 16:12:08 +0000 (09:12 -0700)]
split SmallLocks.h to get a larger portion of folly compiled on 32bit platforms

Summary: This is only a simple #include file split, no functional change was made. SmallLocks.h provides 2 classes: MicroSpinLock and PicoSpinLock, with the latter not being available on 32bit platforms. There are several classes in folly that included SmallLocks.h but only needed MicroSpinLock, these also refused to compile on 32bit, e.g. folly/futures/Future.h. Now these compile fine.

Reviewed By: @yfeldblum

Differential Revision: D2234263

8 years agoAn has_member_type macro.
Yedidya Feldblum [Sat, 11 Jul 2015 04:24:17 +0000 (21:24 -0700)]
An has_member_type macro.

Summary: [Folly] An has_member_type macro.

Reviewed By: @juchem

Differential Revision: D2229775

8 years agoAdded default value for filter's predicate argument
Joe Richey [Thu, 9 Jul 2015 21:48:17 +0000 (14:48 -0700)]
Added default value for filter's predicate argument

Summary: After discussion with Tom about frozen files, we noticed that the use
case of filtering out somthing that looks like false (0, nullptr, folly::none)
is unnecessarily tedious. So folly::gen::filter now filters by the value of
the item by default.

Reviewed By: @ddrcoder

Differential Revision: D2220582

8 years agoAdd mocks for isBufferMovable
Subodh Iyengar [Thu, 9 Jul 2015 05:44:59 +0000 (22:44 -0700)]
Add mocks for isBufferMovable

Summary: Add mocks for the new isBufferMovable methods.

Reviewed By: @yfeldblum

Differential Revision: D2222642

8 years agoThreadedExecutor.
Yedidya Feldblum [Thu, 9 Jul 2015 00:54:16 +0000 (17:54 -0700)]
ThreadedExecutor.

Summary: [Folly] ThreadedExecutor.

It's an Executor that runs functions each in its own thread.

Kind of simple. Suitable for a few types of strange cases.

Reviewed By: @​hannesr

Differential Revision: D2226211

8 years agoAdd isManaged / makeManaged
Tudor Bosman [Wed, 8 Jul 2015 15:39:55 +0000 (08:39 -0700)]
Add isManaged / makeManaged

Summary: Add a way to tell whether an IOBuf (either indvidually or the whole chain)
refers to memory that's outside of IOBuf's control (via WRAP_BUFFER). That is,
can you assume that clone() will extend the lifetime of the memory? Is it safe
to use clone() instead of copying the data (and avoid a copy)?

Reviewed By: @simpkins

Differential Revision: D2191883

8 years agofolly/singleton: fatal in unrecoverable error cases
Steve O'Brien [Tue, 7 Jul 2015 23:10:07 +0000 (16:10 -0700)]
folly/singleton: fatal in unrecoverable error cases

Summary: Early in the startup process there may not be a default signal handler installed, and stack traces are not available; also during the startup process is when init-order fiascos occur.  Dump a stacktrace and fatal when an unregistered singleton is used.

Also fatals -- with glog `LOG(FATAL)`, which triggers an ABRT signal -- on other illegal and unrecoverable usage like double-registration or circular dependency.

Reviewed By: @andriigrynenko

Differential Revision: D2200408

8 years agohigh init priority for FiberManagerMap data
Mark McDuff [Tue, 7 Jul 2015 22:20:59 +0000 (15:20 -0700)]
high init priority for FiberManagerMap data

Summary: Ran into a bug in D2158570 where we dtor'ing these data structures before the event bases destructed, so the assert on line 47 (of the old code) failed.

Reviewed By: @andriigrynenko

Differential Revision: D2198318

8 years agoBump version to 49:1 v0.49.1
Sara Golemon [Tue, 7 Jul 2015 20:45:17 +0000 (13:45 -0700)]
Bump version to 49:1

8 years agoInstall Ubuntu 12.04 LTS dependencies for Travis CI
Alexey Spiridonov [Tue, 7 Jul 2015 20:36:16 +0000 (13:36 -0700)]
Install Ubuntu 12.04 LTS dependencies for Travis CI

Summary: This is the first of a series of diffs to get folly, fbthrift, and bistro to run on Ubuntu 12.04 LTS, which is what powers Travis CI.

It's important for folly to be easily usable with Travis CI, since everything C++ depends on it, and we really want all FB open-source projects to be monitored via continuous integration to avoid breaking their OSS builds.

Thanks to @int's work on `mcrouter`, this was considerably easier than it would have been otherwise.

This puts us a hop and a skip away from actually running folly's `make && make check && make install` on Travis CI. Do y'all think this is useful?

Reviewed By: @yfeldblum

Differential Revision: D2217441

8 years agoBump version to 49:0 v0.49.0
Sara Golemon [Tue, 7 Jul 2015 17:26:57 +0000 (10:26 -0700)]
Bump version to 49:0

8 years agofolly/wangle -> wangle cutover
James Sedgwick [Mon, 6 Jul 2015 18:35:30 +0000 (11:35 -0700)]
folly/wangle -> wangle cutover

Summary: Another stab at D2111063 now that we have the go ahead to actually open up the wangle github repo

Reviewed By: @djwatson, @mdordal

Differential Revision: D2178291

8 years agocleanup CompressedList / MutableCompressedList interfaces
Philip Pronin [Mon, 6 Jul 2015 00:29:39 +0000 (17:29 -0700)]
cleanup CompressedList / MutableCompressedList interfaces

Summary: Drop those `const_cast<>` hacks.

Reviewed By: @ot

Differential Revision: D2217629

8 years agofolly/futures Update README.md
Hans Fugal [Thu, 2 Jul 2015 23:03:25 +0000 (16:03 -0700)]
folly/futures Update README.md

Summary: This is a documentation dump, with updates from the past couple weeks. Most notably, the new information about `Future<Unit>` replacing `Future<void>`.

Reviewed By: @​hannesr

Differential Revision: D2211135

8 years agoLift thrift/lib/cpp/test/TNotificationQueueTest.
Yedidya Feldblum [Thu, 2 Jul 2015 20:58:58 +0000 (13:58 -0700)]
Lift thrift/lib/cpp/test/TNotificationQueueTest.

Summary: [Folly] Lift thrift/lib/cpp/test/TNotificationQueueTest.

`NotificationQueue` is already moved into folly; move its accompanying test suite as well.

Reviewed By: @simpkins

Differential Revision: D2207104

8 years agoFix typo - ac defined are prefixed with FOLLY_
Sara Golemon [Thu, 2 Jul 2015 21:02:18 +0000 (14:02 -0700)]
Fix typo - ac defined are prefixed with FOLLY_

Summary: Got this ifdef wrong in my last change here.

Reviewed By: @paulbiss

Differential Revision: D2213708

8 years agonice error message if you try to Future<void>
Hans Fugal [Thu, 2 Jul 2015 18:43:42 +0000 (11:43 -0700)]
nice error message if you try to Future<void>

Summary: If you try to make a future or promise of `void`, you will get this nice error message telling you to use `Unit` instead.

Reviewed By: @djwatson

Differential Revision: D2211239

8 years agoAdd an exception for building on OSX.
Michael Lee [Thu, 2 Jul 2015 14:49:15 +0000 (07:49 -0700)]
Add an exception for building on OSX.

Summary: The Homebrew setup fails to compile on OSX.

Reviewed By: @paulbiss

Differential Revision: D2212084

8 years agofolly::Unit::Drop.
Yedidya Feldblum [Thu, 2 Jul 2015 01:39:41 +0000 (18:39 -0700)]
folly::Unit::Drop.

Summary: [Folly] folly::Unit::Drop.

Antisymmetric to folly::Unit::Lift.

Reviewed By: @fugalh

Differential Revision: D2211725

8 years agominor Timekeeper bug
Hans Fugal [Thu, 2 Jul 2015 01:21:28 +0000 (18:21 -0700)]
minor Timekeeper bug

Summary: Fix so `Timekeeper::at(now() - something)` works. Also introduce a test which explicitly tests when <= now codepath, which wasn't broken per se here, but which test also tickled this bug.

Reviewed By: @jsedgwick

Differential Revision: D2209166

8 years agoDiscourage Duration in code comments and tests
Hans Fugal [Thu, 2 Jul 2015 01:18:53 +0000 (18:18 -0700)]
Discourage Duration in code comments and tests

Reviewed By: @yfeldblum

Differential Revision: D2209095

8 years agoFuture<Unit> global fixup
Hans Fugal [Wed, 1 Jul 2015 22:42:50 +0000 (15:42 -0700)]
Future<Unit> global fixup

Summary: This is three codemods:

* `(folly::(Future|Promise|Try))<void>` -> `\1<folly::Unit>`
* `(Future|Promise|Try)<void>` -> `\1<Unit>`
* add `using folly::Unit` statements where needed

Then
* undo false positives in javascript files and fibers::Promise

cf D2201259, which this will land with

Reviewed By: @djwatson

Differential Revision: D2201801

8 years agoFuture<Unit> wangle fixup
Hans Fugal [Wed, 1 Jul 2015 22:42:30 +0000 (15:42 -0700)]
Future<Unit> wangle fixup

Summary: Mostly this is `s/(Promise|Future|Try)<void>/\1<Unit>/`

Reviewed By: @djwatson

Differential Revision: D2201272

8 years agoNuke Future<void> (folly/futures)
Hans Fugal [Wed, 1 Jul 2015 22:42:23 +0000 (15:42 -0700)]
Nuke Future<void> (folly/futures)

Summary: Nuke Future<void> in favor of Future<Unit>, for the `folly/futures` subdirectory.

Reviewed By: @djwatson

Differential Revision: D2201259

8 years agoDo an explicit test for XSI strerror_r
Sara Golemon [Wed, 1 Jul 2015 21:56:12 +0000 (14:56 -0700)]
Do an explicit test for XSI strerror_r

Summary: The current #if directive is a laundry list of
"strerror_r defaults to XSI style on these platforms",
and we keep missing some, so let's just do a proper test
and simplify the code directives.

Closes #232

Reviewed By: @paulbiss

Differential Revision: D2208843

8 years ago(easy) wrong test suite name
Hans Fugal [Wed, 1 Jul 2015 22:07:31 +0000 (15:07 -0700)]
(easy) wrong test suite name

Reviewed By: @yfeldblum

Differential Revision: D2209197

8 years agoImplement a BitVector-based list
Vignesh Gowda [Wed, 1 Jul 2015 21:07:37 +0000 (14:07 -0700)]
Implement a BitVector-based list

Summary: Implemented a BitVector Encoder and BitVector Reader with the same interface as EliasFanoCoding.h

Reviewed By: @ot, @philippv

Differential Revision: D2198935

8 years agofix? AutoTimerTest
Andrey Goder [Wed, 1 Jul 2015 17:37:34 +0000 (10:37 -0700)]
fix? AutoTimerTest

Summary: Apparently this test sometimes fails. @Gownta suggests it's because we're
storing temproaries in StringPiece. Change it to store in a std::string, which
should hopefully fix it.

Reviewed By: @Gownta

Differential Revision: D2208643

8 years agomake it really clear that wangle/rx is deprecated
Hans Fugal [Wed, 1 Jul 2015 17:24:18 +0000 (10:24 -0700)]
make it really clear that wangle/rx is deprecated

Summary: More people are starting to use Rx. Yay! But they're trying to use `wangle/rx`. So make sure there's no doubt about its deprecated status.

Reviewed By: @yfeldblum

Differential Revision: D2196273

8 years agoAdd missing include for flock()
Sara Golemon [Wed, 1 Jul 2015 16:00:48 +0000 (09:00 -0700)]
Add missing include for flock()

Summary: flock() expects sys/file.h which on many platforms
is getting included as a side-effect, but on at least one
this isn't the case.

Add the explicit include to fix builds on those platforms.

Closes #232

Facebook

Unrelated runtime failures.

Reviewed By: @JoelMarcey

Differential Revision: D2196306

8 years agomake folly/detail/FunctionalExcept.* work if FOLLY_HAVE_BITS_FUNCTEXCEPT_H is set...
Marc Horowitz [Tue, 30 Jun 2015 19:39:50 +0000 (12:39 -0700)]
make folly/detail/FunctionalExcept.* work if FOLLY_HAVE_BITS_FUNCTEXCEPT_H is set or not

Summary: When doing android development, we need to compile with
FOLLY_HAVE_BITS_FUNCTEXCEPT_H set for some flavors, and
FOLLY_HAVE_BITS_FUNCTEXCEPT_H unset for others (primarily for tests
run in the local (xcode) development platform).  This diff adds some
more conditionals so it all works.

In this repro, these files are never used, so this is more or less a
noop, but this is the upstream so I'm making these changes here.

Reviewed By: @Gownta

Differential Revision: D2202107

8 years agocheck ReadCallback before using it
Woo Xie [Tue, 30 Jun 2015 16:21:08 +0000 (09:21 -0700)]
check ReadCallback before using it

Summary: before the first setReadCallback(), the readCallback_ is nullptr.  Thanks @siyengar for pointing out this!

Reviewed By: @siyengar

Differential Revision: D2203489

8 years agomove the socket setting into setReadCB()
Woo Xie [Mon, 29 Jun 2015 23:43:14 +0000 (16:43 -0700)]
move the socket setting into setReadCB()

Summary: refactor D2201181

Reviewed By: @afrind

Differential Revision: D2202245

8 years agoBump version to 48:0 v0.48.0
Sara Golemon [Mon, 29 Jun 2015 18:01:35 +0000 (11:01 -0700)]
Bump version to 48:0

8 years agoa subset of folly now compiles with Windows mingw64 toolchain
Kjell Schubert [Mon, 29 Jun 2015 15:33:54 +0000 (08:33 -0700)]
a subset of folly now compiles with Windows mingw64 toolchain

Summary: a subset of folly now compiles with Windows mingw64 toolchain

Reviewed By: @djwatson

Differential Revision: D2171872

8 years agocleanup includes in folly/Format.h
Philip Pronin [Sun, 28 Jun 2015 01:09:24 +0000 (18:09 -0700)]
cleanup includes in folly/Format.h

Summary: `folly/Format.h` pulls in `folly/small_vector.h` and
`folly/FBVector.h`, which (according to @​oleksandr's analysis)
are the most expensive includes for multiple fbcode projects.

Reviewed By: @ot

Differential Revision: D2198904

8 years agoFix resplit | batch
Tom Jackson [Fri, 26 Jun 2015 20:30:07 +0000 (13:30 -0700)]
Fix resplit | batch

Summary: Resplit violated the contract of `apply()`; it returned `false` even though the input sequence was fully consumed.

Reviewed By: @philippv

Differential Revision: D2195889

8 years agoRemove double-conversion as a source dep in OS X script
Mike Arpaia [Fri, 26 Jun 2015 18:37:16 +0000 (11:37 -0700)]
Remove double-conversion as a source dep in OS X script

Summary: double-conversion was recently added to homebrew, making it the last
folly dependency to do so. this diff modifies the existing OS X
bootstrap tool to account for that. I also added an rm for the gtest
wget, so there wasn't a leftover zip file in your repo. alternatively,
we could remove that and add it to the gitignore.

Reviewed By: @fugalh

Differential Revision: D2196000

Pulled By: @sgolemon

8 years agoFix passing RequestContext to executor thread
Alex Landau [Wed, 24 Jun 2015 23:20:08 +0000 (16:20 -0700)]
Fix passing RequestContext to executor thread

Summary: If x->add() executes its lambda on a different thread and
doesn't pass the context on its own, the callback wouldn't
have the correct context set.

Reviewed By: @djwatson

Differential Revision: D2189318

8 years agoFix stop_ thread race
Dave Watson [Fri, 26 Jun 2015 16:19:32 +0000 (09:19 -0700)]
Fix stop_ thread race

Summary: make it std::atomic

Reviewed By: @tudor

Differential Revision: D2191861

8 years agoto_shared_ptr.
Yedidya Feldblum [Fri, 26 Jun 2015 06:11:30 +0000 (23:11 -0700)]
to_shared_ptr.

Summary: [Folly] to_shared_ptr.

So you can write this:

    auto sptr = to_shared_ptr(getSomethingUnique<T>());

Instead of this:

    auto sptr = shared_ptr<T>(getSomethingUnique<T>());

Useful when `T` is long, such as `T = foobar::cpp2::FooBarServiceAsyncClient`.

Reviewed By: @meyering

Differential Revision: D2193572

8 years agoopt proxygen with newly added OpenSSL functions
Woo Xie [Fri, 26 Jun 2015 03:11:55 +0000 (20:11 -0700)]
opt proxygen with newly added OpenSSL functions

Summary: this taks advantage of SSL_write_iovec and SSL_read_buf functions to improve CPU.  This eliminates one malloc+memcpy+free operation for all HTTPS traffic, and save up to two for small packets.

It saves 10~15% CPU
https://fburl.com/99681397
https://fburl.com/99427544

Reviewed By: @djwatson

Differential Revision: D1993764

8 years agoGroupBy
Tom Jackson [Thu, 25 Jun 2015 23:39:22 +0000 (16:39 -0700)]
GroupBy

Reviewed By: @ot

Differential Revision: D2188740

8 years ago(easy) remove cruft comment
Hans Fugal [Thu, 25 Jun 2015 19:17:51 +0000 (12:17 -0700)]
(easy) remove cruft comment

Summary: We have this now.

Reviewed By: @jsedgwick

Differential Revision: D2191642

8 years ago(Wangle) Fix possible race in updating FSM state
Hannes Roth [Thu, 25 Jun 2015 15:44:29 +0000 (08:44 -0700)]
(Wangle) Fix possible race in updating FSM state

Summary: Storing the new state could be a memory race according to C++ (but wasn't in practice). I only checked GCC though.

Reviewed By: @nbronson

Differential Revision: D2189287

8 years ago(Wangle) Clean up some data races in tests
Hannes Roth [Thu, 25 Jun 2015 15:41:28 +0000 (08:41 -0700)]
(Wangle) Clean up some data races in tests

Summary: Not 100% about the `ThreadWheelTimekeeper` test. It makes TSAN happy
though.

Reviewed By: @yfeldblum

Differential Revision: D2187901

8 years ago(Wangle) Fix bug with CrappyExecutors, and bad PriorityExecutor
Hannes Roth [Thu, 25 Jun 2015 15:38:14 +0000 (08:38 -0700)]
(Wangle) Fix bug with CrappyExecutors, and bad PriorityExecutor

Summary: 1) We forgot to `--attached_` if `x` throws an exception
2) `PriorityExecutor` didn't execute `Func`, causing leaks in the test (not a bug in Futures)
3) I moved up the initialization for an empty `Core` into the constructor to make it easier to see

Reviewed By: @jsedgwick

Differential Revision: D2187343

8 years agoDon't hardcode thread limit in ServerBootstrap
Sara Golemon [Wed, 24 Jun 2015 17:48:20 +0000 (10:48 -0700)]
Don't hardcode thread limit in ServerBootstrap

Summary: This was set to 32 which probably works fine for the
majority of FB servers, but not everyone's system is so endowed.

Closes #119

Reviewed By: @fredemmott

Differential Revision: D2187008

8 years ago(Wangle) Remove unnecessary constructor argument to CollectAnyContext
Hannes Roth [Wed, 24 Jun 2015 17:20:39 +0000 (10:20 -0700)]
(Wangle) Remove unnecessary constructor argument to CollectAnyContext

Summary: See title.

Reviewed By: @fugalh

Differential Revision: D2186833

8 years agoFix tests for glog and gflags
Sara Golemon [Wed, 24 Jun 2015 16:31:49 +0000 (09:31 -0700)]
Fix tests for glog and gflags

Summary: The existing tests were trying to find undocumented
symbols in glog/glags which aren't guaranteed to be there on all
platforms.

Use AC_RUN_IFELSE() to try building and executing some code
typical of the usage of these libraries.

Closes #117

Reviewed By: @JoelMarcey

Differential Revision: D2183526

8 years agoChange visibility of folly::Arena constructors to public
Sara Golemon [Wed, 24 Jun 2015 16:32:24 +0000 (09:32 -0700)]
Change visibility of folly::Arena constructors to public

Summary: In the case of the copy constructor, this change
doesn't really matter, since it's deleted anyway.

In the case of the move constructor, it fixes what was probably
an unintentional hiding.  The class certainly looks like
it supports moving.

Closes #121

Reviewed By: @yfeldblum

Differential Revision: D2184131

8 years agoFix copy/pasta in docs
Sara Golemon [Wed, 24 Jun 2015 16:32:42 +0000 (09:32 -0700)]
Fix copy/pasta in docs

Summary: svformat explicitly takes a container for direct indexing,
but the format string used is per-arg, which corresponds to format/sformat.

Closes #228

Reviewed By: @JoelMarcey

Differential Revision: D2184334

8 years agoUpdate README.md to refer to homebrew Formula
Sara Golemon [Wed, 24 Jun 2015 16:33:02 +0000 (09:33 -0700)]
Update README.md to refer to homebrew Formula

Summary: Release builds should probably favor using
@marpaia's brew Formula to get a release build.

Leave the boostrap script around to simplify building
from master.

Closes #229

Reviewed By: @jwatzman

Differential Revision: D2184416

8 years ago(Wangle) Possibly undefined behavior in collect
Hannes Roth [Wed, 24 Jun 2015 15:55:44 +0000 (08:55 -0700)]
(Wangle) Possibly undefined behavior in collect

Summary: Not sure if this is really undefined behavior or whether UBSAN is just super paranoid. Will try to read up on it later.

I also changed some other `std::atomic` initialization to always follow the same pattern, let me know if I should revert those. I couldn't resist, OCD kicked in.

idonthaveocd

Reviewed By: @fugalh

Differential Revision: D2181074

8 years agoProvide backfill s6_addr16 on BSD platforms
Sara Golemon [Tue, 23 Jun 2015 22:44:37 +0000 (15:44 -0700)]
Provide backfill s6_addr16 on BSD platforms

Summary: Extend the MacOS s6_addr16 hack to Net/Open/FreeBSD

Closes #106

Reviewed By: @JoelMarcey

Differential Revision: D2182912

8 years agoFutex: ignore errors on wake
Anton Likhtarov [Tue, 23 Jun 2015 02:31:17 +0000 (19:31 -0700)]
Futex: ignore errors on wake

Summary: See the comment for details

Reviewed By: @nbronson

Differential Revision: D2181231

8 years agorearrange Pipeline to have more functionality in PipelineBase
James Sedgwick [Tue, 23 Jun 2015 18:21:34 +0000 (11:21 -0700)]
rearrange Pipeline to have more functionality in PipelineBase

Summary: This way, handlers can carry out more complex manipulations of the pipeline via ctx->getPipeline() without knowing the R/W types

Reviewed By: @djwatson

Differential Revision: D2158736

8 years agoFix for clang (llvm 3.7.0+)
191919 [Tue, 23 Jun 2015 16:59:11 +0000 (09:59 -0700)]
Fix for clang (llvm 3.7.0+)

Summary: Roughly described in https://github.com/facebook/hhvm/issues/5344.

Closes #206

Reviewed By: @yfeldblum

Differential Revision: D2170803

Pulled By: @sgolemon

8 years agoRemove -Wno-inconsistent-missing-override suppression in folly
Igor Sugak [Tue, 23 Jun 2015 16:01:38 +0000 (09:01 -0700)]
Remove -Wno-inconsistent-missing-override suppression in folly

Summary: It is fixed in gmock. No need to suppress it in sources.

Reviewed By: @meyering

Differential Revision: D2181564

8 years agoinstance Eq Unit
Yedidya Feldblum [Tue, 23 Jun 2015 03:29:35 +0000 (20:29 -0700)]
instance Eq Unit

Summary: [Folly] instance Eq Unit

    Unit::operator==(const Unit&)
    Unit::operator!=(const Unit&)

Reviewed By: @Gownta

Differential Revision: D2179384

8 years agoAdd missing override and remove redundant virtual in folly
Igor Sugak [Mon, 22 Jun 2015 23:40:19 +0000 (16:40 -0700)]
Add missing override and remove redundant virtual in folly

Summary: Running clang-tidy to fix this problem, using script D2171334.

I noticed that even without this change clang dev build succeeds for folly and opened a separate task to investigate why.

Reviewed By: @markisaa

Differential Revision: D2179299

8 years agoAdd ./configure check for vsnprintf returning negative on error
Mike Kaplinskiy [Mon, 22 Jun 2015 23:15:24 +0000 (16:15 -0700)]
Add ./configure check for vsnprintf returning negative on error

Summary: This is slightly more correct than assuming that
__APPLE__ is the only place this assumption breaks.

Pulled from relevant section of folly-PR#95, other sections
are either already applied by other fixes, or have been code-moved.

Closes #95

Reviewed By: @jwatzman

Differential Revision: D2178439

8 years agoBuilding instructions for MAC OS X (MacPorts)
Adriano Melo [Mon, 22 Jun 2015 17:15:46 +0000 (10:15 -0700)]
Building instructions for MAC OS X (MacPorts)

Summary: Tested on Mac OS X 10.10.3 and MacPorts 2.3.3.
Closes #227

Reviewed By: @yfeldblum

Differential Revision: D2176700

Pulled By: @sgolemon

8 years agoBump version to 47:0 v0.47.0
Sara Golemon [Sun, 21 Jun 2015 18:59:51 +0000 (11:59 -0700)]
Bump version to 47:0

8 years agonew small_vector tests that fail on trunk and uncover a bug in emplace_back on refere...
Yoni Lavi [Sat, 20 Jun 2015 14:45:56 +0000 (07:45 -0700)]
new small_vector tests that fail on trunk and uncover a bug in emplace_back on references to memory inside the vector + a fix + perf improvement to const lvalue push_back

Summary: emplace_back() on a small_vector applied on data inside the vector doesn't work properly.
In standard vectors, this usage is required to work properly, but I'm not sure whether it should in small_vector. Consider fixing / adding a lint rule.

Reviewed By: @yfeldblum

Differential Revision: D2122931

8 years agoARM64 assembler fixes for Folly.
Ananth Jasty [Fri, 19 Jun 2015 02:16:22 +0000 (19:16 -0700)]
ARM64 assembler fixes for Folly.

Summary: Wrap asm("pause") in an inline so that it becomes
asm("wfe") on aarch64.

Closes #187
Closes #190

Reviewed By: @yfeldblum

Differential Revision: D2152868

Pulled By: @sgolemon

8 years agothen() ropagates exceptions properly
Sam Merat [Thu, 18 Jun 2015 18:42:07 +0000 (11:42 -0700)]
then() ropagates exceptions properly

Summary: fixed then() exceptions propagation and added unit-test

Reviewed By: @fugalh

Differential Revision: D2159075

8 years agoMove folly::compression::Instructions to a separate file
Vignesh Gowda [Thu, 18 Jun 2015 17:00:51 +0000 (10:00 -0700)]
Move folly::compression::Instructions to a separate file

Summary: Moved abstraction layer for platform-specific bit-manipulation instructions from the EliasFanoCoding.h to Instructions.h since we will need to use it also for BitVectors:

Reviewed By: @ot

Differential Revision: D2165314

8 years agomove SharedMutex from folly/experimental to folly
Nathan Bronson [Wed, 17 Jun 2015 21:27:06 +0000 (14:27 -0700)]
move SharedMutex from folly/experimental to folly

Summary: SharedMutex has been in heavy production use for a while with no
bugs reported and no API changes requested, it is no longer experimental.

Reviewed By: @yfeldblum

Differential Revision: D2165275

8 years agoCheck array get for < 0
Marc Horowitz [Wed, 17 Jun 2015 18:06:45 +0000 (11:06 -0700)]
Check array get for < 0

Summary: dynamic's integer type is signed, so make sure array indices
are not negative.

(See https://our.intern.facebook.com/intern/tasks/?t=7445055)

Reviewed By: @Gownta

Differential Revision: D2145689

8 years agouse Unit in Pipeline
James Sedgwick [Tue, 16 Jun 2015 17:31:02 +0000 (10:31 -0700)]
use Unit in Pipeline

Summary: Instead of the one-off Nothing struct

Reviewed By: @yfeldblum

Differential Revision: D2158621

8 years agovarious perf improvements
James Sedgwick [Tue, 16 Jun 2015 17:30:18 +0000 (10:30 -0700)]
various perf improvements

Summary: Three strategies
1. Optimistic locking
2. Acquire-release memory ordering instead of full sequential consistency
3. Some low-hanging branch miss optimizations

Please review carefully; the dogscience is strong with this one

```
Before:

============================================================================
folly/futures/test/Benchmark.cpp                relative  time/iter  iters/s
============================================================================
constantFuture                                             127.99ns    7.81M
promiseAndFuture                                  94.89%   134.89ns    7.41M
withThen                                          28.40%   450.63ns    2.22M
----------------------------------------------------------------------------
oneThen                                                    446.68ns    2.24M
twoThens                                          58.35%   765.55ns    1.31M
fourThens                                         31.87%     1.40us  713.41K
hundredThens                                       1.61%    27.78us   35.99K
----------------------------------------------------------------------------
no_contention                                                4.63ms   216.00
contention                                        80.79%     5.73ms   174.52
----------------------------------------------------------------------------
throwAndCatch                                               10.91us   91.64K
throwAndCatchWrapped                             127.14%     8.58us  116.51K
throwWrappedAndCatch                             178.22%     6.12us  163.32K
throwWrappedAndCatchWrapped                      793.75%     1.37us  727.38K
----------------------------------------------------------------------------
throwAndCatchContended                                        1.35s  741.33m
throwAndCatchWrappedContended                    139.18%   969.23ms     1.03
throwWrappedAndCatchContended                    169.51%   795.76ms     1.26
throwWrappedAndCatchWrappedContended            17742.23%     7.60ms   131.53
----------------------------------------------------------------------------
complexUnit                                                127.50us    7.84K
complexBlob4                                     100.14%   127.32us    7.85K
complexBlob8                                     100.16%   127.30us    7.86K
complexBlob64                                     96.45%   132.19us    7.57K
complexBlob128                                    92.83%   137.35us    7.28K
complexBlob256                                    87.79%   145.23us    6.89K
complexBlob512                                    81.64%   156.18us    6.40K
complexBlob1024                                   72.54%   175.76us    5.69K
complexBlob2048                                   58.52%   217.89us    4.59K
complexBlob4096                                   32.54%   391.78us    2.55K
============================================================================

After:
============================================================================
folly/futures/test/Benchmark.cpp                relative  time/iter  iters/s
============================================================================
constantFuture                                              85.28ns   11.73M
promiseAndFuture                                  88.63%    96.22ns   10.39M
withThen                                          30.46%   279.99ns    3.57M
----------------------------------------------------------------------------
oneThen                                                    231.18ns    4.33M
twoThens                                          60.57%   381.70ns    2.62M
fourThens                                         33.52%   689.71ns    1.45M
hundredThens                                       1.49%    15.48us   64.58K
----------------------------------------------------------------------------
no_contention                                                3.84ms   260.19
contention                                        88.29%     4.35ms   229.73
----------------------------------------------------------------------------
throwAndCatch                                               10.63us   94.06K
throwAndCatchWrapped                             127.17%     8.36us  119.61K
throwWrappedAndCatch                             179.83%     5.91us  169.15K
throwWrappedAndCatchWrapped                     1014.48%     1.05us  954.19K
----------------------------------------------------------------------------
throwAndCatchContended                                        1.34s  749.03m
throwAndCatchWrappedContended                    140.66%   949.16ms     1.05
throwWrappedAndCatchContended                    164.87%   809.77ms     1.23
throwWrappedAndCatchWrappedContended            49406.39%     2.70ms   370.07
----------------------------------------------------------------------------
complexUnit                                                 86.83us   11.52K
complexBlob4                                      97.42%    89.12us   11.22K
complexBlob8                                      96.63%    89.85us   11.13K
complexBlob64                                     92.53%    93.84us   10.66K
complexBlob128                                    90.85%    95.57us   10.46K
complexBlob256                                    82.56%   105.17us    9.51K
complexBlob512                                    74.13%   117.12us    8.54K
complexBlob1024                                   63.67%   136.37us    7.33K
complexBlob2048                                   50.25%   172.79us    5.79K
complexBlob4096                                   26.63%   326.05us    3.07K
============================================================================
```

Reviewed By: @djwatson

Differential Revision: D2139822

8 years agoUsing emplace_back to avoid temporary
Praveen Kumar [Tue, 16 Jun 2015 17:02:00 +0000 (10:02 -0700)]
Using emplace_back to avoid temporary

Summary: Directly pass the arguments to respective constructors.
Instead of first making temporary and then pass that.

Closes #218

Reviewed By: @yfeldblum

Differential Revision: D2156978

Pulled By: @sgolemon

8 years agoBump version to 46:0
Sara Golemon [Tue, 16 Jun 2015 03:24:49 +0000 (20:24 -0700)]
Bump version to 46:0