1. 25 Jul, 2014 2 commits
  2. 21 Jul, 2014 6 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
    • Marcin Pawlowski's avatar
      added replaceAt and replaceAll to MutableStringPiece · 28a34a4e
      Marcin Pawlowski authored
      Summary:
      To make MutableStringPiece more usable (and make the
      implementation of replace* methods easier) I made sure that
      all the const methods (like find) work for MutableStringPiece
      in a fashion similar to how they work with StringPiece
      (work with everything auto convertible to StringPiece). As
      a result this change is pretty susbstatial in LOC, even
      though now much happens here.
      
      Test Plan: unit tests
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D1420965
      
      Tasks: 4632424
      28a34a4e
    • Jim Meyering's avatar
      folly: toLowerAscii: avoid unaligned access; also correct 3 conditions · 24e54548
      Jim Meyering authored
      Summary:
      * folly/String.cpp (toLowerAscii): Fix two errors: the most important
      would cause unaligned accesses.  This would cause a performance loss
      in general, but would also result in segfaults on ARM processes.
      In addition, three conditionals were wrong, further limiting
      the performance of this code: switch those "<" to "<=".
      
      Test Plan:
      Run this to exercise existing tests:
      fbconfig folly/test:string_test && fbmake runtests_opt
      Run this to generate timing stats (before and after this change), e.g.,
      fbconfig folly/test:string_benchmark && fbmake opt
      _bin/folly/test/string_benchmark > TIMING-toLower-old
      
      These numbers show a 1.6% speed increase with this change:
      
      --- TIMING-toLower-old  2014-07-14 16:51:12.793523778 -0700
      +++ TIMING-toLower-new  2014-07-14 16:49:45.815119145 -0700
      @@ -1,6 +1,6 @@
      ============================================================================
      folly/test/StringBenchmark.cpp                  relative  time/iter  iters/s
      ============================================================================
      -libc_tolower                                                 1.06us  941.91K
      -folly_toLowerAscii                                          89.99ns   11.11M
      +libc_tolower                                                 1.06us  941.90K
      +folly_toLowerAscii                                          88.57ns   11.29M
      ============================================================================
      
      Reviewed By: brianp@fb.com
      
      Subscribers:
      
      FB internal diff: D1434585
      
      Tasks: 4696800
      
      Blame Revision: D1421056
      24e54548
  3. 15 Jul, 2014 4 commits
    • Tudor Bosman's avatar
      oops, remove stray libgtest · b003d618
      Tudor Bosman authored
      Reviewed By: lesha@fb.com
      Test Plan: no
      b003d618
    • Tudor Bosman's avatar
      Update folly/thrift README with tested deps for Ubuntu 13.10 and 14.04 · 0120bd85
      Tudor Bosman authored
      Test Plan: no
      
      Reviewed By: lesha@fb.com
      
      Subscribers: alandau, jhj, kma
      
      FB internal diff: D1434163
      0120bd85
    • Tudor Bosman's avatar
      Allow undefined LZ4_MAX_INPUT_SIZE · edec0c3f
      Tudor Bosman authored
      Summary:
      Because the version of lz4 that ships by default with Ubuntu 13.10 doesn't
      define it (but has lz4_decompress_safe, so it's usable)
      
      Test Plan: built on Ubuntu 13.10
      
      Reviewed By: meyering@fb.com
      
      Subscribers: jhj, lesha, kma
      
      FB internal diff: D1433864
      
      @override-unit-failures
      edec0c3f
    • Pavlo Kushnir's avatar
      Fix IPAddress operator== · 7ccfefc7
      Pavlo Kushnir authored
      Summary: IPAddress operator== throws an exception when comparing ip v6 mapped address with unitialized (default constructed) address. With this diff it returns false.
      
      Test Plan: folly unit tests
      
      Reviewed By: bmatheny@fb.com
      
      FB internal diff: D1421280
      7ccfefc7
  4. 14 Jul, 2014 7 commits
    • Gunjan Sharma's avatar
      Fix another race in Notification Queue · c765dfdf
      Gunjan Sharma authored
      Summary: Consider a case we found that the queue is empty and unlocked and before our setActive(false) from SCOPE_EXIT gets called (or gets the lock) putMessageImpl got the lock. Now putMessage thinks that we donot want to add another signal but actually we do.
      
      Test Plan:
      Running mcreplay2 without running into this problem on a box.
      Benchmark:
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1428249
      c765dfdf
    • Tudor Bosman's avatar
      Enforce max uncompressed size; use safe LZ4 decompressor, which requires a newer version of LZ4 · b6b4f60b
      Tudor Bosman authored
      Test Plan: folly/io/test, whatever contbuild dreams up for hphp
      
      Reviewed By: meyering@fb.com
      
      Subscribers: meyering, hphp-diffs@, ps, jhj, kma, sainbar, lesha
      
      FB internal diff: D1429372
      
      @override-unit-failures
      b6b4f60b
    • Elizabeth Smith's avatar
      Small changes for cygwin build · 0e2b9093
      Elizabeth Smith authored
      Summary:
      Folly is almost "out of the box" working with cygwin
      
      This has the proper ifdefs to include cygwin in two areas and a workaround for a cygwin bug when including headers
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1413303
      0e2b9093
    • Elizabeth Smith's avatar
      MSVC includes for inet/sockets · a303e3e4
      Elizabeth Smith authored
      Summary:
      MSVC has all the sockets and internet functionality required except for one missing item - which can safely be defined to a windows specific type
      But it requires a different set of headers than on *nix systems
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1413265
      a303e3e4
    • Elizabeth Smith's avatar
      MSVC intrinsics for bits and cpuid · 5ed20b59
      Elizabeth Smith authored
      Summary: Use msvc intrinsics for cpuid, popcount, byteswap, and bit scan functionality
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1413254
      5ed20b59
    • Elizabeth Smith's avatar
      Expression SFINAE issue in base.h · 1f1ba906
      Elizabeth Smith authored
      Summary:
      MSVC 14 is still broken with expression sfinae - and the things that break are often strange
      Moving this out into two expr templates solves the compilation issue
      
      Test Plan: fbconfig -r folly && fbmake runtests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1413297
      1f1ba906
    • Wez Furlong's avatar
      use recursive_mutex to protect State · d7f1adb6
      Wez Furlong authored
      Summary:
      maelstrom destructs a Promise during an indirect call from
      maybeCallback and deadlocks on itself unless we use a recursive mutex.
      
      There may be a smarter way to proceed but at the moment I can't build
      and deploy a package from trunk because the service is non-functional
      :-/
      
      Test Plan:
      run
      
      ```
      fbconfig -r folly/wangle messaging/maelstrom
      fbmake runtests
      ```
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: fugalh, fsilva
      
      FB internal diff: D1428504
      d7f1adb6
  5. 09 Jul, 2014 10 commits
    • Tudor Bosman's avatar
      Remove unnecessary and broken hash specializations · df377ed2
      Tudor Bosman authored
      Summary:
      No need to specialize std::hash for std::basic_string; the STL already does
      this. Plus, the specializations were broken in multiple ways:
      
      1. std::hash does not treat const char* specially, so it just hashes the
      pointer value (contrasting the old __gnu_cxx::hash, which hashed a C-string)
      
      2. Either way, using __gnu_cxx::hash<const char*> for std::string is broken,
      as it won't hash anything past the first null byte.
      
      Also, make sure fbstring gets the same (full) specializations as std::string
      does in the standard.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt, also tests in tupperware/agent which is still using __gnu_cxx::hash_map with string keys.
      
      Reviewed By: pgriess@fb.com, andrei.alexandrescu@fb.com
      
      Subscribers: njormrod, jhj, kma, lesha
      
      FB internal diff: D1426479
      df377ed2
    • Gunjan Sharma's avatar
      Fix race in Notification Queue · ed684e76
      Gunjan Sharma authored
      Summary: When we are changing value of numActiveConsumers_ with setActive from handlerReady at the SCOPE_EXIT we have a race with reading of the same variable in putMessageImpl.
      
      Test Plan: Had a local race which works fine now.
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent
      
      FB internal diff: D1424674
      ed684e76
    • Tudor Bosman's avatar
      Simplify pipe2 / O_CLOEXEC handling in Subprocess.cpp · fca9fccb
      Tudor Bosman authored
      Summary: per @rockyliu's suggestions
      
      Test Plan: subprocess_test
      
      Reviewed By: rockyliu4@fb.com
      
      Subscribers: rockyliu, jhj, lesha, kma
      
      FB internal diff: D1423157
      fca9fccb
    • Paul Tarjan's avatar
      Revert "make `folly::Formatter` extendible" · 2c378ec8
      Paul Tarjan authored
      Summary:
      This reverts commit 5ea0eb0c705224b82a5c284dc5f7722e1f71199f.
      
      This breaks the HHVM clang build test.
      
      Test Plan: clang will pass now
      
      Reviewed By: smith@fb.com
      
      Subscribers: dmitrys
      
      FB internal diff: D1426399
      
      Tasks: 4667712
      2c378ec8
    • Tyler MacDonald's avatar
      make `folly::Formatter` extendible · 664e121a
      Tyler MacDonald authored
      Summary:
      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.
      
      I wasn't able to get the recursive formatter to be polymorphic -- whenever I tried to convert `class FormatValue<Formatter<containerMode, Args...>, void>` into `class FormatValue<BaseFormatter...`, `FormatTest.cpp:Test(Format, Nested)` wouldn't compile because it couldn't find the template. @tudorb, if you have an easy fix for this, lmk, otherwise I'm (reluctantly) okay with requiring that `Formatter`s define their own nesting `FormatValue`.
      
      phew. the last time I did this sort of metaprogramming was over 5 years ago in perl. Doing it in C++ is... interesting.
      
      Test Plan: `fbconfig -r thrift folly cold_storage && fbmake dbg && fbmake runtests`
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: tudorb, dgp
      
      FB internal diff: D1422343
      
      Tasks: 4624268
      664e121a
    • Tudor Bosman's avatar
      Fix libc++ build errors · eaed5551
      Tudor Bosman authored
      Summary:
      Reported externally:
      
      https://github.com/facebook/folly/issues/70
      https://github.com/facebook/folly/issues/71
      https://github.com/facebook/folly/issues/72
      https://github.com/facebook/folly/issues/73
      
      Note that I can't test on libc++ myself, but the reports suggested fixes which
      sounded good.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt
      
      Reviewed By: marcelo.juchem@fb.com
      
      Subscribers: jhj, ntv, lesha, kma, fugalh, jdelong
      
      FB internal diff: D1421029
      eaed5551
    • Tudor Bosman's avatar
      Use pipe2 in Subprocess; platform-specific config · 217e88e6
      Tudor Bosman authored
      Summary:
      We've wanted to use pipe2 in Subprocess for a while, but that's not supported
      on glibc 2.5.1. This is not a problem in OSS (autoconf can solve this),
      but, internally, we don't run autoconf; add an internal platform include file
      with such per-platform differences.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt
      
      Reviewed By: meyering@fb.com
      
      Subscribers: jhj, lesha, kma, agallagher
      
      FB internal diff: D1422128
      217e88e6
    • Tom Jackson's avatar
      stride() · 2015ae71
      Tom Jackson authored
      Summary: thatwaseasy
      
      Test Plan: iloveunittests
      
      Reviewed By: lucian@fb.com
      
      Subscribers: philipp
      
      FB internal diff: D1419848
      
      Tasks: 4636617
      2015ae71
    • Brian Pane's avatar
      Move the branchless, parallel ASCII toLower into folly · db66e2f4
      Brian Pane authored
      Summary:
      * Moved the fast toLower code into folly
      * Updated the name to emphasize that it's ASCII-only
      
      Test Plan: * Unit tests and benchmarks included.
      
      Reviewed By: tudorb@fb.com
      
      Subscribers: ruibalp, bmatheny
      
      FB internal diff: D1421056
      db66e2f4
    • Hans Fugal's avatar
      (wangle) fix shadow · a0d5122f
      Hans Fugal authored
      Summary: Not sure why this shadow error didn't turn up in my tests, but whatevs
      
      Test Plan: traffic manager builds without warning-errors
      
      Reviewed By: suhas@fb.com
      
      Subscribers: hannesr, net-systems@, fugalh, exa
      
      FB internal diff: D1421495
      
      Tasks: 4653938
      a0d5122f
  6. 07 Jul, 2014 10 commits
    • Tudor Bosman's avatar
      fix Makefile.am · 3454265d
      Tudor Bosman authored
      Summary: wangle/detail.h -> wangle/detail/State.h
      
      Test Plan: OSS build
      
      Reviewed By: meyering@fb.com
      
      Subscribers: fugalh, lesha
      
      FB internal diff: D1421490
      3454265d
    • Tudor Bosman's avatar
      gflags now likes namespace gflags, not google · f6a8fe63
      Tudor Bosman authored
      Summary:
      Use namespace gflags going forward, import namespace google into it if
      backward.
      
      Also added a few "checking for..." messages in autoconf.
      
      Test Plan: fbconfig -r folly && fbmake runtests_opt, OSS build
      
      Reviewed By: meyering@fb.com
      
      Subscribers: fjargsto, ntv, jhj, lesha, kma, davejwatson
      
      FB internal diff: D1420575
      f6a8fe63
    • Hans Fugal's avatar
      (wangle) cold via · 73e3273b
      Hans Fugal authored
      Summary:
      Instead of returning a Later, `via` returns a cold future.
      This works without keeping a backreference like Later does, because an inactive Future will always activate on destruction. Alternatively we could have an extra Promise, a la Later, and pass that along like Later does, and require launch() at the end (though, implicit launching on destruction would be an option there too).
      
      If you think this approach is viable I'll clean it up on Wednesday: make sure all the calling sites work, etc.
      
      Test Plan:
      new unit test
      This may fail in contbuild, I haven't done the codemod for calling sites, if there are any.
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412499
      
      Tasks: 4480567
      73e3273b
    • Hans Fugal's avatar
      (wangle) Future/Promise detachment · 03f41278
      Hans Fugal authored
      Summary:
      Bring a bit more sanity to the lifetime. Now Future and Promise detach by calling the respective methods on State, and they do it during their destruction only. State manages its own lifetime.
      
      Besides being cleaner, this also sets the stage for cancellation (where we'll need Future to hang on to its reference to State after setting the callback), and for folding in Later (we will have a bool for whether the future is hot and hold off executing the callback if it isn't).
      
      Also cleans up various things I noticed while auditing the code for usages of `state_`.
      
      Test Plan:
      All the unit tests still pass.
      Ran with ASAN (and found I had introduced a bug, then fixed it. yay)
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412038
      
      Tasks: 4618297
      03f41278
    • Hannes Roth's avatar
      (Folly/FBString) Enum class for category · 7609a2fb
      Hannes Roth authored
      Summary: Suggested by @aalexandre.
      
      Test Plan: Compile.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: folly@lists, njormrod, aalexandre
      
      FB internal diff: D1246180
      7609a2fb
    • Lucian Grijincu's avatar
      folly: StringPiece: add skipWhitespace · 38fb7acd
      Lucian Grijincu authored
      Test Plan: copied from folly::json
      
      Reviewed By: philipp@fb.com, soren@fb.com
      
      FB internal diff: D1417992
      
      Tasks: 4527315
      38fb7acd
    • Hans Fugal's avatar
      s/setCallback_/setCallback/ for detail::State · 368266c3
      Hans Fugal authored
      Summary: This isn't really an internal-to-this-class method. :-/
      
      Test Plan: builds
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412008
      368266c3
    • Hans Fugal's avatar
      (wangle) s/continuation_/callback/ (missed some) · 82ab3bae
      Hans Fugal authored
      Summary: In the spirit of D1406753
      
      Test Plan: still builds and tests pass
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1412002
      82ab3bae
    • Hans Fugal's avatar
      (wangle) s/FutureObject/detail::State/ · 1d42dc0b
      Hans Fugal authored
      Summary:
      codemod
      I never was satisfied with this name. `State` feels a little better. More descriptive. But still pretty generic, so I'm open to alternative ideas.
      
      Test Plan: It still builds and tests pass.
      
      Reviewed By: hannesr@fb.com
      
      Subscribers: jsedgwick, net-systems@, fugalh, exa
      
      FB internal diff: D1411506
      1d42dc0b
    • Kevin Chou's avatar
      Fix string split when last part is shorter than delimiter · 02a9ec75
      Kevin Chou authored
      Summary: The bug is when ignoreEmpty is true, we use the wrong token size, which will be 0 when last token is shorter than delimiter.
      
      Test Plan:
      1. Add unit test
      2. fbconfig -r folly && fbmake runtests
      
      Reviewed By: philipp@fb.com
      
      Subscribers: maxime, xiaol
      
      FB internal diff: D1415803
      02a9ec75
  7. 02 Jul, 2014 1 commit