1. 09 Sep, 2014 15 commits
    • Daniel Sommermann's avatar
      Fix compilation warning · 9a5abb71
      Daniel Sommermann authored
      Summary:
      Defining hash as a struct and a class was causing some junk to
      get printed during fbmake.
      
      Test Plan: `fbconfig -r proxygen; fbmake dbg`, ran unit tests, didn't see output
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: doug, shilin, njormrod
      
      FB internal diff: D1514793
      9a5abb71
    • Nicholas Ormrod's avatar
      Fix block overhead estimation in tests · cec3fa89
      Nicholas Ormrod authored
      Summary:
      folly/test/ArenaTest.h assumes that goodMallocSize will account
      for the block overhead, if the size is +1. However, when compiling
      without jemalloc (as, I would imagine, most of our open-source clients
      do), goodMallocSize(64 + 1) returns 65, which is less than 64 +
      sizeof(Block), and so the tests fail.
      
      I have added a constant to Arena.h which exposes the overhead taken by
      the Block, and changed the tests to use that value instead of 1.
      (Arena::getTotalSize relies on the totalAllocatedSize_ variable, which
      is only non-trivially set in allocateSlow, where the size of the heap is
      added to sizeof(Block)).
      
      Test Plan: fbconfig --allocator=malloc folly/test:arena_test && fbmake runtests
      
      Reviewed By: jon.coens@fb.com
      
      Subscribers: sdwilsh, njormrod
      
      FB internal diff: D1512231
      cec3fa89
    • Sean Cannella's avatar
      Fix various compiler warnings · 5899b4ed
      Sean Cannella authored
      Summary:
      This allows projects that use -Wextra (sans -Wunused-parameter) to
      compile folly.
      
      Test Plan: compiled with gcc and clang
      
      Reviewed By: meyering@fb.com
      
      Subscribers: njormrod, kmdent, fma, benyluo, shikong, ranjeeth, subodh, pgriess
      
      FB internal diff: D1509827
      5899b4ed
    • Nicholas Ormrod's avatar
      Fix #includes · e892dc54
      Nicholas Ormrod authored
      Summary:
      A few of folly's includes do not start with folly/, and so were
      missed by D1411225's include-quotation ##""## -> ##<>## transformation change.
      There were also some folly includes in deeper folly directories and the
      docs, which I also fixed.
      
      The search ##egrep "# *include *\"" -R folly/*## now only includes two
      lines in FBString.h, which are included for libgcc purposes.
      
      The wangle/test/Thens.cpp file, which is auto-generated, was special.
      I changed the generator .rb script, but when I ran it I overwrote some
      manual changes to Thens.cpp. For simplicity, I have manually applied the
      change to Thens.cpp as well.
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: sdwilsh, fugalh
      
      FB internal diff: D1511712
      e892dc54
    • Jim Meyering's avatar
      fbcode: __x__-protect all __attribute__ keywords, mechanically · a42878e3
      Jim Meyering authored
      Summary:
      The first (and sometimes 2nd) argument to __attribute__
      should begin and end with "__". If it does not, then it
      is at risk of conflicting with user cpp-defined symbols.
      Don't do that.  This change mechanically corrects most
      such violations in fbcode.  A companion change (see parent task)
      adds a lint rule to help keep things clean going forwards.
      
      Define this function to filter the list of file names to which
      we will apply the transformations. First, ensure we modify only
      C and C++ sources.  The second process excludes a few directories
      that appear to contain third-party code:
      
      filter() {
      grep -E '\.(c|h|cc|cpp|hpp)$' | grep -vE \
      '^external/|/unbound/|/gearmand_|(3rd|third.)party|/external/libevent'
      }
      
      then, run this command,
      
      git grep -l __attribute__ | filter \
      | xargs perl -pi -e 's/(__attribute__ *)\(\(( *[^_]\w+)/$1((__${2}__/g'
      
      inducing changes like this, for each such keyword:
      
      -} __attribute__((packed));
      +} __attribute__((__packed__));
      
      That got all but the __format__ archetype arguments like this:
      __attribute__((__format__(printf.  That final "printf"
      keyword should have the "__" prefix and suffix, too.
      
      Run this command to transform those remaining uses:
      
      git grep -l '__attribute__.*__format' | filter | xargs perl -pi -e \
      's/(__attribute__ *\(\(__format__ *)\( *(printf|scanf|strftime|strfmon)/$1(__${2}__/g'
      
      That command induces changes like this:
      
      -static inline int __attribute__ ((__format__ (printf, 3, 4)))
      +static inline int __attribute__ ((__format__ (__printf__, 3, 4)))
      
      This exercise is useful to avoid spurious name-space conflicts,
      especially when the unprotected keyword is used in a header file.
      
      Test Plan:
      I've ensured tao builds and passes its tests.
      I will watch the arc-run tests.
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: rounak, trunkagent, hphp-diffs@, nli, ps, fbcode-common-diffs@, mcdonald, chaoyc, bill, search-fbcode-diffs@, lars, net-systems@, davejwatson, varunk, ruibalp, hero-diffs@, andrewcox, sorg, dfechete, dhruba, sdoroshenko, mcduff, marccelani, hitesh, mshneer, cold-storage-diffs@, omry, jcoens, unicorn-diffs@, ldbrandy, sumeet, abirchall, fugalh, atlas2-eng@, dcapra, mpawlowski, alandau, nkgupta, shilin, bmatheny, everstore-dev@, zhuohuang, wormhole-diffs@, vnalla, msk, maoy, mwa, jgehring, adsatlasreporting@, mconnor, oujin, bwester, micha, tulloch, ptc, logdevice-diffs, alikhtarov, shikong, fuegen
      
      FB internal diff: D1508983
      
      Tasks: 4947824
      @override-unit-failures
      a42878e3
    • Dave Watson's avatar
      Add link-local scope handling · 4547b603
      Dave Watson authored
      Summary: Also save the link-local scope in the V6 address.  See D1479365 for more details
      
      Test Plan: fbconfig folly/test:network_address_test; fbmake runtests
      
      Reviewed By: simpkins@fb.com
      
      Subscribers: marccelani, doug, ps, bmatheny
      
      FB internal diff: D1486435
      4547b603
    • Marcin Pawlowski's avatar
      made toAppendDelim better · 46e3ed29
      Marcin Pawlowski authored
      Summary:
      preallocate once and for all, so that we
      are really malloc efficient in toAppendDelim
      
      Test Plan: unit tests
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D1496310
      
      Tasks: 4886092
      46e3ed29
    • Nicholas Ormrod's avatar
      Fix Optional test for -fb platform · 1cab639b
      Nicholas Ormrod authored
      Summary:
      The Optional test relied on std::string clearing its data when
      it is the source of a move. This does not happen for in-situ fbstrings,
      so the test breaks in the -fb platform. The solution: wrap the string in
      a class that explicitly invalidates its data upon a move.
      
      Test Plan:
      fbconfig --platform-all=gcc-4.8.1-glibc-2.17-fb -r folly
      fbmake runtests
      fbconfig -r folly
      fbmake runtests
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: sdwilsh
      
      FB internal diff: D1506840
      
      Tasks: 4943996
      1cab639b
    • Tom Jackson's avatar
      hash_range · 33f1f3d1
      Tom Jackson authored
      Test Plan: Unit test
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: shilin
      
      FB internal diff: D1497250
      33f1f3d1
    • Hannes Roth's avatar
      (Wangle) Optimize empty continuation · a8218a39
      Hannes Roth authored
      Summary: It should remove one malloc as per the task.
      
      Test Plan: `fbconfig folly/wangle && fbmake runtests` Also, `--clang`.
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: fugalh
      
      FB internal diff: D1498331
      
      Tasks: 4913277
      a8218a39
    • Tudor Bosman's avatar
      Add Optional::value_or · 65902504
      Tudor Bosman authored
      Summary:
      Common pattern: a function returns Optional<X>, indicating whether some X was
      present or not; you want a default value if the X was not present. Requires
      that X is copiable.
      
      Test Plan: optional_test (test added)
      
      Reviewed By: tjackson@fb.com
      
      Subscribers: aalexandre, fjargsto, jhj, ntv, lesha, kma
      
      FB internal diff: D1502397
      65902504
    • Jez Ng's avatar
      Fix json_test's lookup of test files. · 32a19232
      Jez Ng authored
      Summary:
      The test runner for folly seems to run from folly/test rather than the base fbcode directory. This hack ensures that we find the necessary test files in either case.
      
      This fixes the breakage introduced by {D1493963}.
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: dipanshu
      
      FB internal diff: D1502161
      32a19232
    • Andrey Kashin's avatar
      Enabling folly::Synchronized for non-default constructible objects · d77b369f
      Andrey Kashin authored
      Summary:
      Currently folly::Synchronized can't be used with non-default
      constructible types because copy and move constructors require
      creation of datum_ before it's assignment.
      To fix this we can initialize them in initializer-list and
      handle guard creation using helper constructor
      
      Test Plan:
      fbconfig -r folly && fbmake runtests
      Fixes compilation error: Synchronized started working for non-default
      constructible types in my project(rfe).
      
      Reviewed By: yuri@fb.com
      
      Subscribers: dhruvbird
      
      FB internal diff: D1502110
      d77b369f
    • Darren Mo's avatar
      Clang Love · 7ec1fc0e
      Darren Mo authored
      Summary: Added support for clang in Checksum.cpp preprocessor statements.
      
      Test Plan: The right code path is chosen using both gcc and clang now.
      
      Reviewed By: brianp@fb.com
      
      Subscribers: mathieubaudet, sroy, satadru
      
      FB internal diff: D1502289
      7ec1fc0e
    • Jez Ng's avatar
      Factor out JSON stripComments(). · 34307dc2
      Jez Ng authored
      Summary:
      Comments are a useful extension to JSON, especially for configuration files.
      
      Facebook: twagent would previously barf on JSON files that contained '//' in their strings, and this commit allows twagent to strip comments properly. Fixes T4686066.
      
      Test Plan: fbconfig common/json mcrouter/lib/config tupperware/agent && fbmake runtests
      
      Reviewed By: aravindn@fb.com
      
      Subscribers: anarayanan, pavlo, stepan, dipanshu, alikhtarov
      
      FB internal diff: D1493963
      
      Tasks: 4686066
      34307dc2
  2. 15 Aug, 2014 5 commits
  3. 14 Aug, 2014 20 commits
    • Sara Golemon's avatar
      Bump version to 3:0 · c56f3152
      Sara Golemon authored
      c56f3152
    • Hannes Roth's avatar
      (Wangle) Generic void star callback wrapper · 2a015b5f
      Hannes Roth authored
      Summary: Less generic than I hoped for. Naming is terrible.
      
      Test Plan:
      `fbconfig -r tao/client && fbmake runtests` -- I figured if it compiles
      it works. Also did a `--sanitize=address` build just in case.
      
      Reviewed By: hans@fb.com
      
      Subscribers: fugalh, zhuohuang, anca
      
      FB internal diff: D1470483
      2a015b5f
    • Philip Pronin's avatar
      fix build (gtest 1.6 -> 1.7) · 4b8e47d6
      Philip Pronin authored
      Summary:
      D1494614 migrated us to gtest 1.7 which broke multiple builds (with
      "error: 'tuple' is already declared in this scope" coming from
      https://code.google.com/p/googletest/source/detail?spec=svn621&r=621).
      This diff makes folly compatible with both versions of gtest, and the rest
      of fbcode is now compatible with gtest 1.7.
      
      Test Plan: fbconfig -r folly unicorn/diskindex4 && fbmake opt -j32
      
      Reviewed By: jiayan@fb.com
      
      Subscribers: fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, sdoroshenko, cold-storage-diffs@, unicorn-diffs@
      
      FB internal diff: D1497389
      
      Tasks: 4909974, 4910547, 4910567, 4909983
      4b8e47d6
    • Ranjeeth Dasineni's avatar
      move EvictingCacheMap to folly · 3ff4b4f4
      Ranjeeth Dasineni authored
      Summary:
      adding @agartrell's implementation of EvictingCacheMap to folly. Its a general purpose
      cache with LRU eviction. It maintains a doubly linked list threaded throught a hash map using
      boost::intrusive. set, get and delete are all constant time operations.  It is not thread safe.
      
      Configurability: It allows callers to specify a hasher for the keys, has callbacks for eviction
      events and the number of evictions on reaching a capacity limit is configurable. resizing for
      a higher capacity though could be suboptimal since index is not resized accordingly and you could
      end up with a bad load factor.
      
      Test Plan: unit tests
      
      Reviewed By: tulloch@fb.com, njormrod@fb.com
      
      Subscribers: tulloch, chrisbray, mhx, doug, agartrell
      
      FB internal diff: D1483789
      3ff4b4f4
    • Josh Watzman's avatar
      Remove constructor version attribute on OS X · be419a8e
      Josh Watzman authored
      Summary:
      OS X doesn't support this -- it requires support at the linker
      level which OS X just doesn't have. Reasonable OS X compilers will yell
      about it, but even the ones that don't are just silently dropping it
      on the floor.
      
      So I'm not sure what //we// can do other than just silently dropping
      this on the floor too and hoping that everything works.
      
      Test Plan:
      HHVM build on OS X gets ever so slightly further (runs into
      other issues). HHVM build in fbcode still seems to build folly okay
      (didn't wait for it to finish fully).
      
      Fixes https://github.com/facebook/folly/issues/78
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1487191
      
      Blame Revision: rFBCODE502be7cb0fda306ddc33b9c5ad7a53b0cfbdc893
      be419a8e
    • Brian Pane's avatar
      Small memory footprint reduction for folly::MultiLevelTimeSeries · 747f8a8e
      Brian Pane authored
      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
      747f8a8e
    • Lucian Grijincu's avatar
      folly: operator << for MutableStringPiece · 8925b642
      Lucian Grijincu authored
      Test Plan: n.a
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D1487919
      8925b642
    • Nathan Bronson's avatar
      always log from LOG_EVERY_MS if interval is <= 0 · f13e9e39
      Nathan Bronson authored
      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
      f13e9e39
    • Chip Turner's avatar
      Fix test breakage in clang · e3e6edad
      Chip Turner authored
      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
      e3e6edad
    • Marc Celani's avatar
      store ipaddresses in folly::IPAddress · a1f3fd04
      Marc Celani authored
      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
      a1f3fd04
    • Sarang Masti's avatar
      Add timed_wait and try_wait to Baton · a3b85e00
      Sarang Masti authored
      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
      a3b85e00
    • Philip Pronin's avatar
      EliasFanoReader::{jump,jumpTo} · 297d5cee
      Philip Pronin authored
      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
      297d5cee
    • Henry Filgueiras's avatar
      Improve IPAddress::toFullyQualified() CPU performance · 59bd43f8
      Henry Filgueiras authored
      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
      59bd43f8
    • Jim Meyering's avatar
      folly/test: correct an erroneous test for failed mmap · 1fc548e1
      Jim Meyering authored
      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
      1fc548e1
    • Philip Pronin's avatar
      streaming support for EF compression · 942204a4
      Philip Pronin authored
      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
      942204a4
    • Jim Meyering's avatar
      folly/IndexedMemPool: correct an erroneous test for failed mmap · af59f4c1
      Jim Meyering authored
      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
      af59f4c1
    • Marc Celani's avatar
      sorted_vector containers have a shrink_to_fit() method · 7ce33845
      Marc Celani authored
      Summary: Adds a shrink_to_fit() method to sorted vector types.
      
      Test Plan: unit test
      
      Reviewed By: mshneer@fb.com
      
      FB internal diff: D1477864
      7ce33845
    • Marc Horowitz's avatar
      Don't check for thread running in terminateLoopSoon() · 2215f6c0
      Marc Horowitz authored
      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
      2215f6c0
    • Ranjeeth Dasineni's avatar
      rfc: move folly::json::ParseError type to folly/json.h · 9633f475
      Ranjeeth Dasineni authored
      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
      9633f475
    • Philip Pronin's avatar
      EliasFanoReader::goTo() · 9f160366
      Philip Pronin authored
      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
      9f160366