1. 02 Feb, 2015 12 commits
    • Haijun Zhu's avatar
      Try to fix IdleTime unit test · e26db8a2
      Haijun Zhu authored
      Summary:
      IdleTime unit test has been failing randomly (#5996886). The
      event base loop calculates an exponentially moving average of loop busy
      time in each loop. In the test, the busy time is initialized to 5900 and
      each loop runs more than 8000 us. In normal case decaying of the
      previous loop busy time will take 6 loops to  move this average to >6000.
      But if the test is running on a heavily loaded machine the busy+idle time
      a loop is longer than it should be, causing the decaying happen faster.
      This diff skips this test if this happens.
      
      Test Plan:
      It won't affect anything if running on my devserver. It only
      helps on a heavily loaded contbuild host.
      
      Reviewed By: alandau@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1788450
      
      Tasks: 5996886
      
      Signature: t1:1788450:1421460774:1ec575c50f881e10b5a0208717fe68164f0d0f57
      e26db8a2
    • Alexey Spiridonov's avatar
      Fix comment typo · 5279c26d
      Alexey Spiridonov authored
      Test Plan: checked this is the right function name
      
      Reviewed By: ngbronson@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1788386
      
      Signature: t1:1788386:1421453582:82d0c4685c1bd2d888f5974fd2a998ebbc27a9b5
      5279c26d
    • Nathan Bronson's avatar
      fix and improve MPMCQueue comment · 62030871
      Nathan Bronson authored
      Summary:
      The big comment block at the top of MPMCQueue had a non-sense
      sentence resulting from a merge conflict, and also didn't include
      details about ordering or recommended patterns for handling consumer
      shutdown.
      
      Test Plan: comment change
      
      Reviewed By: lesha@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1788230
      
      Signature: t1:1788230:1421451643:7c768c2b127499e3f2b06ee241fba851b4ed2a29
      62030871
    • Satadru Pan's avatar
      apply all sockopts to listening sockets · 292de17c
      Satadru Pan authored
      Summary:
      We want all socket options to be applied to the listen sockets too.
      
      The old code here that only applied SO_KEEPALIVE is a bit superstitious.
      Not all options will be inherited by accept()ed sockets, but that's
      fine.  We set them again post-accept().
      
      Applying all these options to the listening sockets will fix at least
      one long standing bug, which is that QoS is not set correctly for the
      first few packets in a flow.  This also will let us do the right thing
      when we gain the ability to set TCP_MAXSEG in D1741753.
      
      Test Plan: fbmake runtests & canary in prod
      
      Reviewed By: afrind@fb.com, davejwatson@fb.com
      
      Subscribers: jsedgwick, satadru, trunkagent, fugalh, exa, folly-diffs@, agartrell
      
      FB internal diff: D1745182
      
      Tasks: 2911597
      
      Signature: t1:1745182:1418860157:045680a91b153482bcd4a014894fb28059955d06
      292de17c
    • Jim Meyering's avatar
      folly: Bits: restore type of bitOffset_ to shorter "unsigned int" · 98c4cba4
      Jim Meyering authored
      Summary:
      My initial change to avoid the -Wsign-compare error neglected
      the fact that the difference of two unsigned types is also
      unsigned. That broke some unicorn tests, as seen in D1776343,
      which worked around the problem by changing the type of
      bitOffset_ like this: s/unsigned int/size_t.
      
      The real problem lay in the distance_to function, which computed
      the signed difference of two bitOffset_ values.
      To work properly with the narrower unsigned type,
      we could either first widen each operand to ssize_t
      before computing their parenthesized difference, or
      (as Philip suggested and I prefer), just drop the
      parentheses and let the signedness of the preceding
      operands ensure that each successive intermediate
      result is also signed.
      
      Test Plan:
      Choose one of the failing tests, and ensure it now passes:
      
      fbconfig -r unicorn/diskindex4/test:doc_map_test
      fbmake runtests
      
      Also run all unicorn tests, for good measure (still waiting):
      fbconfig -r unicorn && fbmake runtests
      
      Reviewed By: philipp@fb.com, andrei.alexandrescu@fb.com
      
      Subscribers: trunkagent, net-systems@, folly-diffs@
      
      FB internal diff: D1776624
      
      Tasks: 5941250
      
      Signature: t1:1776624:1420872874:b1ea8a3f23f21269aa65cbe1647e86a8f622a710
      
      Blame Revision: D1770613
      98c4cba4
    • James Sedgwick's avatar
      remove outer Try from whenAll/whenN/whenAny callbacks · 7887ef2a
      James Sedgwick authored
      Summary:
      it's redundant and we shouldn't encourage it, so i'm changing all callsites
      i changed docs as well
      
      Test Plan: wait for contbuild
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, fbcode-common-diffs@, hero-diffs@, cold-storage-diffs@, targeting-diff-backend@, adityab, everstore-dev@, zhuohuang, darshan, micha, folly-diffs@, wch, lins, tingy, jsedgwick
      
      FB internal diff: D1784667
      
      Tasks: 5936469
      
      Signature: t1:1784667:1421364620:83169739320e5342d28a744e3689794f16108fea
      7887ef2a
    • James Sedgwick's avatar
      kill remaining Futures-related Wangle references · b4074536
      James Sedgwick authored
      Summary: grep around for wangle, adjust where appropriate
      
      Test Plan: contbuild
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, fbcode-common-diffs@, ruibalp, zeus-diffs@, vikas, targeting-diff-backend@, alandau, mwa, jgehring, zhguo, jying, darshan, fuegen, mshneer, folly-diffs@, lins, maxwellsayles, jsedgwick
      
      FB internal diff: D1777581
      
      Tasks: 5960242
      
      Signature: t1:1777581:1421361395:2ee8bfeca76dafe7376a217c66e0a4eaf3ef416a
      b4074536
    • Jim Meyering's avatar
      MPMCQueue.h: fix a bug introduced while accommodating -Wsign-compare · 1509cebb
      Jim Meyering authored
      Summary:
      * folly/MPMCQueue.h (waitForTurn): My changes to accommodate
      -Wsign-compare introduced a bug that could cause lots of wasted CPU.
      (See @scottf's comments on the blamed patch.)
      Subtraction involving an unsigned type will always yield an unsigned
      result, and there was at least this one instance where the result
      would sometimes have to be a small negative number.  Instead, we'd
      get approximately UINT32_MAX.  The fix is to explicitly cast the
      difference to a signed type.
      
      Test Plan:
      Run this and note there is no error:
      (this ensures it remains -Wsign-compare-clean with gcc-4.9)
      
      fbconfig --platform-all=gcc-4.9-glibc-2.20 tao/server && fbmake dbgo
      
      Before this change, running the mpmc_queue_test test would get
      timeout errors ~8 in 100 runs.  Confirm that with this patch, now
      there is no type of failure. I.e., run these commands and ensure
      the grep prints nothing:
      
      fbconfig folly/test:mpmc_queue_test
      for i in $(seq 100); do fbmake runtests_dbgo >& makerr-$i; done
      grep -E '(TIMEOUT|FATAL|FAIL).* [1-9]' makerr-*
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, scottf, folly-diffs@
      
      FB internal diff: D1783672
      
      Tasks: 5941250
      
      Signature: t1:1783672:1421350260:d7d306e8cf3ed3ee636d06228e1f24a2c2796b54
      
      Blame Revision: D1766722
      1509cebb
    • Dave Watson's avatar
      'fix' threadlocal fork test · 6502bca2
      Dave Watson authored
      Summary:
      configure seems to think ubuntu 14.04 doesn't have pthread_atfork, which seems wrong?! But this test seems to fail if we don't have it on some platform anyway.  Not sure the right fix, just disable it for now?
      
      Test Plan: watch https://ci-builds.fb.com/job/folly/
      
      Reviewed By: hans@fb.com
      
      Subscribers: doug, folly-diffs@
      
      FB internal diff: D1783046
      
      Signature: t1:1783046:1421348575:d279877abcc597a04c285092a5e5e53406922d5a
      
      Blame Revision: D1768669
      6502bca2
    • Ranjeeth Dasineni's avatar
      fix the manual config and flipped condition in SpinLock.h · e300e8b6
      Ranjeeth Dasineni authored
      Summary:
      i) FOLLY_HAVE_INT128_T definition is duplicated and is getting set to 1 on android. deleted that.
      ii) we dont have pthread_spinlock_t and pthread_atfork on android, the former is absent apple as well
      iii) a condition got flipped in D1768669. __ANDROID__ implies !FOLLY_HAVE_PTHREAD_SPINLOCK_T. fixed that
      
      Test Plan:
      - fbconfig -r folly && fbmake
      - ran folly build with buck as well
      - synced to fb4a and it builds
      
      Reviewed By: seanc@fb.com
      
      Subscribers: doug, seanc, folly-diffs@
      
      FB internal diff: D1783579
      
      Signature: t1:1783579:1421350138:9301303f77784e7bdb851e3f643751078457b025
      e300e8b6
    • James Sedgwick's avatar
      global executors with weak_ptr semantics · 6214f971
      James Sedgwick authored
      Summary:
      unfortunately, can't use atomics now that a weak_ptr is stored instead of a raw ptr, hence the additional singleton locks
      might want to make an overload of via() that takes shared_ptr to integrate more easily? or change via() to store a shared_ptr (and make it non-owning if a raw ptr is passed)
      
      Test Plan: unit
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: jsedgwick, trunkagent, fugalh, folly-diffs@
      
      FB internal diff: D1764359
      
      Tasks: 5002442
      
      Signature: t1:1764359:1420845340:349ea88091d7ca4ee386b54aec599647341fadd4
      6214f971
    • Louis Kruger's avatar
      Add folly::sorted_vector_map::at() · 32654ab1
      Louis Kruger authored
      Summary: http://www.cplusplus.com/reference/map/map/at/
      
      Test Plan: unittest
      
      Reviewed By: ldbrandy@fb.com
      
      Subscribers: trunkagent, jkong, folly-diffs@
      
      FB internal diff: D1773996
      
      Signature: t1:1773996:1421176834:33c8b39f03bf085ca2dd45df113cba948d0f2dd0
      32654ab1
  2. 13 Jan, 2015 28 commits
    • Viswanath Sivakumar's avatar
      Bump version to 22:0 · ba2a9e1b
      Viswanath Sivakumar authored
      ba2a9e1b
    • Hans Fugal's avatar
      (folly) osx bootstrap script · 6de57aa5
      Hans Fugal authored
      Summary:
      This is a bootstrap script for building folly on osx. I attempted to make it Just Work for anyone who uses Homebrew (http://brew.sh/) but even if it doesn't work out of the box it should be instructive for the motivated developer on OSX.
      
      Facebook:
      In #5134151 Wangle used to not build, because something was using a futex. But that seems to have been rectified (or the build problems are hiding in headers that aren't used in the libfolly build).
      
      I'll also update https://our.intern.facebook.com/intern/wiki/Folly/BuildingOnMac to point people to this script instead.
      
      Test Plan:
      Tested on my laptop which is running Yosemite (10.10.1)
      Build, then inspect `otool -L .libs/*dylib`
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly-diffs@, exa
      
      FB internal diff: D1765248
      
      Tasks: 5134151
      
      Signature: t1:1765248:1420500905:bc5da97a0446f502cb2badc85c9004ff0a62027a
      6de57aa5
    • Viswanath Sivakumar's avatar
      Add libgtest to Makefile to unbreak OSS build · 3178699d
      Viswanath Sivakumar authored
      Summary:
      SpookyHashTest now needs libgtestmain to be linked
      (https://phabricator.fb.com/D1775555).
      
      https://ci-builds.fb.com/job/folly/1570/console
      
      Test Plan:
      Don't have Ubuntu setup, but this should fix it. Will kick off jenkins
      build.
      
      Reviewed By: andrewjcg@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1779604
      
      Signature: t1:1779604:1421174608:de865529d728e943288b52c0d63ebb712eda094f
      
      Blame Revision: D1775555
      3178699d
    • James Sedgwick's avatar
      move Futures from folly::wangle to folly · 502c8e4b
      James Sedgwick authored
      Summary: Namespace change. Next up is to extract the Executors into folly/executors/
      
      Test Plan: wait for contbuild
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: jsedgwick, trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, lars, davejwatson, ruibalp, hero-diffs@, zeus-diffs@, andrewcox, vikas, mcduff, cold-storage-diffs@, unicorn-diffs@, ldbrandy, targeting-diff-backend@, netego-diffs@, abirchall, fugalh, adamsyta, atlas2-eng@, chenzhimin, mpawlowski, alandau, bmatheny, adityab, everstore-dev@, zhuohuang, mwa, jgehring, prometheus-diffs@, smarlow, akr, bnitka, jcoens, benj, laser-diffs@, zhguo, jying, darshan, micha, apodsiadlo, alikhtarov, fuegen, dzhulgakov, jeremyfein, mshneer, folly-diffs@, wch, lins, tingy, hannesr, maxwellsayles
      
      FB internal diff: D1772779
      
      Tasks: 5960242
      
      Signature: t1:1772779:1420751149:bc0b9220be25f1d46d9cef3fdeaa9c3681217aff
      502c8e4b
    • Andrew Gallagher's avatar
      folly: make remaining TARGETS files auto converitble to BUCK files · f3ac5cca
      Andrew Gallagher authored
      Summary: Also add the `@buckify` tag to keep these automatically synced.
      
      Test Plan: built and tested with buck and fbconfig/fbmake
      
      Reviewed By: robbert@fb.com
      
      Subscribers: trunkagent, sdwilsh, fugalh, folly-diffs@, jsedgwick
      
      FB internal diff: D1775555
      
      Signature: t1:1775555:1420840948:e9a2e86379be71b7d953fa53a727e51d2541b011
      f3ac5cca
    • Lucian Grijincu's avatar
      folly: Bits: make bitsPerBlock 64 bit back · 1507fc0b
      Lucian Grijincu authored
      Summary: D1770613 made bitsPerBlock 32 bit. Sadpanda.
      
      Test Plan: _bin/unicorn/diskindex4/test/doc_map_test --gtest_filter=DocMap/DocMapTest.Deleted/23
      
      Reviewed By: meyering@fb.com
      
      Subscribers: net-systems@, folly-diffs@
      
      FB internal diff: D1776343
      
      Tasks: 5968993
      
      Signature: t1:1776343:1420852923:f35166dd9023a701ff16467710131f821810215a
      
      Blame Revision: D1770613
      1507fc0b
    • Jim Meyering's avatar
      folly/dynamic-inl.h: avoid -Wsign-compare error · ed281068
      Jim Meyering authored
      Summary:
      * folly/dynamic-inl.h (format): Add an explicit
      int-to-size_t cast (that is ok because we've just ensured
      it is non-negative) to avoid this error from gcc-4.9:
      
      folly/dynamic-inl.h:953:29: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: delong.j@fb.com
      
      Subscribers: trunkagent, folly-diffs@
      
      FB internal diff: D1773242
      
      Tasks: 5941250
      
      Signature: t1:1773242:1420822301:b1e3c065cd25728c77957ce9e1f52e884ba8693b
      ed281068
    • Jim Meyering's avatar
      folly: ProducerConsumerQueue: avoid many -Wsign-compare errors · 7fdf8141
      Jim Meyering authored
      Summary:
      There were many templates instantiated with signed types.
      Changing them to unsigned avoids the compilation failures
      noted below.  However, we'll have to watch arc-diff-spawned
      tests for new failures, just in case.
      
      This is by far the largest undecomposable patch of those
      I've written for this task so far.  It is possible that
      some subset of these changes accomplishes the same goal,
      but once I managed to get a successful compilation, I have
      only re-reviewed it once and did not try to shrink it.
      
      Test Plan:
      Without these changes, we would get the following 32 errors from gcc-4.9:
      https://phabricator.fb.com/P19692642
      With them, (and all of the other patches attached to the parent task,
      all of fbcode compiles and passes its tests (modulo preexisting
      failures and aborts).
      
      Reviewed By: delong.j@fb.com
      
      Subscribers: trunkagent, folly-diffs@
      
      FB internal diff: D1773461
      
      Tasks: 5941250
      
      Signature: t1:1773461:1420821964:61635f3a2efc95e8d4457c36e7a5ee3a0a50df23
      7fdf8141
    • James Sedgwick's avatar
      move wangle/futures to futures · bc374dcb
      James Sedgwick authored
      Summary:
      First step of moving futures out of wangle into folly
      
      Namespace change will be another diff
      
      This was just a straight codemod of "wangle/futures" to "futures"
      
      Test Plan: wait for contbuild
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fbcode-common-diffs@, chaoyc, search-fbcode-diffs@, lars, ruibalp, hero-diffs@, zeus-diffs@, vikas, mcduff, hitesh, cold-storage-diffs@, unicorn-diffs@, ldbrandy, targeting-diff-backend@, netego-diffs@, fugalh, adamsyta, atlas2-eng@, alandau, apollo-diffs@, bmatheny, adityab, everstore-dev@, zhuohuang, sweeney, mwa, jgehring, prometheus-diffs@, smarlow, akr, bnitka, jcoens, zhguo, jying, darshan, apodsiadlo, alikhtarov, fuegen, dzhulgakov, alihussains, jeremyfein, mshneer, folly-diffs@, wch, lins, tingy, maxwellsayles, hannesr
      
      FB internal diff: D1772041
      
      Tasks: 5960242
      
      Signature: t1:1772041:1420739169:36126b1264c5d1747d241921d02b13e306c73fe1
      bc374dcb
    • Jim Meyering's avatar
      folly/Bits.h (BitIterator): avoid -Wsign-compare error · 0a9f6eef
      Jim Meyering authored
      Summary:
      * folly/Bits.h (BitIterator) [bitOffset_]: Change type of this
      member from ssize_t to "unsigned int".
      (bitsPerBlock): Change return type from size_t to "unsigned int".
      These changes avoid some -Wsign-compare-highlighted issues, e.g.,
      folly/Bits.h:456:18: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      I've also run "fbmake runtests", and it failed precisely the way it does
      without this patch.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: trunkagent, net-systems@, folly-diffs@
      
      FB internal diff: D1770613
      
      Tasks: 5941250
      
      Signature: t1:1770613:1420757397:7ee7e5de500c8991af2597a6245d12d8f286b4b7
      0a9f6eef
    • Jim Meyering's avatar
      folly: fix many -Wsign-compare warning/errors reported by gcc-4.9 · 377e3f4c
      Jim Meyering authored
      Summary:
      With the upgrade to gcc-4.9 fbcode's default is to enable
      -Wsign-compare by default.  That exposes nontrivial technical debt.
      This is part of that clean-up.  Some of these changes fix the problem
      where there's an "int" for-loop index, yet an unsigned limit.
      The fix is to use an unsigned type when the limit is also unsigned.
      I usually choose size_t because of the general recommendation (when
      writing portable code) to avoid size-tied types like uint32_t and
      uint64_t unless you have a very good reason to require them.
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 tao/server && fbmake dbgo
      
      Also, run this, compiling and running tests with gcc-4.8.1.
      Verify that there are no more failures than without this patch:
      fbmake opt -k && fbmake runtests_opt
      Here's the tail of that process, (same with and without the patch):
      Summary (total time 47.45s):
      PASS: 1949
      FAIL: 1
      SKIP: 0
      FATAL: 9
      TIMEOUT: 0
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1766722
      
      Tasks: 5941250
      
      Signature: t1:1766722:1420762240:a8545648ddb4fd0b2adf0d3147a84409c0f706a8
      377e3f4c
    • Hans Fugal's avatar
      (folly) Account for different vsnprintf behavior on OSX in test · 7f0c4bda
      Hans Fugal authored
      Summary: Apparently there is some dispute about the correct thing for `snprintf(buf, len, "bogus%", "foo")` to return. OSX says 5, Linux says -1. The code in `folly/String.cpp` depends on -1 to throw the exception this test was expecting.
      
      Test Plan: make check on OSX
      
      Reviewed By: chip@fb.com
      
      Subscribers: exa, folly-diffs@
      
      FB internal diff: D1770970
      
      Tasks: 5936226
      
      Signature: t1:1770970:1420680750:bafae2aa8327a52013e68af64a163323244ca03b
      7f0c4bda
    • Hans Fugal's avatar
      (folly) make check on OSX Yosemite (10.10) · 6d079c14
      Hans Fugal authored
      Summary:
      This switches from gcc-4.9 provided by Homebrew to the default g++ (clang) from Yosemite.
      
      $ g++ --version
      Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
      Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
      Target: x86_64-apple-darwin14.0.0
      Thread model: posix
      
      Absolute path for double-conversion, so make in `test/` works.
      
      gtest-1.7.0 (Using 1.6.0 causes compilation errors in Yosemite)
      
      Various portability fixes.
      
      Enhancements/fixes to `configure.ac` and associated source code for better portability.
      
      Test Plan:
      It builds and runs (yay)
      Two tests fail, not sure whether that's specific to osx. Will investigate and make any fixes in a follow-up diff
      
      Reviewed By: pgriess@fb.com
      
      Subscribers: trunkagent, folly-diffs@, exa
      
      FB internal diff: D1768669
      
      Tasks: 5936226
      
      Signature: t1:1768669:1420728580:dd6919c21e0edf30788e523b16e3a5b923e2d7f0
      6d079c14
    • Hans Fugal's avatar
      avoid std::_Hash_impl · 32f335ca
      Hans Fugal authored
      Summary:
      Default Yosemite clang has no `std::_Hash_impl`, which is an internal implementation detail anyway.
      
      @davejwatson you might have a different suggestion about how to implement this without that function, or how to test if it exists and do this only if it doesn't. This is probably not the most efficient approach, since it copies the string.
      
      Test Plan:
      builds
      inspection
      fbgs doesn't turn up many results (only recent wangle ssl code really) so I don't think this will be a big perf regression if we just go with it. But if I'm wrong, we can gate it on `#if __APPLE__` or something.
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: folly-diffs@, fugalh, exa, davejwatson
      
      FB internal diff: D1767052
      
      Signature: t1:1767052:1420738784:e219ebff7aec8682b24c15a03b47077e1559c1ab
      32f335ca
    • Andrei Alexandrescu's avatar
      Mini-refactoring prompted by https://phabricator.fb.com/D1770460 · a1942184
      Andrei Alexandrescu authored
      Summary: I got obliged into this one :o).
      
      Test Plan: runtests
      
      Reviewed By: meyering@fb.com
      
      Subscribers: njormrod, folly-diffs@
      
      FB internal diff: D1772328
      
      Signature: t1:1772328:1420744114:2b81e46d77800d247293cb667bbef86e9d6d4755
      a1942184
    • Jim Meyering's avatar
      folly/stats/Histogram-defs.h: avoid -Wsign-compare error · 2ab6db1e
      Jim Meyering authored
      Summary:
      * folly/stats/Histogram-defs.h (HistogramBuckets): Take the unusual
      approach of converting "numBuckets" to signed, because we cannot
      cast "max-min" (a known positive value) to an unsigned type --
      we don't have an unsigned variant of ValueType.
      This avoids the following error from gcc-4.9:
      
      folly/stats/Histogram-defs.h:41:31: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: ldbrandy@fb.com
      
      Subscribers: trunkagent, net-systems@, folly-diffs@
      
      FB internal diff: D1770129
      
      Tasks: 5941250
      
      Signature: t1:1770129:1420745311:c447e59f1730abafdf0b962e70f0886ae1d48db1
      2ab6db1e
    • Jim Meyering's avatar
      folly/.../FileUtilDetail.h: avoid -Wsign-compare warnings · 9d9b01ef
      Jim Meyering authored
      Summary:
      * folly/detail/FileUtilDetail.h (wrapvFull): Change type of result
      variable from ssize_t to size_t: this required changing r == -1 to
      r == (size_t)-1.
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      Also run fbmake runtests, and confirm that the results are
      the same with and without this change.
      
      Reviewed By: lucian@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1772171
      
      Tasks: 5941250
      
      Signature: t1:1772171:1420743142:1f9e02006e2d77a0c9451bae7965fb28617d95d6
      9d9b01ef
    • Jim Meyering's avatar
      folly/wangle/futures/Future-inl.h: avoid -Wsign-compare errors · 7f4d487a
      Jim Meyering authored
      Summary:
      * folly/wangle/futures/Future-inl.h (whenAll): Do not compare
      signed (std::distance) with unsigned(size_t): add an assertion
      to eliminate the possibility of negative, then assign to a new
      size_t "n".
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: jsedgwick@fb.com
      
      Subscribers: trunkagent, fugalh, folly-diffs@
      
      FB internal diff: D1770668
      
      Tasks: 5941250
      
      Signature: t1:1770668:1420736965:fc722657a2ec523052fd96c33d65d5ca24aae61c
      7f4d487a
    • Jim Meyering's avatar
      folly/FBString.h: avoid -Wsign-compare error · 5b12bbfc
      Jim Meyering authored
      Summary:
      * folly/FBString.h (operator>>): Since istream.width() is signed,
      handle the case of a negative width. This avoids risk that "n"
      will be less than 0 when compared against unsigned "extracted".
      However, to suppress the following warning, we must also explicitly
      convert "n" to size_t before comparing:
      
      folly/FBString.h:2326:22: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: trunkagent, net-systems@, njormrod, folly-diffs@
      
      FB internal diff: D1770460
      
      Tasks: 5941250
      
      Signature: t1:1770460:1420679684:b262eb31e6511b6311bebf0fbc29099471648b36
      5b12bbfc
    • James Sedgwick's avatar
      stop returning move(...) when unnecessary · 0b215436
      James Sedgwick authored
      Summary: as discussed in another diff, this might help with NRVO
      
      Test Plan: unit
      
      Reviewed By: hans@fb.com
      
      Subscribers: trunkagent, fugalh, folly-diffs@
      
      FB internal diff: D1764921
      
      Signature: t1:1764921:1420677311:c6b63d7bf04c0e17283117b3edef798c288e5fbb
      0b215436
    • James Sedgwick's avatar
      fix shadowed variables · 0e8d462a
      James Sedgwick authored
      Summary: as above, fixes builds
      
      Test Plan: compiled thrift + mcrouter
      
      Reviewed By: seanc@fb.com
      
      Subscribers: seanc, fugalh, folly-diffs@
      
      FB internal diff: D1771910
      
      Signature: t1:1771910:1420733490:7f33e57a5853395cab786e5d35d4c15c75a15c5a
      0e8d462a
    • James Sedgwick's avatar
      doxygen comments for Try · 4ea6cf43
      James Sedgwick authored
      Summary:
      One header at a time, starting with the small fry
      
      I'm allowed to drink while I do this right? Good, because I don't think I ever had a choice.
      
      Test Plan: generated doxygen and looked decent http://home.fburl.com/~jsedgwick/html/classfolly_1_1wangle_1_1Try.html
      
      Reviewed By: davejwatson@fb.com
      
      Subscribers: trunkagent, fugalh, njormrod, folly-diffs@
      
      FB internal diff: D1677730
      
      Tasks: 5480262
      
      Signature: t1:1677730:1415899240:bdd03569a82be1c8def8c13786eae39b4a2a2f94
      4ea6cf43
    • James Sedgwick's avatar
      exception_ptr -> exception_wrapper migration · 352bbea6
      James Sedgwick authored
      Summary:
      integrate exception_wrapper everywhere, and deprecate public methods that take ptrs directly to discourage their use
      note that this will break for throwing non-exceptions, which is probably fine
      
      this change opens the door to interesting optimizations for those interested, e.g. Future::then<Exn1, Exn2>(/* func throwing Exn1 and Exn2 */) that autowraps the given types into the resultant future
      
      new benchmark:
      ```
      throwAndCatch                                               23.69us   42.21K
      throwAndCatchWrapped                             119.53%    19.82us   50.45K
      throwWrappedAndCatchWrapped                      350.16%     6.77us  147.80K
      ```
      
      Test Plan: existing unit tests, suspected potential perf wins confirmed by benchmark, will wait for windtunnel to see other wins/regressions
      
      Reviewed By: hans@fb.com
      
      Subscribers: search-fbcode-diffs@, apodsiadlo, alikhtarov, andrii, trunkagent, fugalh, njormrod, folly-diffs@, bmatheny
      
      FB internal diff: D1644912
      
      Signature: t1:1644912:1420731849:3dc658dc03bfd6e75d61158808c7dad96092ecfb
      352bbea6
    • Jim Meyering's avatar
      folly/String-inl.h (humanify): avoid -Wsign-compare error · 06cee071
      Jim Meyering authored
      Summary:
      * folly/String-inl.h (humanify): Count with a signed type.
      Otherwise, gcc-4.9 fails with e.g.,
      folly/String-inl.h:596:33: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      folly/String-inl.h:601:32: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: philipp@fb.com
      
      Subscribers: trunkagent, folly-diffs@
      
      FB internal diff: D1770451
      
      Tasks: 5941250
      
      Signature: t1:1770451:1420704354:c841ca453a5586fbf474535ca26cef17f95427dd
      06cee071
    • Jim Meyering's avatar
      folly/AtomicHashArray: use an unsigned type for each of two counters · d6ddc282
      Jim Meyering authored
      Summary:
      * folly/AtomicHashArray.h (numEntries_, numPendingEntries_):
      Use an unsigned type for each of these.  They count things, can
      never go below 0, and are compared to unsigned values.
      Otherwise, gcc-4.9 would emit this:
      folly/AtomicHashArray-inl.h:153:38: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: philipp@fb.com
      
      Subscribers: trunkagent, folly-diffs@
      
      FB internal diff: D1770695
      
      Tasks: 5941250
      
      Signature: t1:1770695:1420683354:bfa4775bc2f8aab74e34772308a5c8b1779243b8
      d6ddc282
    • Jim Meyering's avatar
      folly/AtomicHashMap-inl.h: avoid -Wsign-compare warning/error (easy) · 69e1c7dc
      Jim Meyering authored
      Summary:
      * folly/AtomicHashMap-inl.h (insertInternal): Do not declare
      nextMapIdx to be signed ("int"), since we compare it against
      variables of unsigned type.  Otherwise, gcc-4.9 would give this
      diagnostic:
      folly/AtomicHashMap-inl.h:99:18: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      complaining about this comparison:
      if (nextMapIdx >= kNumSubMaps_ ||
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: philipp@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1770683
      
      Tasks: 5941250
      
      Signature: t1:1770683:1420683505:4452c7cb4f14f098be089601be906884036348ed
      69e1c7dc
    • Jim Meyering's avatar
      Histogram and Timeseries vs gcc-4.9 and -Wsign-compare · 29be5d6d
      Jim Meyering authored
      Summary:
      Address multiple -Werror=sign-compare issues exposed when building
      tao with gcc-4.9.
      In most of these changes I've changed the type of the index in
      a for-loop from int to size_t.  The important thing is to use
      an unsigned type when the limit is also unsigned.  I choose size_t
      because the general recommendation (when writing portable code)
      to avoid size-tied types like uint32_t and uint64_t unless you
      have a very good reason to require them.
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 tao/server && fbmake dbgo
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: trunkagent, net-systems@, folly-diffs@
      
      FB internal diff: D1766651
      
      Tasks: 5941250
      
      Signature: t1:1766651:1420594537:56ef53ca233e1649469db9570942c1d5dd47cf6d
      29be5d6d
    • Jim Meyering's avatar
      folly/test/ForeachTest.cpp: avoid -Wsign-compare error · 8cae10aa
      Jim Meyering authored
      Summary:
      * folly/test/ForeachTest.cpp: Change a "1" to "1U", so it matches
      the signedness of the size_t upper bound.
      Otherwise, gcc-4.9 fails with e.g.,
      folly/Foreach.h:194:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
      
      Test Plan:
      Run this and note there are fewer errors than before:
      fbconfig --platform-all=gcc-4.9-glibc-2.20 -r folly && fbmake dbgo
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      Subscribers: folly-diffs@
      
      FB internal diff: D1770603
      
      Tasks: 5941250
      
      Signature: t1:1770603:1420679246:56ef62ac7fa4413a4ad6310c3381a12bdc59e64c
      8cae10aa