1. 19 Jan, 2013 9 commits
    • Florent Thoumie's avatar
      Unbreak folly. · 2271234d
      Florent Thoumie authored
      Summary: Extra '#' in there.
      
      Test Plan: fbconfig nagios/plugins && fbmake opt
      
      Reviewed By: carl.moran1@fb.com
      
      FB internal diff: D660977
      2271234d
    • Anton Korobeynikov's avatar
      Get rid of some gcc-ism's in Portability.h · 2cc058aa
      Anton Korobeynikov authored
      Summary:
      handle at least clang. It will be better to turn this into
      configure check, though.
      
      Test Plan: .
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D660139
      2cc058aa
    • Thomas Whitton's avatar
      Fixed mistake with Makefile.am for spooky tests. · b2b94be3
      Thomas Whitton authored
      Summary: Tests not compiling due to a copy and paste error in Makefile.am.
      
      Test Plan: .
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D660138
      b2b94be3
    • Anton Korobeynikov's avatar
      Make sure there is no signed int overflow · e5baaa96
      Anton Korobeynikov authored
      Summary: use proper type for index.
      
      Test Plan: .
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D660142
      e5baaa96
    • Jordan DeLong's avatar
      Make dynamic::object callable with initializer lists · c1e51516
      Jordan DeLong authored
      Summary:
      Using perfect forwarding here prevents the ability to create
      dynamic arrays.
      
      Test Plan: Added unit test case that compiles now with this.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D660662
      c1e51516
    • Yang Ni's avatar
      Fixed a potential deadlock in folly::RWSpinLock · 3692ff51
      Yang Ni authored
      Summary:
      The current UpgradedHolder implementation may lead to a deadlock when upgrading from a reader lock, because it is blocking.
      
      A reader that has failed to set the UPGRADED bit may block the
      winner (upgrader) that has successfully set the UPGRADED bit, while
      waiting to upgrade in an infinite loop without releasing its own
      reader lock. The upgrader needs to wait for all reader locks to be
      released before it can move forward.
      
      This is the code pattern:
      
      {
      ReadHolder reader(lock);
      UpgradedHolder upgrader(std::move(reader));
      WriteHolder writer(std::move(upgrader));
      }
      
      To avoid this to happen, removed UpgradedHolder(ReadHolder&&)
      constructor and the function that impelments it
      unlock_shared_and_lock_upgrade. This would require a programmer explicitly
      release a read lock before acquiring an upgrade lock, therefore
      avoid the above mentioned deadlock.
      
      In addition, the current folly::RWSpinLock::try_lock_shared()
      implementation does not check the UPGRADED bit at all. The UPGRADED bit can be used to avoid starving writers.  This diff fixed this by correctly checking the UPGRADED bit.
      
      Test Plan:
      Passed folly unit tests.
      Tested in a Facebook service that uses the
      folly::RWSpinLock::UpgradedHolder.
      
      Reviewed By: xliux@fb.com
      
      FB internal diff: D659875
      3692ff51
    • Anton Korobeynikov's avatar
      Make sure the op does not change the sign of the operand · dca19fc4
      Anton Korobeynikov authored
      Summary: .
      
      Test Plan: .
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D660143
      
      Blame Revision:
      dca19fc4
    • Jonathan Wakely's avatar
      trivial typo · 8dd97c8c
      Jonathan Wakely authored
      Summary: I wouldn't even bother reporting this if github didn't make it so easy!
      
      Test Plan: .
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D660136
      8dd97c8c
    • Soren Lassen's avatar
      Remove unnecessary branch in Range::find_first_of(Range,size_t) · d6c4dda1
      Soren Lassen authored
      Summary:
      Added benchmarks.
      
      Before:
      
      folly/test/RangeFindBenchmark.cpp               relative  time/iter  iters/s
      ============================================================================
      string length 10:
      FindFirstOfRange                                             1.36ns  733.07M
      FindFirstOfOffsetRange                                       2.15ns  464.16M
      ============================================================================
      string length 256:
      FindFirstOfRange                                             1.36ns  733.07M
      FindFirstOfOffsetRange                                       1.42ns  704.22M
      ============================================================================
      string length 10240:
      FindFirstOfRange                                             1.36ns  733.07M
      FindFirstOfOffsetRange                                       3.72ns  268.70M
      ============================================================================
      string length 10485760:
      FindFirstOfRange                                             1.36ns  733.07M
      FindFirstOfOffsetRange                                       5.00ns  199.96M
      
      After:
      
      string length 10:
      FindFirstOfRange                                             1.36ns  732.92M
      FindFirstOfOffsetRange                                       1.36ns  732.61M
      ============================================================================
      string length 256:
      FindFirstOfRange                                             1.36ns  732.93M
      FindFirstOfOffsetRange                                       1.38ns  727.16M
      ============================================================================
      string length 10240:
      FindFirstOfRange                                             1.36ns  732.93M
      FindFirstOfOffsetRange                                       1.79ns  558.40M
      ============================================================================
      string length 10485760:
      FindFirstOfRange                                             1.36ns  732.93M
      FindFirstOfOffsetRange                                       2.73ns  366.44M
      
      Test Plan: fbconfig folly && fbmake runtests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D660125
      d6c4dda1
  2. 16 Dec, 2012 31 commits
    • Gaurav Jain's avatar
      Fix some clang compiler warnings/errors · 83da0042
      Gaurav Jain authored
      Summary:
      Fixes instances of the following problems:
      error: offset of on non-POD type 'folly::fbstring_core<char>::RefCounted'
      [-Werror,-Winvalid-offsetof]
      Solution: Since the atomic is not a POD I used sizeof() instead to calculate
      the offset
      
      warning: C++11 requires lambda with omitted result type to consist of a single
      return statement
      Solution: Specify a return type
      
      error: in-class initializer for static data member is not a constant expression
      Solution: Move initializer
      
      Test Plan: - Compiled folly and ran fbmake runtests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D656963
      83da0042
    • Tudor Bosman's avatar
      Fix bug in Bits<T>::get / set · 06eaa4f3
      Tudor Bosman authored
      Summary:
      Everything worked except for getting properly aligned full blocks
      because 1ULL << 64 is invalid (the shift amount must be strictly less than
      the value size in bits)
      
      Test Plan: test added
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D657800
      06eaa4f3
    • Tudor Bosman's avatar
      Silence -Wuninitialized in some cases · 9284f39b
      Tudor Bosman authored
      Test Plan: compiles
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D657623
      9284f39b
    • Tudor Bosman's avatar
      folly::padded_sequence -> folly::padded · af8b3ec1
      Tudor Bosman authored
      Summary: Mechanical.
      
      Test Plan: fbconfig unicorn/test unicorn/diskindex3 unicorn/diskindex4/test common/datastruct:css_tree_test folly/test:padded_test dragon/test:posting_list_test && fbmake opt
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D649539
      af8b3ec1
    • Tom Jackson's avatar
      Removing test code from `first` · e722023c
      Tom Jackson authored
      Summary: TSIA
      
      Test Plan: Unit tests
      
      Reviewed By: kedarb@fb.com
      
      FB internal diff: D652180
      e722023c
    • Nicholas Ormrod's avatar
      dummy results in stl_vector_test on gcc 4.6 · 37392377
      Nicholas Ormrod authored
      Summary:
      The test doesn't run when GCC < 4.7, however our test framework
      needs some output anyways. I've added a placeholder test that does
      nothing, but does cause something to be printed.
      
      Test Plan: run fbmake runtests on folly/test/stl_tests/
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D652161
      37392377
    • Christopher Berner's avatar
      Add converter for containers of pairs · 333ed393
      Christopher Berner authored
      Summary:
      Add specialized dynamic converter for containers of pairs,
      which can convert from a list of pairs, or from a object
      
      Test Plan: added a unit test
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D650730
      333ed393
    • Nicholas Ormrod's avatar
      FBVector 2.0 - now standard compliant · 8dd82d48
      Nicholas Ormrod authored
      Summary:
      This is FBVector 2.0. It supports all of the original FBVector
      optimizations and is standard compliant.
      Accompanying this diff are two suites, StlVectorTest and Benchmark.
      StlVectorTest runs an extensive battery of tests against a vector
      implementation per the N3337 standard. In addition to checking normal
      correctness, StlVectorTest checks the use of allocators, exception
      safety, memory leaks, and type requirements.
      Benchmark run a wide range of speed tests between std::vector, the
      original fbvector, and the new fbvector.
      
      Test Plan:
      First test: run StlVectorTest.
      Second test: run Benchmark.
      Third test: compile and run some fbcode (e.g. multifeed/).
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D566719
      8dd82d48
    • Nicholas Ormrod's avatar
      Added two new traits and a way to specify them · 93b0f543
      Nicholas Ormrod authored
      Summary:
      Added IsBits (has value semantics; can be copied by memcpy and
      deleted by free. Implies IsRelocatable) and Is0Initializable (new (ptr)
      T() is equivalent to memset(ptr, 0, sizeof(T))).
      Converted the boost types for IsRelocatable to std types (now available
      from <type_traits>).
      Added a new way to specify IsRelocatable, IsBits, and Is0Initializable:
      typedef std::true_type <property-name> in your class. No namespace
      exiting required. This method also supports inheritance, and may be
      overriden in base classes.
      Added a test file to test Traits.
      
      Test Plan:
      Run new test file. Compile some real-world code (in my case,
      multifeed).
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D610996
      93b0f543
    • Tom Jackson's avatar
      Fixing GENERATOR benchmark · 291bf062
      Tom Jackson authored
      Summary: I forgot fbmake runtests doesn't build all that's configured, oops.
      
      Test Plan: Build folly/experimental/test, run benchmark.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D647191
      291bf062
    • Philip Pronin's avatar
      fix GroupVarintDecoder::rest() · ec496276
      Philip Pronin authored
      Summary:
      It makes sense to return subpiece of the original data
      from ##rest()##.
      
      Test Plan: gv tests
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D647179
      ec496276
    • Tom Jackson's avatar
      Simplifying GENERATOR to be like ScopeGuard · 62cbd21f
      Tom Jackson authored
      Summary:
      It was previously breaking any time a generator included a comma, which
      is pretty stupid. Now, it's modelled after `ScopeGuard`, using a little operator
      overloading to get rid of the trailing `)` and sidestepping preprocessor issues.
      
      Test Plan: Unit tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D646825
      62cbd21f
    • Tudor Bosman's avatar
      folly/PaddedSequence.h · 95ad385e
      Tudor Bosman authored
      Summary:
      Code that aids in storing data aligned on block (possibly cache-line)
      boundaries, perhaps with padding. There's class Node which represents one
      block, and Iterator which, given an iterator to a container of Nodes, gives you
      an iterator to the underlying elements.  There's also Adaptor, which converts a
      sequence of Node into a sequence of underlying elements. (with enough
      functionality to make it useful, although it's not fully STL compatible)
      
      Split off from https://phabricator.fb.com/D641114
      
      Also includes changes to make TypedIOBuf container-like so it can be used with padded_sequence::Adaptor.
      
      I plan to rename this to Padded.h / folly::padded in a separate diff.
      
      Test Plan: test added
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D646249
      95ad385e
    • Soren Lassen's avatar
      tiny fbstring push_back(Char) optimization · d12f21b0
      Soren Lassen authored
      Summary:
      I noticed that push_back(Char) was slower for fbstring than
      for std::string for long strings and found that I could make
      it faster by inlining the call to mutable_data() and
      exploit that it's always non-small and non-shared.
      
      Benchmarks before:
      
      ./folly/test/FBStringTestBenchmarks.cpp.h       relative  time/iter  iters/s
      BM_push_back_string(1)                                      69.42ns   14.41M
      BM_push_back_string(23)                                    582.31ns    1.72M
      BM_push_back_string(127)                                     1.47us  682.12K
      BM_push_back_string(1024)                                    5.52us  181.07K
      BM_push_back_fbstring(1)                                     9.55ns  104.74M
      BM_push_back_fbstring(23)                                  212.45ns    4.71M
      BM_push_back_fbstring(127)                                 864.00ns    1.16M
      BM_push_back_fbstring(1024)                                  6.73us  148.52K
      
      and after:
      
      BM_push_back_fbstring(1)                                     9.55ns  104.74M
      BM_push_back_fbstring(23)                                  212.45ns    4.71M
      BM_push_back_fbstring(127)                                 783.08ns    1.28M
      BM_push_back_fbstring(1024)                                  4.03us  248.05K
      
      Test Plan: fbconfig folly/test && fbmake runtests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D646081
      d12f21b0
    • Helios Alonso Cabanillas's avatar
      Added missing curly braces · 8244bf0d
      Helios Alonso Cabanillas authored
      Summary:
      Added closing curly braces at 173.
      Sorry, must make diff if it's a new commit.
      
      Test Plan: nothing really
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D644925
      8244bf0d
    • Helios Alonso Cabanillas's avatar
      Add samples to FBVector documentation · 40a24cb6
      Helios Alonso Cabanillas authored
      Summary: Added two samples of use for FBVector in docs
      
      Test Plan: just check if FBVector.md looks good.
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D636813
      40a24cb6
    • Yiding Jia's avatar
      folly/stats - fix c++ spec compliance for call to template name · 3e8d7341
      Yiding Jia authored
      Summary:
      This code is not strictly correct per c++ spec section 14.2.4:
      
      > When the name of a member template specialization appears after . or -> in a
      > postfix-expression or after a nested-name-specifier in a qualified-id, and the
      > object or pointer expression of the postfix-expression or the
      > nested-name-specifier in the qualified-id depends on a template parameter
      > (14.6.2) but does not refer to a member of the current instantiation
      > (14.6.2.1), the member template name must be prefixed by the keyword template.
      > Otherwise the name is assumed to name a non-template.
      
      This causes clang to complain, but gcc is lax about this, as usual.
      
      Test Plan: compile stuff that use this.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D643515
      3e8d7341
    • Yiding Jia's avatar
      folly/dynamic fix use of incomplete type in template definition · 407e633f
      Yiding Jia authored
      Summary:
      the old code is ill-formed per spec (section 14.6.8):
      
      > If a type used in a non-dependent name is incomplete at the point at which a
      > template is defined but is complete at the point at which an instantiation is
      > done, and if the completeness of that type affects whether or not the program
      > is well-formed or affects the semantics of the program, the program is
      > ill-formed; no diagnostic is required.
      
      GCC is lax and allows this, clang gives an error.
      
      Test Plan: compiles.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D643431
      407e633f
    • Yiding Jia's avatar
      fix std::out_of_range calls to use real constructors · 35a186fe
      Yiding Jia authored
      Summary:
      curiously, std::out_of_range doesn't have a zero-argument constructor according
      to the spec. This was causing issues in my clang setup...
      
      Test Plan: compiles.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D643363
      35a186fe
    • Tudor Bosman's avatar
      fix Traits.md · 87e1985f
      Tudor Bosman authored
      Test Plan: looked at the generated html in a browser
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D642998
      87e1985f
    • Davide Bolcioni's avatar
      Fix output of 128 bit integer to string conversion. · 785dd995
      Davide Bolcioni authored
      Summary:
      Added specializations of folly::to<String> for __int128_t
      and __uint128_t.
      
      Test Plan: Added tests of the above to the integral to string tests.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D636992
      785dd995
    • Sergey Doroshenko's avatar
      Add bytesUsed() to folly::Arena · 817e76cb
      Sergey Doroshenko authored
      Summary:
      Returns number of bytes "really used by the user", i.e. number of bytes
      allocated on the arena via calls to `allocate()`.
      
      Test Plan: compiled, unit tests
      
      Reviewed By: azzolini@fb.com
      
      FB internal diff: D636976
      817e76cb
    • Tom Jackson's avatar
      Supressing GCC 4.7 warning for Optional · 4b1e7193
      Tom Jackson authored
      Summary:
      Supressing the warning for GCC4.7, and supressing the error supressing
      the warning in GCC4.6.
      
      Test Plan: Compile, run unit tests on GCC4.6 and GCC4.7
      
      Reviewed By: ldbrandy@fb.com
      
      FB internal diff: D635982
      4b1e7193
    • Soren Lassen's avatar
      use std::underlying_type to support enum classes · 4f0bc527
      Soren Lassen authored
      Summary:
      Noticed these TODOs in Conv.h and decided to fix them.
      Discovered that the underlying_type implementation also
      covers enum classes, which didn't work with the pre-existing code.
      
      Test Plan:
      fbconfig -r folly --platform=gcc-4.7.1-glibc-2.14.1-fb
      fbmake dbg _bin/folly/test/conv_test
      _bin/folly/test/conv_test
      
      --platform=gcc-4.6.2-glibc-2.13
      fbmake dbg _bin/folly/test/conv_test
      _bin/folly/test/conv_test
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D634309
      4f0bc527
    • Alan Frindell's avatar
      Fix IOBufQueue::preallocate for callers who really wanted a hard max · c462b064
      Alan Frindell authored
      Summary: D633912 broke unicorn because it relied on preallocate having a hard max.  Add an optional hard max parameter and rename maxHint to newAllocationSize.  Pass the hard max in for unicorn
      
      Test Plan: folly and unicorn unit tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D634894
      c462b064
    • Alan Frindell's avatar
      Return the maximum available space from IOBufQueue::preallocate · 01e1af4a
      Alan Frindell authored
      Summary: IOBufQueue::preallocate currently takes a min and max size, and will return to the caller a buffer with N writable bytes with min <= N <= max.  This is a bit wasteful, since there may be more than max bytes available at the end if the queue with no extra cost.  Now preallocate will return the full amount of contigious space to the caller, even if it is larger than the requested max.
      
      Test Plan: folly and proxygen unit tests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D633912
      01e1af4a
    • Dave Watson's avatar
      add clone / insert methods · 559830c8
      Dave Watson authored
      Summary:
      cursor.clone() will clone a length of the chain.  insert(std::move(buf)) will splice in a length of chain
      I want this to change thrift2 binary type to IOBuf: we will clone() the network data for zero-copy userspace data, and insert() it if the return value is a IOBuf.
      
      Test Plan: added unittest
      
      Reviewed By: afrind@fb.com
      
      FB internal diff: D632073
      559830c8
    • Adam Simpkins's avatar
      add IOBuf::maybeCopyBuffer() · cb771e84
      Adam Simpkins authored
      Summary:
      Add a version of IOBuf::copyBuffer() which accepts a std::string, as
      well as a maybeCopyBuffer() function which returns a null pointer if the
      input string is empty.
      
      In proxygen we have a few places where we construct an IOBuf from a
      string configuration parameter, and we almost always want a null pointer
      rather than an empty IOBuf chain if the string is empty.
      
      Test Plan: Included unit tests for these new functions.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D630547
      cb771e84
    • Tom Jackson's avatar
      Removing unneeded eachAs() operators · 389fb8a5
      Tom Jackson authored
      Summary: ##byLine## already yields StringPieces, no neat to ##eachAs()## then.
      
      Test Plan:
      fbconfig folly/experimental/symbolizer folly/test folly/experimental/io folly/experimental/io/test tupperware/agent
      fbmake opt
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D630422
      389fb8a5
    • Tudor Bosman's avatar
      static constexpr in enclosing class + lambdas make compilers unhappy? · b24f3cf8
      Tudor Bosman authored
      Test Plan: build
      
      Reviewed By: dneiter@fb.com
      
      FB internal diff: D630324
      b24f3cf8
    • Tudor Bosman's avatar
      one more · 47fc6cdf
      Tudor Bosman authored
      Test Plan: build
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D630280
      47fc6cdf