1. 26 Aug, 2012 5 commits
    • Tudor Bosman's avatar
      sizeof works just as well as numeric_limits<T>::digits · 442e1c0c
      Tudor Bosman authored
      Summary: ... and is shorter and more readable
      
      Test Plan: folly/test
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D545774
      442e1c0c
    • Nicholas Ormrod's avatar
      Increased std::vector compatibility of fbvector · bf188b34
      Nicholas Ormrod authored
      Summary:
      fbvector was not accepting move_iterators for
      InputIterator-templated construct, assign, and insert. The root cause
      was the check '(b_ <= &*first && &*first < e_)', used to check if the
      assignment was from internal data. This addressof check does not compile
      with rvalue-references, and causes the first iterator to be dereferenced
      more than once; both against the contract of std::vector. The standard
      allows for undefined behaviour in the self-iterator case, so there are
      no contractual barriers to removing this check.
      
      Test Plan:
      run fbvector test and benchmark. An fbgs for 'assign' turns
      up few matches; the seem to be normal use-case. Test fbvector assign
      with self-iterators in order (i.e. fbv.assign(fbv.begin(), fbv.end()));
      this seems to work fine.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D535012
      bf188b34
    • Tom Jackson's avatar
      Removing broken specialization of std::hash<std::tuple> · cc1518db
      Tom Jackson authored
      Summary: ^
      
      Test Plan: Unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D543586
      cc1518db
    • Jeremy Lilley's avatar
      Add "short append" benchmark to fbstring benchmark suite. · be7be7e2
      Jeremy Lilley authored
      Summary:
      Appending many small strings to fbstring appears much slower (~3x) vs.
      std::string. Adding benchmark case to illustrate.
      
      [If this isn't wanted, I can revert]
      
      Test Plan: This is a benchmark.
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D544159
      be7be7e2
    • Andrew Gallagher's avatar
      folly::dynamic: comment about std::vector const-iter erase issue · 5d3f05bd
      Andrew Gallagher authored
      Test Plan: none
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D543196
      5d3f05bd
  2. 08 Aug, 2012 9 commits
    • Tudor Bosman's avatar
      Unbreak folly build on fedora / ubuntu · e6ceb4cd
      Tudor Bosman authored
      Test Plan: built
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D543320
      e6ceb4cd
    • Tudor Bosman's avatar
      Use gcc builtins instead of library functions for ffs* · 2d94f427
      Tudor Bosman authored
      Summary:
      because, shockingly, glibc doesn't divert to the gcc builtins which are
      inlined and fast
      
      Test Plan: folly/test
      
      Reviewed By: sding@fb.com
      
      FB internal diff: D543363
      2d94f427
    • Tudor Bosman's avatar
      Remove 1 instruction from popcount · 71acc41b
      Tudor Bosman authored
      Summary:
      by removing the unnecessary constraint that the input and output be in
      the same register (copypasta from https://phabricator.fb.com/D542718)
      
      Test Plan: folly/test
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D543310
      71acc41b
    • Tudor Bosman's avatar
      Detect popcnt instruction at runtime, use it if available. · 7fd87e7e
      Tudor Bosman authored
      Summary:
      If compiled for a popcnt-supporting target (-march=corei7, for example),
      use __builtin_popcount, as it's presumably inlined.  Otherwise, detect
      on startup (in the same way as glibc dispatches to one of the many
      flavors of memcpy): GCC allows us to add a resolver function which the
      dynamic loader will call on startup to resolve a function to one of
      various alternatives; we check (using the cpuid instruction) whether
      popcnt is supported, and use it if available.
      
      Test Plan: tests added
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D542977
      7fd87e7e
    • Andrew Gallagher's avatar
      folly::dynamic: use std::vector instead of folly::fbvector · 192cff5d
      Andrew Gallagher authored
      Summary:
      It appears that std::unordered_map is no longer relocatable in
      gcc-4.7.  Use std::vector instead, until fbvector supports non-
      relocatable types.
      
      Test Plan: Built and ran facebar tests under gcc-4.7.  Also ran folly unittests.
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D543099
      192cff5d
    • Xiaoyang Gao's avatar
      Add operator== and operator!= to folly::StlAllocator · 0286cb33
      Xiaoyang Gao authored
      Summary: Add operator== and operator!= to folly::StlAllocator, which are required by some other libraries.
      
      Test Plan: Tested by running with recursive_wrapper in boost::variant, and unit tests in folly/test.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D541237
      0286cb33
    • James Sharpe's avatar
      Remove unused logging header · 367a8b2c
      James Sharpe authored
      Test Plan: Compiled.
      
      Reviewed By: andrewjcg@fb.com
      
      FB internal diff: D541226
      367a8b2c
    • Daniel Wu's avatar
      Minor typo in comments · 0e47ceb0
      Daniel Wu authored
      Summary: github pull #11
      
      Test Plan: None.
      
      Reviewed By: andrewjcg@fb.com
      
      FB internal diff: D541230
      0e47ceb0
    • Andrew Gallagher's avatar
      fbstring: mute uninitialized warnings in fbstring code · cedbb3d0
      Andrew Gallagher authored
      Summary:
      fbstring generates some apparently false positive uninitialized warnings
      under gcc-4.7.1.  This diff disables the '-Wuninitialized' flag for
      fbstring.
      
      Test Plan: build
      
      Reviewed By: ldemailly@fb.com
      
      FB internal diff: D542722
      cedbb3d0
  3. 05 Aug, 2012 1 commit
  4. 02 Aug, 2012 8 commits
    • Abhijeet Joglekar's avatar
      Allow capacity and length to be different for user buffers · 00616345
      Abhijeet Joglekar authored
      Summary:
      Currently, takeOwnership lets a user pass in a data buffer and wraps it in an
      IOBuffer. However, the capacity and length of the user buffer are required to
      be same.
      
      Added a new API to allow buffers where the capacity and length can be different.
      
      Users of existing API should not be affected.
      
      Test Plan:
      1) Added new test case to IOBufTest that checks buffers with length
      different from capacity
      2) Run existing IOBuf test cases to verify no regressions
      
      Reviewed By: brianp@fb.com
      
      FB internal diff: D536575
      00616345
    • Wei Wu's avatar
      Make AtomicHashMap support move constructible types · bc46f015
      Wei Wu authored
      Summary: modified AtomicHashArray and AtomicHashMap to support move constructible types
      
      Test Plan: tested with fbcode/folly/test/AtomicHashArrayTest.cpp and fbcode/folly/test/AtomicHashMapTest.cpp
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D527270
      bc46f015
    • Rajat Goel's avatar
      Moving some more benchmarks to fbcode benchmark system · f1c708fc
      Rajat Goel authored
      Summary: The format benchmark that was ported some time back has few data points to show - http://fburl.com/3545876
      
      Test Plan: fbmake --log-to-rfe runbenchmarks_opt
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D524306
      f1c708fc
    • Tudor Bosman's avatar
      Add IEC binary unit prefixes · 2afd1f1a
      Tudor Bosman authored
      Summary: KiB, MiB, GiB, TiB, etc
      
      Test Plan: by hand in a program using them
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D527001
      2afd1f1a
    • Nathan Bronson's avatar
      add sched_yield in RWTicketSpinLock · 1805d922
      Nathan Bronson authored
      Summary:
      This diff makes RWTicketSpinLock eventually start calling
      sched_yield() during shared and aggressive exclusive lock access, to
      avoid pathologies that can arise when the number of threads far
      exceeds the number of actual cores.
      
      Test Plan:
      1. unit tests
      2. benchmark w/o + w/ diff
      
      Reviewed By: nathan@fb.com
      
      FB internal diff: D524897
      1805d922
    • Jordan DeLong's avatar
      Add folly::applyTuple utility · 9aa33f6a
      Jordan DeLong authored
      Summary: Applies a function to a std::tuple of arguments.
      
      Test Plan: Unit test.
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D520190
      9aa33f6a
    • Tudor Bosman's avatar
      Fix an issue in IOBufQueue::move · 57bb532f
      Tudor Bosman authored
      Summary: That's all.
      
      Test Plan: .
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D520116
      57bb532f
    • Tudor Bosman's avatar
      Add wrapper macros for "final" and "override" · 3e0db1be
      Tudor Bosman authored
      Summary:
      ... which are supported in gcc 4.7, but not 4.6, and they enable useful
      optimizations.  As long as we're planning to support both 4.6 and 4.7 in
      our code base, we should write code using these macros.
      
      Test Plan:
      test added, compiled with both 4.6 and 4.7, verified the
      assertion in the test comment by looking at dissassembly output in the
      4.7 version
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D520343
      3e0db1be
  5. 14 Jul, 2012 1 commit
  6. 13 Jul, 2012 16 commits
    • Tudor Bosman's avatar
      rallocm(ALLOCM_ZERO) only zeroes *new* memory · 69e9440b
      Tudor Bosman authored
      Summary:
      If you allocate N bytes and then try to grow that in place using rallocm
      (ALLOCM_ZERO | ALLOCM_NO_MOVE) to M > N, our code assumed that all
      memory from N to M would be zeroed.  In fact, rallocm only zeroes *new*
      memory, so if jemalloc actually allocated N1 > N bytes initially,
      rallocm will only zero memory from N1 to M.
      
      Fixed by using calloc.
      
      Test Plan: thread_local_test, tested in production
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D519781
      69e9440b
    • Rajat Goel's avatar
      A sample diff thats ports FormatTests to benchmarks · 37f18254
      Rajat Goel authored
      Summary:
      Is there any better solution? Maybe a generic flag in Benchmarks to say
      please don't run benchmarks?
      
      Test Plan: (not in folly)
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D503619
      37f18254
    • Tudor Bosman's avatar
      Unbreak build. · 8508742e
      Tudor Bosman authored
      Summary: I could have sworn I undid that un-templatification of the constructor.
      
      Test Plan: build folly/test
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D518981
      8508742e
    • Tudor Bosman's avatar
      Range<const char*> -> Range<const unsigned char*> implicit conversion · 51ef8c7a
      Tudor Bosman authored
      Summary: As they can both be used to represent ranges of bytes.
      
      Test Plan: test added
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D518666
      51ef8c7a
    • Tudor Bosman's avatar
      (minor changes, part of unrelated diff) · d50251a5
      Tudor Bosman authored
      Test Plan: No
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D515713
      d50251a5
    • Tudor Bosman's avatar
      Make Bits<T> work with T = Unaligned<X> (X is unsigned integral type) · 7488db1c
      Tudor Bosman authored
      Test Plan: all folly tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D517118
      7488db1c
    • Andrew Gallagher's avatar
      folly/Malloc.h: use libstdc++-safe exception wrappers · 25189ad9
      Andrew Gallagher authored
      Summary:
      gcc errors out when code that throws is compiled with
      '-fno-exceptions'.  Since we add Malloc.h into our custom libstdc++
      use the exception wrappers from functexcept.h so that they can build
      with third-party projects that use '-fno-exceptions'.
      
      Test Plan:
      Built llvm in the gcc-4.7.1-glibc-2.14.1-fb platform with these
      changes.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D516577
      25189ad9
    • Philip Pronin's avatar
      fix memory order in AtomicHashMap<>::findInternal() · 5eeb7509
      Philip Pronin authored
      Summary:
      Looks like a typo, it should obviously be std::memory_order_relaxed (all
      necessary synchronization is done on numMapsAllocated_).
      
      Test Plan: compiled it, ran tests
      
      Reviewed By: sahrens@fb.com
      
      FB internal diff: D515322
      5eeb7509
    • Andrew Gallagher's avatar
      folly: fix build on ubuntu and fedora platforms · dcf79b80
      Andrew Gallagher authored
      Summary:
      A boost regex dependency wasn't added to the Makefile.am file.  Also
      the it appears that boost thread lib dependencies had a typo in the
      makefile variable name.
      
      Test Plan: ran builds on ubunutu and fedora VMs
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D514039
      dcf79b80
    • Tudor Bosman's avatar
      (minor changes, part of unrelated diff) · 6dca2b32
      Tudor Bosman authored
      Test Plan: no
      
      Reviewed By: philipp@fb.com
      
      FB internal diff: D512868
      6dca2b32
    • Tudor Bosman's avatar
      Add IOBufQueue::prepend, fix bug in IOBuf::prepend. · 53d4209f
      Tudor Bosman authored
      Summary:
      IOBuf::prepend needs to increment length_.
      
      Added IOBufQueue::prepend, which uses the headroom in the first buffer
      instead of growing the queue at the head.
      
      Test Plan: tests added
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D513676
      53d4209f
    • Eitan Frachtenberg's avatar
      Improve digits_to() performance · b384b6bc
      Eitan Frachtenberg authored
      Summary:
      This optimization eliminates about 75% of the multiplications and bounds
      checking in the original code by using constant lookup tables to convert
      from decical digit to (shifted) binary number, instead of arithmetic.
      The total cost of the lookup tables is 2KB of static memory, but the
      average throughput gain across the range from 1 to 19 characters is 27%.
      The throughput distributes as follows: (in million iters/sec)
      Bytes   Orig    New     Speedup
      1       101.31  110.12  109%
      2       97.42   110.12  113%
      3       97.42   105.53  108%
      4       79.13   101.31  128%
      5       74.48   97.42   131%
      6       74.48   93.81   126%
      7       70.35   93.81   133%
      8       61.77   79.14   128%
      9       58.9    72.35   123%
      10      58.9    74.48   126%
      11      56.28   74.48   132%
      12      50.22   64.93   129%
      13      48.52   60.3    124%
      14      47.74   61.77   129%
      15      46.88   61.77   132%
      16      42.54   55.06   129%
      17      41.51   51.69   125%
      18      40.97   52.76   129%
      19      39.57   52.76   133%
      
      Test Plan: Passes all unit tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D493245
      b384b6bc
    • Tudor Bosman's avatar
      Add multi-bit operations to folly/experimental/Bits.h · 2a4a4178
      Tudor Bosman authored
      Summary: Add ability to set and get N consecutive bits from the bit sequence.
      
      Test Plan: test added
      
      Reviewed By: lucian@fb.com
      
      FB internal diff: D511438
      2a4a4178
    • Rafael Sagula's avatar
      adding StringPiece constructor that takes a piece of another StringPiece · e9ee87a6
      Rafael Sagula authored
      Summary:
      adding what seems to be a missing constructor to StringPiece --
      I need to be able to take a piece of another StringPiece. (It's possible
      to do that with all sorts of strings already, except StringPiece...)
      
      Test Plan: na -- tested as part of other (dependent) diffs
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D508545
      e9ee87a6
    • Tudor Bosman's avatar
      Remove unnecessary member variable. · 4138e84a
      Tudor Bosman authored
      Test Plan: No
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D509324
      4138e84a
    • Spencer Ahrens's avatar
      add bm_max/min_iters and bm_regex · 13692fcf
      Spencer Ahrens authored
      Summary: These were handy in the old framework and easy enough to add.
      
      Test Plan:
      ran ThreadCachedIntTest - got better (but not perfect due to
      subtraction of single-threaded baseline from multi-threaded results).
      
      Reviewed By: sherman.ye@fb.com
      
      FB internal diff: D490324
      13692fcf