IPAddress::empty()

Summary: Checks if IPAddress has not been initialized.

Test Plan: unit test

Reviewed By: tudorb@fb.com

Subscribers: tudorb

FB internal diff: D1459525
Move TDelayedDestruction to folly::DelayedDestruction

Summary: This doesn't have many thrift dependencies and I need it for another async class I'm adding to folly.

Test Plan: unit tests

Reviewed By: alandau@fb.com

Subscribers: doug, mcduff, marccelani, mshneer, alandau, bmatheny

FB internal diff: D1453095
Construct Later with exception_ptr

Summary:
It would be nice to be able to create a Later with pre-loaded
exception.

Test Plan: Unit test

Reviewed By: hans@fb.com

Subscribers: fugalh

FB internal diff: D1462810
install delayeddestruction header

Summary: added recently, needs to be installed

Test Plan: watch fbthrift contbuild

Reviewed By: noamz@fb.com

Subscribers: doug

FB internal diff: D1469760

Blame Revision: D1453095
API for getTimeoutManager

Test Plan: Tested end-to-end with D1342452

Reviewed By: mshneer@fb.com

Subscribers: alandau, bmatheny

FB internal diff: D1470814

Tasks: 2682011
EliasFanoReader::goTo()

Summary: Random lookup support.

Test Plan: fbconfig -r folly/experimental/test:eliasfano_test && fbmake runtests_opt -j32

@override-unit-failures

Reviewed By: soren@fb.com

FB internal diff: D1473244

Tasks: 4536072
rfc: move folly::json::ParseError type to folly/json.h

Summary:
I don't know why this was in the cpp but seems pretty safe to move it to the .h
There are a few files that directly include json.cpp to get around this: https://fburl.com/30544625.
I need it for something else and if you dont see a problem I want to move it.

Test Plan: unittests

Reviewed By: pgriess@fb.com

Subscribers: simpkins, doug

FB internal diff: D1471958

Tasks: 3623725
Don't check for thread running in terminateLoopSoon()

Summary:
Consider this use case:
thread 1:
make an evb
create and start thread 2
do some work
evb->terminateLoopSoon()
join thread 2 with a timeout
thread 2:
do some initialization
evb->loop()
Normally, this all works fine.  However, if the work thread 1 has to do is sufficiently small, and no external input occurs (one of the thing the evb is doing is listening on a socket), then sometimes, terminateLoopSoon() happens before loop() is called (or at least, before loopThread_.store() happens). isRunning() in terminateLoopSoon() is false, and so stop_ is never set, and event_base_loopbreak() is never called. The join times out, and thread 2 is still running.  Removing the isRunning() check gives the desired behavior.

Test Plan:
In my ad hoc tests, this fix caused my threads to exit when
I wanted them to exit in a situation like the one above.

Reviewed By: andrewcox@fb.com

FB internal diff: D1455885

Tasks: 2057547
sorted_vector containers have a shrink_to_fit() method

Summary: Adds a shrink_to_fit() method to sorted vector types.

Test Plan: unit test

Reviewed By: mshneer@fb.com

FB internal diff: D1477864
folly/IndexedMemPool: correct an erroneous test for failed mmap

Summary:
* folly/IndexedMemPool.h (IndexedMemPool): Correct the test for
failed mmap.  Upon failure, it returns MAP_FAILED, not nullptr.

Test Plan:
fbconfig -r folly/test:indexed_mem_pool_test && fbmake runtests

Reviewed By: ngbronson@fb.com

FB internal diff: D1480389

Tasks: 4846893
@override-unit-failures
streaming support for EF compression

Test Plan: fbconfig -r folly/experimental/test:eliasfano_test && fbmake opt -j32

Reviewed By: lucian@fb.com

Subscribers: chaoyc, search-fbcode-diffs@, unicorn-diffs@

FB internal diff: D1474625

Tasks: 4828866
folly/test: correct an erroneous test for failed mmap

Summary:
* folly/test/AtomicHashArrayTest.cpp (MmapAllocator):
Upon failure, mmap returns MAP_FAILED, not NULL.

Test Plan:
fbconfig -r folly/test:atomic_hash_array_test && fbmake runtests

Reviewed By: mwang@fb.com

FB internal diff: D1481080

Tasks: 4846893
Improve IPAddress::toFullyQualified() CPU performance

Summary:
Currently IPAddress::toFullyQualified() is fairly slow for IPv6.

Change here implements more lightweight in_addr/in6_addr to string functions.

I also added a benchmark for comparison with inet_ntop.

This makes IPAddressV6::toFullyQualified() significantly faster than inet_ntop, and makes IPAddressV4::str() ~20ns faster than previous impementation (previously ~80ns).

Previous benchmark:
============================================================================
folly/test/IPAddressBenchmark.cpp               relative  time/iter  iters/s
============================================================================
ipv4_to_string_inet_ntop                                   238.91ns    4.19M
ipv4_to_fully_qualified                          289.96%    82.39ns   12.14M
----------------------------------------------------------------------------
ipv6_to_string_inet_ntop                                   780.72ns    1.28M
ipv6_to_fully_qualified                           51.11%     1.53us  654.59K
============================================================================

With this change:
============================================================================
folly/test/IPAddressBenchmark.cpp               relative  time/iter  iters/s
============================================================================
ipv4_to_string_inet_ntop                                   238.06ns    4.20M
ipv4_to_fully_qualified                          364.76%    65.26ns   15.32M
----------------------------------------------------------------------------
ipv6_to_string_inet_ntop                                   770.74ns    1.30M
ipv6_to_fully_qualified                          791.63%    97.36ns   10.27M
============================================================================

Test Plan:
fbconfig folly/test:network_address_test folly/test:network_address_benchmark
fbmake runtests_opt

Reviewed By: simpkins@fb.com

Subscribers: ps, bmatheny

FB internal diff: D1477925

Tasks: 4832974
EliasFanoReader::{jump,jumpTo}

Summary:
Renamed `goTo` to `jump`, introduced `jumpTo`.

FBCode: Updated CSS tree benchmark to compare with EF-based search that
is using `jumpTo` (P14517259).

Test Plan: fbconfig -r folly/experimental/test:eliasfano_test && fbmake runtests_opt -j32

@override-unit-failures

Reviewed By: lucian@fb.com

Subscribers: fbcode-common-diffs@

FB internal diff: D1474431

Tasks: 4536072
Add timed_wait and try_wait to Baton

Summary:
This diff adds timed_wait that allows waiting on the Baton
with a timeout. The diff also adds try_wait which doesn't
block the thread at all.

Test Plan:
-- added new unit tests
-- ran all folly tests

Reviewed By: ngbronson@fb.com

Subscribers: bwatling

FB internal diff: D1468909

Tasks: 4679428
store ipaddresses in folly::IPAddress

Summary: Save space and avoid extra mallocs

Test Plan: fbconfig -r smc/zeus; fbmake runtests

Reviewed By: henryf@fb.com

Subscribers: zeus-diffs@

FB internal diff: D1476688

Tasks: 4832974
Fix test breakage in clang

Summary:
clang would re-use the same memory location for recreated
objects, so instead of checking pointers, we can use a serial number.

Test Plan: runtests with fbconfig --clang

Reviewed By: lins@fb.com

Subscribers: mathieubaudet, lins, anca

FB internal diff: D1485907
always log from LOG_EVERY_MS if interval is <= 0

Summary:
This diff changes LOG_EVERY_MS so that if the specified
interval is zero or negative, no clock call is made and LOG(severity) is
always called.  milli_interval is copied into a temporary to avoid
double-evaluation.

Test Plan:
1. unit tests
2. new unit test

Reviewed By: lesha@fb.com

FB internal diff: D1469366

Tasks: 4813858
folly: operator << for MutableStringPiece

Test Plan: n.a

Reviewed By: philipp@fb.com

FB internal diff: D1487919
Small memory footprint reduction for folly::MultiLevelTimeSeries

Summary:
* Spend some extra time in getNumBuckets() in order to save
space: 8 bytes per object on 64-bit platforms.

Test Plan: Ran the unit tests

Reviewed By: simpkins@fb.com

Subscribers: ruibalp

FB internal diff: D1488345