1. 14 Aug, 2014 19 commits
    • 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
    • Hitesh Khandelwal's avatar
      API for getTimeoutManager · 874ef580
      Hitesh Khandelwal authored
      Test Plan: Tested end-to-end with D1342452
      
      Reviewed By: mshneer@fb.com
      
      Subscribers: alandau, bmatheny
      
      FB internal diff: D1470814
      
      Tasks: 2682011
      874ef580
    • Dave Watson's avatar
      install delayeddestruction header · fae4fcc8
      Dave Watson authored
      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
      fae4fcc8
    • Rushi Desai's avatar
      Construct Later with exception_ptr · ac639d56
      Rushi Desai authored
      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
      ac639d56
    • Alan Frindell's avatar
      Move TDelayedDestruction to folly::DelayedDestruction · fa6a9824
      Alan Frindell authored
      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
      fa6a9824
    • Marc Celani's avatar
      IPAddress::empty() · 6fc66ca7
      Marc Celani authored
      Summary: Checks if IPAddress has not been initialized.
      
      Test Plan: unit test
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: tudorb
      
      FB internal diff: D1459525
      6fc66ca7
  2. 25 Jul, 2014 17 commits
    • Chip Turner's avatar
      Bump version to 2:0 · a8307a9e
      Chip Turner authored
      a8307a9e
    • Chip Turner's avatar
      Try again: folly::Singleton, a class for managing singletons · 2fcb96be
      Chip Turner authored
      Summary:
      Singletons are surprisingly tricky in a codebase where
      libraries depend on one another.  folly::Singleton hopes to make this
      process more reliable by ensuring object creation happens in a safe
      order, that destruction is possible, and that singletons are created
      on-demand.
      
      The basic fbcode use intention is to invoke registration completion in
      initFacebook, so users need only declare singletons via
      Singleton<ClassName> in their .cpp files.
      
      This diff ties the Singletons into the core Init process, but not hhvm
      (which will be a separate diff).
      
      Test Plan: runtests
      
      Reviewed By: joelm@fb.com, hans@fb.com
      
      Subscribers: fbcode-common-diffs@, hphp-diffs@, soren, anca, lins, aalexandre, ps, trunkagent, lucian, hannesr, yfeldblum, maxwellsayles
      
      FB internal diff: D1453135
      2fcb96be
    • Jun LI's avatar
      Add method to parse parameter list in query string to folly::Uri · 1e5e33a5
      Jun LI authored
      Summary:
      Add a method to folly::Uri to get parsed query string
      
      e.g. http://localhost?key1=foo&key2=bar
      
      We can get key value map containing:
      "key1" => "foo"
      "key2" => "bar"
      
      Test Plan:
      fbconfig folly/test
      fbmake runtests_dbg
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: wormhole-dev@
      
      FB internal diff: D1455158
      
      Tasks: 4768038
      1e5e33a5
    • Tom Jackson's avatar
      Adding one more test for trailing dots · b942767a
      Tom Jackson authored
      Summary: Sorry, forgot to include tests for the other side of the equation.
      
      Test Plan: It is a test
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1455583
      b942767a
    • Hans Fugal's avatar
      (wangle) set* should not invalidate getFuture · 56df65be
      Hans Fugal authored
      Summary: @jcoens observed in D1451114 that it was unintuitive that you have to retrieve the `Future` before fulfilling the `Promise`. That seemed wrong to me too, but sure enough when I wrote the unit tests that doesn't work (throws "promise already fulfilled" when you call `getFuture`). I think this is just a simple mistake, but I'm going to carefully look at the output of contbuild test suites before committing.
      
      Test Plan:
      red-green
      careful dependency unit test inspection
      
      Reviewed By: jon.coens@fb.com
      
      Subscribers: net-systems@, fugalh, exa, jcoens
      
      FB internal diff: D1453780
      56df65be
    • Tudor Bosman's avatar
      Versioning for Thrift, remove thrift/lib/cpp/config.h · a99854ba
      Tudor Bosman authored
      Summary:
      Also, regenerate thrift_config.h.
      
      Move .gitignore to public_tld so I can add thrift_config.h while still
      having it checked into fbcode.
      
      Test Plan: fbconfig -r thrift && fbmake runtests_opt
      
      Reviewed By: meyering@fb.com
      
      Subscribers: alandau, bmatheny, jhj, kma, lesha
      
      FB internal diff: D1449068
      a99854ba
    • Tom Jackson's avatar
      Support trailing decimals for floats · 33d3277c
      Tom Jackson authored
      Summary: So integer-like numbers can be formatted in a manner which disambiguates them from integers.
      
      Test Plan: Unit tests
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: jfh, cscheau
      
      FB internal diff: D1454446
      33d3277c
    • Tudor Bosman's avatar
      Make ElfFile not crash on invalid ELF files · ba00a0d4
      Tudor Bosman authored
      Summary:
      @rkroll wants to run this on more than just fbcode binaries; there are x86 (not
      x86_64) binaries in there and probably a lot of other junk. So, if you call
      openNoThrow explicitly, you get a pretty error message in this case.
      
      Test Plan: folly/experimental/symbolizer/test
      
      Reviewed By: lucian@fb.com
      
      Subscribers: rkroll, jhj, lesha, kma
      
      FB internal diff: D1453758
      ba00a0d4
    • Tudor Bosman's avatar
      Enforce that only one version of folly is loaded at the same time · 1274a688
      Tudor Bosman authored
      Test Plan: folly/test, OSS build, check the macro in separate file
      
      Reviewed By: dancol@fb.com
      
      FB internal diff: D1448086
      1274a688
    • Yedidya Feldblum's avatar
      Fix a folly build failure under clang: ConvTest.cpp. · c52e055c
      Yedidya Feldblum authored
      Summary: [Folly] Fix a folly build failure under clang: ConvTest.cpp.
      
      Test Plan: Build the unit-test folly/test/ConvTest.cpp with clang.
      
      Reviewed By: tudorb@fb.com, njormrod@fb.com
      
      Subscribers: mathieubaudet, dougw
      
      FB internal diff: D1446232
      
      Tasks: 4723132
      c52e055c
    • Yedidya Feldblum's avatar
      Fix a folly build failure under clang: MPMCQueueTest.cpp. · a9a04804
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix a folly build failure under clang: MPMCQueueTest.cpp.
      
      In clang-v3.4, there is a bug with the combination of a lambda expression inside a function template taking a template name (rather than a type name) as a template argument.
      
      This diff, in the interest of building folly under clang-v3.4, extracts the lambda expression into a separate function so that the function template taking a template name as a template argument no longer has a lambda expression in it.
      
      Test Plan: Build folly/test/MPMCQueueTest.cpp under clang.
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: mathieubaudet, dougw
      
      FB internal diff: D1446279
      
      Tasks: 4723132
      a9a04804
    • Yedidya Feldblum's avatar
      Fix a folly build failure under clang: FutexTest.cpp. · 3c001a31
      Yedidya Feldblum authored
      Summary:
      [Folly] Fix a folly build failure under clang: FutexTest.cpp.
      
      In clang-v3.4, there is a bug with the combination of a lambda expression inside a function template taking a template name (rather than a type name) as a template argument.
      
      This diff, in the interest of building folly under clang-v3.4, extracts the lambda expression into a separate function so that the function template taking a template name as a template argument no longer has a lambda expression in it.
      
      Test Plan: Build folly/test/FutexTest.cpp under clang.
      
      Reviewed By: njormrod@fb.com
      
      Subscribers: mathieubaudet, dougw
      
      FB internal diff: D1446237
      
      Tasks: 4723132
      3c001a31
    • Tyler MacDonald's avatar
      fix D1422343 ("make `folly::Formatter` extendible") for clang · bd1cd83b
      Tyler MacDonald authored
      Summary:
      This is D1422343, but with a one-line change to make it clang-compatible. I authored this diff by first copying the original, then updating, so it's easy to see what I had to change.
      
      > on advice of @tudorb, move most of `folly::Formatter` into `folly::BaseFormatter` so that we can use compile-time polymorphism to provide different types of Formatters.
      
      Test Plan:
      ```
      fbmake clean
      fbconfig -r thrift folly cold_storage && fbmake dbg && fbmake runtests
      fbmake clean
      fbconfig -r hphp --clang && fbmake dbgo && fbmake runtests
      ```
      
      Reviewed By: tudorb@fb.com, pt@fb.com
      
      Subscribers: mathieubaudet, tudorb
      
      FB internal diff: D1440310
      
      Tasks: 4624268, 4667712
      bd1cd83b
    • Brian Pane's avatar
      Fix the unaligned string toLowerAscii test · 5d36a4ff
      Brian Pane authored
      Summary:
      * The test computed nonaligned inputs but then copied them into temporary
      buffers to compare different implementations. The temporary buffers
      were word-aligned.
      * This diff keeps the temp buffers but ensures that the data in them
      keeps the original input's alignment.
      
      Test Plan:
      * Ran the test case with a modified String.cpp containing an assert to
      catch unaligned reads.  The assert failed, as expected, on a copy
      of the code without the fix from D1434585
      
      Reviewed By: meyering@fb.com
      
      Subscribers: ruibalp
      
      FB internal diff: D1435028
      
      Tasks: 4696800
      5d36a4ff
    • Alexey Spiridonov's avatar
      A generic line-reading callback for communicate() · 1f4f3030
      Alexey Spiridonov authored
      Summary: There are a couple of places where this behavior is useful, and it's not 100% trivial to implement it from scratch. Adding it to Folly to save people code & bugs.
      
      Test Plan: unit tests
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: tjackson, folly@lists, tudorb
      
      FB internal diff: D1297506
      1f4f3030
    • Alexey Spiridonov's avatar
      Factor out string stream re-splitting as StreamSplitter · dbcb08a7
      Alexey Spiridonov authored
      Summary: This way I can reuse it in Subprocess. It also makes it easy to make a bunch of other convenient tokenization routines (e.g. delimiter-preserving folly::gen tokenizers, file tokenizers, etc, etc).
      
      Test Plan: fbconfig folly/gen/test && fbmake runtests
      
      Reviewed By: tjackson@fb.com
      
      Subscribers: vkatich, tjackson
      
      FB internal diff: D1317973
      dbcb08a7
    • Marcin Pawlowski's avatar
      extend folly::split · ce5e83f4
      Marcin Pawlowski authored
      Summary:
      see task:
      https://our.intern.facebook.com/intern/tasks/?t=4723861
      
      Test Plan: unit tests
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D1443223
      
      Tasks: 4723861
      ce5e83f4
  3. 21 Jul, 2014 4 commits
    • Tudor Bosman's avatar
      Bump version to 1:0 · 18fd7eb1
      Tudor Bosman authored
      18fd7eb1
    • Philip Pronin's avatar
      make folly::Range literal type · 7756a098
      Philip Pronin authored
      Summary:
      7.1.5 [dcl.constexpr] / 9 (N3337) requires type to be literal to use it
      in `constexpr` object declaration (seems to be not enforced by GCC 4.8?)
      
      Currently `folly::Range<>` fails one of the requirements:
      
      * is an aggregate type, or has at least one constexpr constructor or
      constructor template that is not a copy or move constructor,
      
      Test Plan: fbconfig folly/test:range_test && fbmake runtests_opt -j32
      
      Reviewed By: lucian@fb.com
      
      Subscribers: chaoyc, search-fbcode-diffs@, unicorn-diffs@
      
      FB internal diff: D1441646
      
      Tasks: 4720575
      7756a098
    • Zejun Wu's avatar
      Check for self-assignment in move assignment · cb2dc2c8
      Zejun Wu authored
      Summary:
      Check for self-assignment in move assignment. Otherwise
      Optional<Neko> cat = whatever;
      cat = std::move(cat);
      cat.hasValue(); // always returns false
      
      Test Plan: fbmake runtests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1440633
      cb2dc2c8
    • Marcin Pawlowski's avatar
      reserve capacity in toAppend<StringType>(...) · b6a8eb2e
      Marcin Pawlowski authored
      Summary:
      I modified the toAppend(args..., StringType* dest) so that
      before appending it reserves enough space for data to be appended. It is
      still work in progress (floats and doubles are really bad: we only do
      very naive approximation of the size). On float like workload we gain
      ~10% perf, on strings/ints/chars we gain as much as 25% of perf.
      Probably on bigger strings it will be even faster. We only modify the
      case when toAppend() has more than 1 element to append as it would be
      just overhead in case of one argument.
      
      Test Plan:
      with this change:
      
      ============================================================================
      folly/test/ConvTest.cpp                         relative  time/iter
      iters/s
      ============================================================================
      preallocateTestNoFloat                                       1.59us 627.85K
      preallocateTestFloat                                         1.09us 920.70K
      ----------------------------------------------------------------------------
      ============================================================================
      
      without the change:
      
      ============================================================================
      folly/test/ConvTest.cpp                         relative  time/iter
      iters/s
      ============================================================================
      preallocateTestNoFloat                                       2.12us 471.43K
      preallocateTestFloat                                         1.22us 818.25K
      ----------------------------------------------------------------------------
      ============================================================================
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D1420588
      
      Tasks: 4632421
      b6a8eb2e