1. 21 Apr, 2013 19 commits
    • Tudor Bosman's avatar
      Revert "URI parsing in folly" · cd884e68
      Tudor Bosman authored
      Summary: Unbreak build.  third-party link not yet updated after https://phabricator.fb.com/D776457
      
      Test Plan: no
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D778669
      cd884e68
    • Tudor Bosman's avatar
      URI parsing in folly · 9ff69037
      Tudor Bosman authored
      Summary: Cleaned up from common/strings/URL.h, and it should be URI, not URL.
      
      Test Plan: tests added
      
      Reviewed By: chip@fb.com
      
      FB internal diff: D768880
      9ff69037
    • Christian Kamm's avatar
      Fix bug in reserve() and shrink_to_fit(). · c78e8cf4
      Christian Kamm authored
      Summary:
      impl_.e_ += newB - impl_.b_; fails when the difference
      between newB and impl_.b_ isn't a multiple of sizeof(T).
      
      Test Plan: .
      
      Reviewed By: oyamauchi@fb.com
      
      FB internal diff: D774754
      c78e8cf4
    • Tudor Bosman's avatar
      Make Subprocess::spawn more robust · e33bebd3
      Tudor Bosman authored
      Summary:
      We can't throw after the process is created, because we don't know what to do
      with it (and the Subprocess object goes up in smoke, so we can't rely on the
      caller to clean up, either).  So don't throw.
      
      If we throw before the process is created, make sure we clean up.
      
      Test Plan: subprocess_test
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D774722
      e33bebd3
    • Philip Pronin's avatar
      do not include iostream from Range.h · 570ec333
      Philip Pronin authored
      Summary:
      folly/Range.h is extensively used in fbcode, try to avoid including
      <iostream> (which is pretty heavy), include forward declarations
      (<iosfwd>) instead.
      
      Also transitioned it from 'std type_traits' + 'boost type_traits' to
      'std type_traits'.
      
      Test Plan: compiled, ran tests
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D774834
      570ec333
    • Adam Simpkins's avatar
      move Histogram.h to stats/ · bac6c8f1
      Adam Simpkins authored
      Summary:
      Move Histogram.h into the stats/ subdirectory, along side the
      BucketedTimeSeries code.  Eventually I plan to land more of our stats
      code in this subdirectory too.
      
      This also renames Histogram-inl.h to Histogram-defs.h, and no longer
      includes it by default from Histogram.h.  Instead, this adds a new
      stats/Instantiations.cpp file which explicitly instantiates
      Histogram<int64_t> and BucketedTimeSeries<int64_t>.  Most callers use
      these instantiations, and they now no longer need to include
      Histogram-defs.h.  Only callers that need other instantiations need to
      include Histogram-defs.h.  This will speed up build times.
      
      Test Plan:
      Ran "arc unit" to build all projects depending on folly, and verified
      they all still built and passed tests.
      
      Reviewed By: ldbrandy@fb.com
      
      FB internal diff: D761377
      bac6c8f1
    • Marcelo Juchem's avatar
      easier rebinding of allocators · 2624a682
      Marcelo Juchem authored
      Summary: rebinding allocators is too cumbersome, this diff implements a helper to make this job easier.
      
      Test Plan: unit test added
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D766451
      2624a682
    • Marcelo Juchem's avatar
      Making StlAllocator<Alloc, void> usable when rebinding. · 36b36626
      Marcelo Juchem authored
      Summary:
      currently, StlAllocator<Alloc, void> can't be used when you
      want an untyped allocator that can be rebound later since it doesn't
      carry the SimpleAllocator pointer with it. This diff fixes that.
      
      Test Plan: unit test added
      
      Reviewed By: jon.coens@fb.com
      
      FB internal diff: D766559
      36b36626
    • Michael Connor's avatar
      Initialize variable before using in own initialization · 8a4545ed
      Michael Connor authored
      Summary:
      Clang throws error because the callback refers to itself inside its lambda
      function definition.  I prevent this by declaring the variable first then the
      compiler does not complain when it is used within its lambda definition.
      
      folly/test/TimeoutQueueTest.cpp:99:37: error: variable 'cb' is uninitialized
      when used within its own initialization [-Werror,-Wuninitialized]
      
      Test Plan:
      fbconfig --clang --platform=gcc-4.7.1-glibc-2.14.1 --with-project-version
      boost:1.51.0 folly/test/
      fbmake opt
      fbmake runtests_opt
      
      Reviewed By: ldbrandy@fb.com
      
      FB internal diff: D753061
      8a4545ed
    • Jonathan Coens's avatar
      Soft-limit for arenas · 5e3674ca
      Jonathan Coens authored
      Summary: Create an artificial limit on an arena to start throwing bad_alloc before running out of system memory
      
      Test Plan: adjust unit test
      
      Reviewed By: marcelo.juchem@fb.com
      
      FB internal diff: D762695
      5e3674ca
    • Marcelo Juchem's avatar
      Fixing clang compatibility issues · 005a6c1f
      Marcelo Juchem authored
      Test Plan: all folly unit tests
      
      Reviewed By: andrewjcg@fb.com
      
      FB internal diff: D757374
      005a6c1f
    • Marcelo Juchem's avatar
      Implementing a traits class to check for incomplete types · 622fe822
      Marcelo Juchem authored
      Summary: A traits class to check for incomplete types
      
      Test Plan: unit tests added
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D760676
      622fe822
    • Lucian Grijincu's avatar
      folly: speed up fastpath of ThreadLocal::get() · ee31dcdd
      Lucian Grijincu authored
      Summary:
      A smaller function makes it more likely it will be inlined
      (it wasn't before, is now).
      
      Test Plan: n/a
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D759996
      ee31dcdd
    • Lucian Grijincu's avatar
      folly: speed up fastpath of StaticMeta::get() · 05fd9909
      Lucian Grijincu authored
      Summary:
      A smaller function makes it more likely it will be inlined
      (it wasn't before, is now).
      
      Test Plan: n/a
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D760000
      05fd9909
    • Marcelo Juchem's avatar
      as_stl_allocator "template alias" · c246dd22
      Marcelo Juchem authored
      Summary: Implementing as_stl_allocator as a companion to the existing make_stl_allocator
      
      Test Plan: unit tests added
      
      Reviewed By: jon.coens@fb.com
      
      FB internal diff: D755207
      c246dd22
    • Misha Shneerson's avatar
      Suppress unused variable warning · a25e59da
      Misha Shneerson authored
      Summary:
      HPHP compiler treats warnings as errors and the unused 'constuctor'
      variable breaks the build.
      
      Test Plan: Build
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D759559
      a25e59da
    • Tudor Bosman's avatar
      Optionally, kill subprocess when parent dies · 1f528c76
      Tudor Bosman authored
      Summary: Non-portable.
      
      Test Plan: test added
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D755528
      1f528c76
    • Tudor Bosman's avatar
      remove folly/eventfd.h · 4ace1217
      Tudor Bosman authored
      Test Plan: compile: fbconfig folly/experimental/io/test thrift/test unicorn/io/test common/system_features common/concurrency && fbmake opt
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D753552
      4ace1217
    • Brett Simmers's avatar
      Remove an unused variable in FormatValue<double> · 900b4f9b
      Brett Simmers authored
      Test Plan: Built a program that uses it
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D753460
      900b4f9b
  2. 27 Mar, 2013 13 commits
    • Tudor Bosman's avatar
      make sse4.2 functions in folly/Range.h build on -fb platform · 8ca18b6e
      Tudor Bosman authored
      Test Plan: fbconfig --platform=gcc-4.7.1-glibc-2.14.1-fb folly/test && fbmake runtests_opt
      
      Reviewed By: oyamauchi@fb.com
      
      FB internal diff: D749992
      8ca18b6e
    • Louis Brandy's avatar
      fix clang warnings in folly::Gen · 7677673c
      Louis Brandy authored
      Summary: Two clang warnings. It wants user defined consturctor for static initialization, and it wants fwd-declare to agree with full decleration in regards to struct v class.
      
      Test Plan:
      `fbconfig --clang --platform=gcc-4.7.1-glibc-2.14.1 folly/test/`
      
      And make sure it doesn't break normal build.
      
      Reviewed By: tulloch@fb.com
      
      FB internal diff: D749857
      7677673c
    • Peter Griess's avatar
      Add read/write mode to ElfFile · 37107ac7
      Peter Griess authored
      Summary:
      - Add a mode to ElfFile that allows opening the file for read/write
      access via PROT_WRITE.
      
      Test Plan:
      - Used it in some other code
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D740184
      37107ac7
    • Owen Yamauchi's avatar
      Handle non-Intel platforms in Range and CpuId · ae95c1d5
      Owen Yamauchi authored
      Summary:
      Compile out the SSE versions of these functions in Range, based on a new
      entry in folly-config.h.
      
      The change to CpuId feels slightly iffy to me. It seems like it would be
      more rigorous to make compiling CpuId.h on non-Intel an error, and force
      clients to handle non-Intel platforms at the callsite. However, I think
      that would be too susceptible to unintentional breakage on non-Intel
      platforms, since most people (including automated systems) aren't
      building and testing regularly on any. Falling back to saying "none of
      these features exist on this processor" seems like a reasonable
      alternative.
      
      Test Plan:
      fbmake runtests, with FOLLY_HAVE_EMMINTRIN_H set to 0 and 1.
      Make sure the SSE functions are getting compiled in or out as
      appropriate. ##autoreconf## and ##./configure## to regenerate
      folly-config.h.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D746872
      ae95c1d5
    • Peter Griess's avatar
      Add symbol name resolution and value retrieval · de2cc5ee
      Peter Griess authored
      Summary:
      - Add ElfFile::getSymbolByName(), which finds a Symbol object
      corresponding to the symbol w/ the given name
      - Add ElfFile::getSymbolValue(), which resolves the Symbol object to a
      value in the mapped file, following pointers if necessary
      
      Test Plan: - Unit tests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D740183
      de2cc5ee
    • Peter Griess's avatar
      Enable Elf::at<T> only for POD data types · d7050ad5
      Peter Griess authored
      Summary:
      - Make sure that the utility function Elf::at<T> only works for POD
      datatypes, as it uses reinterpret_cast<T>.
      
      Test Plan: - Unit tests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D748314
      d7050ad5
    • Peter Griess's avatar
      Move folly::symbolizer::systemError() into Exception.h · a6198d25
      Peter Griess authored
      Summary:
      - This is pretty similar to some stuff that we already have in
      Exception.h. Move (and rename) it.
      
      Test Plan: - Unit tests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D748313
      a6198d25
    • Owen Yamauchi's avatar
      Compile out GroupVarint on non-Intel · 5d43d2ab
      Owen Yamauchi authored
      Summary:
      Compile out instead of erroring.
      
      In an ideal world, we'd have a fallback that would work across platforms
      (i.e. no SSE, no unaligned 32-bit writes etc.) and compile some version
      of GroupVarint in all environments. I actually tried this; the SSE stuff
      is all behind #if __SSSE3__ already, so I thought it could work (modulo
      the unaligned-writes problem). I ran into problems with the
      SSSE3-vs.-not distinction that @simpkins alluded to in D652764, and
      decided I'd rather not open that can of worms at the moment.
      
      Test Plan:
      fbmake runtests. Manually force the #ifs to false and make
      sure fbmake runtests still passes (although GroupVarintTest is empty).
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D747150
      5d43d2ab
    • Louis Brandy's avatar
      StlAllocator.h + MakeUnique.h -> Memory.h · 244a8996
      Louis Brandy authored
      Summary:
      Go with the fat header approach. Merge these two into Memory.h. We could, potentially, include Malloc.h as well, but it fbstring header uses the once define for some special magic. Leave it alone for now.
      
      An alternate approach might be moving all three leaner headers into a `memory/` subdir with `folly/Memory.h` just #including the three.
      
      Test Plan:
      fbconfig folly/tests && fbmake runtests_opt
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D745873
      244a8996
    • Mike Curtiss's avatar
      HACK: Static detection of infinite sequences · ae4fa388
      Mike Curtiss authored
      Summary:
      Certain operations should not be performed on infinite sequences
      (e.g. sorting, left-folds, summation).  In some cases, we can
      detect that a sequence is infinite at compile-time and provide
      a static_assert to prevent such dangerous operations.
      
      Test Plan:
      Manually created cases where the operation should
      be disallowed.  Compiler correctly raised an error.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D740011
      ae4fa388
    • Louis Brandy's avatar
      Copyright 2012 -> 2013 · 5c77fedb
      Louis Brandy authored
      Summary: See title.
      
      Test Plan: Inspection.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D745883
      5c77fedb
    • Hans Fugal's avatar
      IOBuf::getIov · 51f6dea4
      Hans Fugal authored
      Summary:
      Generate an `fbvector` of `struct iovec` suitable for using with `writev` or
      `sendmsg`.
      
      This code is pretty straightforward, but Adam pointed out that something along
      these lines has already been done in thrift, so I followed that code closely.
      http://fburl.com/11586814
      
      Test Plan:
      fbmake runtests
      
      I am using also this in a prototype and it's working there.
      
      Reviewed By: agartrell@fb.com
      
      FB internal diff: D744055
      51f6dea4
    • Alessandro Salvatori's avatar
      allow to dequeue the first IOBuf in an IOBufQueue · 33a4bac6
      Alessandro Salvatori authored
      Summary: allow to dequeue the first IOBuf in an IOBufQueue
      
      Test Plan: throughly tested with some dependent code in proxygen
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D732484
      33a4bac6
  3. 19 Mar, 2013 8 commits
    • Mike Curtiss's avatar
      Use aligned loads for Range::find_first_of · 81af5c4c
      Mike Curtiss authored
      Summary:
      Aligned loads are faster on some architectures. Let's refactor
      qfind_first_of so that it uses aligned loads when possible.
      
      Also modify the benchmarks to account for begin/end-of-string
      logic.
      
      Test Plan:
      Tests pass. Updated benchmarks.  Generally seeing a 5-20%
      speed-up, depending on the situation.
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D720369
      81af5c4c
    • Tom Jackson's avatar
      Short-circuit operator== based on size() · df1ffef3
      Tom Jackson authored
      Summary:
      We don't do this today, but it looks like std::string does. For longer, similar strings, this is a big win.
      
      Before:
      
      ```lang=text
      ============================================================================
      ./folly/test/FBStringTestBenchmarks.cpp.h       relative  time/iter  iters/s
      ============================================================================
      BM_equality_string(65536)                                    5.13ms   194.87
      BM_equality_fbstring(65536)                                 11.34ms    88.18
      ============================================================================
      ```
      
      After:
      
      ```lang=text
      ============================================================================
      ./folly/test/FBStringTestBenchmarks.cpp.h       relative  time/iter  iters/s
      ============================================================================
      BM_equality_string(65536)                                    5.01ms   199.74
      BM_equality_fbstring(65536)                                  6.63ms   150.78
      ============================================================================
      ```
      
      Test Plan: Benchmark, unit  tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D737482
      df1ffef3
    • Tom Jackson's avatar
      Fix unsplit(", ") · 76d60885
      Tom Jackson authored
      Summary: Otherwise you get errors like `error: array used as initializer ./folly/experimental/StringGen-inl.h: In constructor ‘folly::gen::detail::UnsplitBuffer<Delimiter, OutputBuffer>::UnsplitBuffer(const Delimiter&, OutputBuffer*) [with Delimiter = char [3] ...]`, since literal strings bind as reference to fixed-length character arrays. Providing an explicit overload for `const char*` fixes this.
      
      Test Plan: Unit tests
      
      Reviewed By: tulloch@fb.com
      
      FB internal diff: D737117
      76d60885
    • Marcelo Juchem's avatar
      adding is_non_positive traits · 1bf1654c
      Marcelo Juchem authored
      Summary:
      template <typename SomeInt>
      void foo(SomeInt x) {
      // yields an error in clang when SomeInt is unsigned and -Werror is used
      if(x <= 0) {
      //...
      }
      }
      
      Test Plan: added unit tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D735735
      1bf1654c
    • David Vickrey's avatar
      Make hash_combine accept a configurable hash function · e4f530f8
      David Vickrey authored
      Summary:
      std::hash is not awesome and not configurable.  Typical cases you might want to customize are:
      string: I happen to know that fnv isn't super awesome, for example, and that's what folly uses for std::hash fbstring.
      pointers: you may want to hash the contents of the pointer instead of the address for certain types.
      
      This is a very simple diff that lets you do that.  It provides StdHasher that passes through to std::hash and uses that for hash_combine, so this should be 100% backward compatible.
      
      Test Plan: test_hash.  I will add another test for using a hasher besides StdHasher shortly.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D733899
      e4f530f8
    • Tom Jackson's avatar
      Fixing namespace for GeneratorBuilder, more moves for Params · 9fb46d14
      Tom Jackson authored
      Summary:
      GENERATOR was broken if you didn't `using namespace folly::gen`, and
      we're still copying quite a few functors where we could move them.
      
      Test Plan: Unit tests
      
      Reviewed By: chaoyc@fb.com
      
      FB internal diff: D731253
      9fb46d14
    • Lovro Puzar's avatar
      Add explicit assignment operator definitions to Optional · fd20c97c
      Lovro Puzar authored
      Summary:
      See new test.  Under GCC 4.6 (which is what the folly tests build with) the old code works fine but under 4.7 building fails with:
      
      folly/test/OptionalTest.cpp: In member function ‘virtual void Optional_AssignmentContained_Test::TestBody()’:
      folly/test/OptionalTest.cpp:122:14: error: use of deleted function ‘ContainsOptional& ContainsOptional::operator=(const ContainsOptional&)’
      folly/test/OptionalTest.cpp:106:21: note: ‘ContainsOptional& ContainsOptional::operator=(const ContainsOptional&)’ is implicitly deleted because the default definition would be ill-formed:
      folly/test/OptionalTest.cpp:106:21: error: use of deleted function ‘folly::Optional<int>& folly::Optional<int>::operator=(const folly::Optional<int>&)’
      In file included from folly/test/OptionalTest.cpp:17:0:
      ./folly/Optional.h:84:7: note: ‘folly::Optional<int>& folly::Optional<int>::operator=(const folly::Optional<int>&)’ is implicitly declared as deleted because ‘folly::Optional<int>’ declares a move constructor or move assignment operator
      folly/test/OptionalTest.cpp:129:30: error: use of deleted function ‘ContainsOptional& ContainsOptional::operator=(ContainsOptional&&)’
      folly/test/OptionalTest.cpp:108:21: note: ‘ContainsOptional& ContainsOptional::operator=(ContainsOptional&&)’ is implicitly deleted because the default definition would be ill-formed:
      folly/test/OptionalTest.cpp:108:21: error: non-static data member ‘ContainsOptional::opt_’ does not have a move assignment operator or trivial copy assignment operator
      folly/test/OptionalTest.cpp:137:14: error: use of deleted function ‘ContainsOptional& ContainsOptional::operator=(const ContainsOptional&)’
      
      Test Plan:
      (1) fbconfig folly/test && fbmake dbg && _build/dbg/folly/test/optional_test
      (2) Remove folly/PLATFORM to build with gcc 4.7, then repeat (1).  Without the code fix, the new test fails to build.  With the fix, the test builds and runs fine.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D732402
      fd20c97c
    • Ben Gertzfield's avatar
      folly (easy): Disable GCC-specific warning disabling hacks in clang · d006f324
      Ben Gertzfield authored
      Summary:
      When compiling folly with clang, the compiler warns about our
      use of GCC-specific pragmas to silence incorrect compiler warnings:
      
      folly/Optional.h:79:33: warning: unknown warning group '-Wpragmas', ignored [-Wunknown-pragmas]
      folly/Optional.h:80:33: warning: unknown warning group '-Wmaybe-uninitialized', ignored [-Wunknown-pragmas]
      
      Thankfully, those incorrect compiler warnings are not emitted by
      clang, so we can just disable the pragmas in clang.
      
      Test Plan:
      Built folly in gcc and ran it through clang. Warning above
      is gone.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D733323
      d006f324