1. 31 Mar, 2014 1 commit
    • Tudor Bosman's avatar
      Harden usingJEMalloc() · cd838428
      Tudor Bosman authored
      Summary:
      In a shared library, we're using whichever memory allocator the main program
      uses, but we may still believe we're using jemalloc if we load libjemalloc.so
      (because rallocm is defined). This means we'll pass to rallocm pointers that
      were not allocated by jemalloc, which is bad.
      
      Test Plan: tests added
      
      Reviewed By: ngbronson@fb.com
      
      FB internal diff: D1228483
      cd838428
  2. 18 Mar, 2014 13 commits
    • Tom Jackson's avatar
      range(), for making Range<T*> from arrays and std::vector · d9c79af8
      Tom Jackson authored
      Summary: So people can more easily write functions which take contiguous values from memory.
      
      Test Plan: Unit tests
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1217809
      d9c79af8
    • Tianjiao Yin's avatar
      Add constexpr specifier for small_vector::max_size · 00162667
      Tianjiao Yin authored
      Summary: Now we could use small_vector::max_size in constant expressions
      
      Test Plan: unittest
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1224274
      00162667
    • Tudor Bosman's avatar
      Unbreak Symbolizer with small ElfCache · 4d966258
      Tudor Bosman authored
      Test Plan: fbconfig -r folly/experimental/symbolizer && fbmake runtests_opt && fbmake runtests
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D1224552
      
      @override-unit-failures
      4d966258
    • Alexey Spiridonov's avatar
      Move commited bits out of folly · 7f4c8868
      Alexey Spiridonov authored
      Summary: Preparing to land the other diffs. No code changes here, just moving files around.
      
      Test Plan: fbconfig bistro/common/cron/test bistro/common/cron/utils/test ; fbmake runtests
      
      Reviewed By: yinwang@fb.com
      
      FB internal diff: D1225159
      7f4c8868
    • Marc Celani's avatar
      sorted_vector_types have move inserts · cc4eb4c8
      Marc Celani authored
      Summary: sorted_vector_types were missing move inserts that come with std::map in c++11. This prevents me from using move iterators in folly::merge use case.
      
      Test Plan: unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1223426
      cc4eb4c8
    • Marc Celani's avatar
      folly::merge() - std::merge() with stronger guarantees (probably same implementation in practice) · cd3fcbcf
      Marc Celani authored
      Summary:
      std::merge() does not guarantee the ordering when equal elements belong in two ranges(comparator(it_a, it_b) == comparator(it_b, it_a) == 0). For maps, it is important that we can specify the ordering (see array_merge in php, where we guarantee which array's value will be present in the output if a key is present in both inputs).
      
      Also removes folly::merge that is specfic for sorted_vector_map since this will not be needed. NOTE: I expect this to break feed, will fix in a separate non-folly diff.
      
      Test Plan: This implementation is directly ripped from cppreference.com, but unit tests added none-the-less. Specifically, one is added where the output is a std::map to demonstrate its usefulness.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1223401
      
      @override-unit-failures
      cd3fcbcf
    • Marc Celani's avatar
      sorted_vector_types does not work with std::inserter · c3633870
      Marc Celani authored
      Summary:
      The signature of insert(hint, const val& v) is wrong. It should return an iterator, not pair<iterator, bool>. This breaks std::inserter, making it impossible to use this for std::merge. I plan to create folly::merge (std::merge with stronger semantics when equal values are present in the two input ranges), so I need this fixed.
      
      Given that the documentation claims this is a "drop in replacement" for std::map, I figure we should fix this.
      
      Test Plan: reran unit tests
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1223396
      c3633870
    • Marc Celani's avatar
      Introduce a merge() function for folly::sorted_vector_map · b2d3a93b
      Marc Celani authored
      Summary:
      Feed spends a non trivial amount of time merging two sorted_vector_maps. Writing code for this efficiently is actually a little tricky, and its much easier to maintain the simpler code. This adds merge() to folly so that its easy for feed and fast. Benchmarks with large input sizes show this is a gigantic win (moving from O(n^2) to O(n).
      
      Test Plan: unit tests, benchmark
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1221725
      
      @override-unit-failures
      b2d3a93b
    • Marcus Holland-Moritz's avatar
      Make sure folly::dynamic arrays can be used with folly::gen · f8e187f6
      Marcus Holland-Moritz authored
      Summary:
      Define a value_type for folly::dynamic to make arrays work with
      folly::gen::from.
      
      Test Plan:
      - added new unit test
      - fbconfig folly/test && fbmake runtests
      
      Reviewed By: tjackson@fb.com
      
      FB internal diff: D1216358
      f8e187f6
    • Dave Watson's avatar
      Move thrift/lib/cpp/async to folly. · 843b72c0
      Dave Watson authored
      Summary:
      Move the minimum amount of stuff and still have everything compile.  Would like to move TAsyncSocket/ServerSocket/SSL/UDP eventually, but not this round.
      
      thrift async is used very widely now: thrift, proxygen, newer mysql async interface, even trying it out in memcache.  A common complaint is that it doesn't get wide enough notice under thrift/, so let's move it to folly/.  After moving TAsyncSocket, both HHVM and proxygen could avoid a dep on thrift as well.
      
      Changes:
      * mv files to folly/io/async
      * remove 'T' prefix on classes/filenames
      * change namespace to 'folly'
      * remove any thrift references.
      
      Tried this before in D470080, this time doesn't attempt to abstract libevent
      
      @override-unit-failures
      
      Test Plan:
      fbconfig -r thrift; fbmake dev.
      Will iterate on any other contbuild failures
      
      Reviewed By: pgriess@fb.com
      
      FB internal diff: D1195393
      843b72c0
    • Philip Pronin's avatar
      update FOLLY_IS_TRIVIALLY_COPYABLE · e22f0a67
      Philip Pronin authored
      Summary:
      Let's make sure that boost version is intented to mean exactly
      the same as `std::is_trivially_copyable` (see 9 [class] / 6) to avoid any
      confusion (current boost path is more close to
      `std::is_trivially_copy_constructible` than to
      `std::is_trivially_copyable`;  UPD: unfortunately, old versions of boost
      don't support `boost::has_trivial_move_constructor` and friends, so I
      can't completely mimic `std::is_trivially_copyable` here).
      
      As mentioned in the original comment, `__has_trivial_copy` returns 1 in
      case of deleted copy ctor in clang (contradicts 12.8 [class.copy] / 13 +
      8.4.2 [dcl.fct.def.default] / 4), which makes `FOLLY_IS_TRIVIALLY_COPYABLE`
      accept `std::unique_ptr<>`; using `boost::has_trivial_destructor` would
      at least save us from the problems in this case.
      
      Alternative "solution" may be to rename `FOLLY_IS_TRIVIALLY_COPYABLE` to
      `FOLLY_IS_TRIVIALLY_COPY_CONSTRUCTIBLE`, and make sure
      `folly::small_vector` won't call dtor when memcopies the data around.
      
      Test Plan: fbconfig --clang folly/test:small_vector_test && fbmake runtests_opt (fails in trunk, passes with this diff)
      
      Reviewed By: pgriess@fb.com
      
      FB internal diff: D1216158
      e22f0a67
    • David Vickrey's avatar
      Add control of floating point serialization to JSON serialization · 46526221
      David Vickrey authored
      Summary: Title.  Note that this is a no-op with default parameters because folly::toAppend(double, &dest) calls folly::toAppend(double, &dest, DtoaMode, numDigits) with DtoaMode = SHORTEST and numDigits = 0.
      
      Test Plan: Tested new functionality in D1212547.
      
      Reviewed By: kelarini@fb.com
      
      FB internal diff: D1212617
      46526221
    • Adam Simpkins's avatar
      fix Cursor's copy constructor · c8ad790f
      Adam Simpkins authored
      Summary:
      The Cursor class didn't provide a copy constructor accepting a
      "const Cursor&".  The existing constructor only accepted references to
      non-const Cursor.
      
      This updates the constructor to also accept "const Cursor&".  I also
      made the template parameter checking more strict, so that it only
      accepts other CursorBase classes.  This prevents the compiler from
      thinking that a Cursor can be constructed from any other possible type
      when performing overload resolution.
      
      Test Plan: Ran all of the folly cursor tests.
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1208428
      c8ad790f
  3. 10 Mar, 2014 16 commits
    • Marcus Holland-Moritz's avatar
      Support numeric types as targets for folly::split · 9f95e046
      Marcus Holland-Moritz authored
      Summary:
      This extends the fixed version of folly::split to support numeric types
      as targets in addition to string pieces. I was almost certain this was
      already possible when I recently reviewed some code that did
      
      folly::StringPiece source, target, strFrequency;
      int frequency;
      if (folly::split('\t', line, source, target, strFrequency) &&
      (frequency = folly::to<unsigned int>(strFrequency)) > 0)
      
      and was about to suggest changing the above into:
      
      folly::StringPiece source, target;
      int frequency;
      if (folly::split('\t', line, source, target, frequency) && frequency > 0)
      
      I double checked and saw that only splitting to string pieces was supported.
      
      In the meantime I came across this pattern again and decided to just make
      it work because it's really convenient.
      
      The implementation should be fully backwards compatible.
      
      Test Plan:
      - New unit tests
      - fbconfig -r folly && fbmake runtests
      - Applied to github release, ./configure && make check
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D1187004
      9f95e046
    • Will Hodges's avatar
      Add setPort() to folly::URI class. · 86fd9acf
      Will Hodges authored
      Summary:
      Add setPort() method to URI class for easy port replacement in
      URIs.
      
      Facebook:
      Perform port replacement in WriteProcessor.cpp in a way that
      supports URI schemes. Add setPort() method to URI class to replace
      the port number in the authority portion of the URI.
      
      Test Plan: Test in debugger for dfsrouter changes.
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1209120
      86fd9acf
    • Philip Pronin's avatar
      folly/experimental/Bits.h + ASan · 85cf7e60
      Philip Pronin authored
      Summary: Allow disabling ASan for `folly::Bits`.
      
      Test Plan: [fb-only]
      
      Reviewed By: soren@fb.com
      
      FB internal diff: D1208584
      85cf7e60
    • Andrey Goder's avatar
      Fix comment · 08c2073d
      Andrey Goder authored
      Summary: This should be 'docs' not 'doc'. Too bad now it exceeds 80 chars :(.
      
      Test Plan: n/a
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D1209738
      
      @override-unit-failures
      08c2073d
    • Hannes Roth's avatar
      (Wangle) Support .then(function pointer) syntax · 4733fd1c
      Hannes Roth authored
      Summary:
      Support `.then(&static_function)`, `.then(&static_member_function)`, `.then(&Class::static_member_function)`, `.then(instance, &Class::member_function)` in Wangle.
      
      C++ does not allow `.then(instance, &member_function)`, sadly.
      
      This implementation just creates the closure for you and defers to the existing `then` implementations.
      
      Test Plan: Added a test.
      
      Reviewed By: hans@fb.com
      
      FB internal diff: D1204954
      4733fd1c
    • Philip Pronin's avatar
      use 0666 as the default permissions for new files · d3ee99f7
      Philip Pronin authored
      Summary: Seems like there is no real need to restrict permissions by default?
      
      Test Plan: fbconfig -r folly/test && fbmake runtests_opt
      
      @override-unit-failures
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1205527
      d3ee99f7
    • Hannes Roth's avatar
      (Wangle) Remove some early returns in tests · 44c12101
      Hannes Roth authored
      Summary:
      I guess they sneaked in when testing.
      
      Also remove an `EXPECT_NE` that depended on `std::move` actually moving.
      
      Test Plan: All the tests.
      
      Reviewed By: hans@fb.com
      
      FB internal diff: D1204971
      44c12101
    • Hannes Roth's avatar
      (Wangle) Actually support the universal reference used in whenAll · dacdff5d
      Hannes Roth authored
      Summary:
      Need to use `std::decay` to actually support the universal reference.
      
      The futures are moved in, and invalidated.
      
      Test Plan: Test; does not compile before.
      
      Reviewed By: hans@fb.com
      
      FB internal diff: D1199841
      dacdff5d
    • Shuo Li's avatar
      Replace random_device/mt19937 with folly/Random · 920a14c7
      Shuo Li authored
      Summary: Replace random_device/mt19937 with folly/Random to increase hygiene of using Random
      
      Test Plan:
      For each file is changed, fbmake -opt is run; except one file: stealing_test.cc, since the TARGETS file is not under the path.
      All fbmake are successfully passing
      
      Reviewed By: bmaurer@fb.com
      
      FB internal diff: D1199483
      
      Blame Revision: v1
      920a14c7
    • Hannes Roth's avatar
      (Wangle) whenAll should take rvalue references instead of references · 60c0047a
      Hannes Roth authored
      Summary: Don't need to keep the old futures around.
      
      Test Plan: `FutureTest.cpp`
      
      Reviewed By: hans@fb.com
      
      FB internal diff: D1197360
      60c0047a
    • Yedidya Feldblum's avatar
      Fix off-by-one affecting benchmark numbers in folly/io. · a640baa1
      Yedidya Feldblum authored
      Summary: Fix off-by-one affecting benchmark numbers in folly/io.
      
      Test Plan:
      $ fbconfig -r folly/io/test
      $ fbmake --fast opt
      $ _build/opt/folly/io/test/iobuf_cursor_test --benchmark
      $ _build/opt/folly/io/test/iobuf_network_bench --benchmark
      
      Reviewed By: simpkins@fb.com
      
      FB internal diff: D1199679
      
      Blame Revision: D344018
      a640baa1
    • Hans Fugal's avatar
      Add Wangle README.md · ac11c858
      Hans Fugal authored
      Summary:
      Facebook:
      Moving from Dex.
      Transliteration from whatever wiki format Dex uses to Markdown
      Some minor corrections/additions.
      
      Test Plan: Pasted into a private gist and it looks reasonable on github.
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1199510
      ac11c858
    • Marc Celani's avatar
      Make it easy to wrap pre-existing cob-style async apis · 44ecd1ef
      Marc Celani authored
      Summary:
      Tao neesd a way to wrap its c-style async apis with Later. Although my comments suggest that you can do this, it turns out I never got around to implementing it. Well, here is the implementation.
      
      Basically, we supply the callback to the pre-existing api, and that callback will fulfill a promise that is used internally within Later. This is thread safe because the async call is not made until the starter is fired, and we can use the future immediately for chaining then() calls.
      
      Test Plan: unit test
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1197721
      44ecd1ef
    • Marcelo Juchem's avatar
      Making folly/Benchmark.cpp clangable · 649cb97d
      Marcelo Juchem authored
      Summary: trunk fails to compile under clang: https://phabricator.fb.com/P6426175
      
      Test Plan: ran some benchmarks and checked output
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D1192933
      649cb97d
    • Hannes Roth's avatar
      (Folly) Fix error when compiling with clang · 122b967d
      Hannes Roth authored
      Summary:
      folly/Benchmark.cpp:427:9: error: logical not is only applied to the left hand side of this comparison
      if (!strcmp(get<1>(benchmarks[i]), "-") == 0) {
      
      Since the `!` binds to `strcmp`, removing both the `!` and the `== 0`
      should be equivalent.
      
      Reviewers of diff that introduced this line: D490324
      
      Test Plan: I compiled `tao/client` with/without this diff.
      
      Reviewed By: delong.j@fb.com
      
      FB internal diff: D1196452
      
      Blame Revision: rFBCODE6f5eea5fcd23044a5c579b040bf45d17006b4adf
      122b967d
    • Peter Griess's avatar
      Make Folly cpp_library targets more granular · e3225b60
      Peter Griess authored
      Summary:
      - Some users of Folly don't want to pull in the entire library just to
      use one feature (e.g. folly::to<T>). Throw those users a bone by
      breaking Folly up into a few discrete chunks: :uri, :range, :string,
      :format, etc. Leave the top-level :folly target alone so that existing
      users don't have to be changed.
      - Update some Thrift and Proxygen users to use the more granular
      targets.
      
      Test Plan: - Phabricator contbuild
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1192765
      e3225b60
  4. 28 Feb, 2014 10 commits
    • Paul Tarjan's avatar
      kill unused vars in folly · acdcf7e4
      Paul Tarjan authored
      Summary: these print as errors when compiling hhvm opensource
      
      Test Plan: none
      
      Reviewed By: tudorb@fb.com
      
      FB internal diff: D1195649
      acdcf7e4
    • Anton Likhtarov's avatar
      Easy: fix signed/unsigned comparisons · 581e60e2
      Anton Likhtarov authored
      Test Plan: build with -Wsign-compare, no warnings
      
      Reviewed By: njormrod@fb.com
      
      FB internal diff: D1193502
      581e60e2
    • Nathan Bronson's avatar
      make FB_LOG_EVERY_MS thread safe · 0a52fd7b
      Nathan Bronson authored
      Summary:
      Use compare_exchange_strong to update the previous time so that
      there is no race.  This diff also adds microbenchmarks.
      
      Test Plan: unit tests
      
      Reviewed By: andrei.alexandrescu@fb.com
      
      FB internal diff: D1191217
      0a52fd7b
    • Hans Fugal's avatar
      (wangle) more comment tweaks · 3fb62b36
      Hans Fugal authored
      Test Plan: eyeballs
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1185813
      3fb62b36
    • Hans Fugal's avatar
      (wangle) comment cleanup · 07b986bf
      Hans Fugal authored
      Summary: Cleaning up some inaccuracies, adding just a little detail in a few places, and trying very hard not to get OCD about the commenting style.
      
      Test Plan: still builds
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1184910
      07b986bf
    • Hans Fugal's avatar
      s/valueTry/getTry/ · c4b348c3
      Hans Fugal authored
      Summary: This is a better name
      
      Test Plan: unit tests. fbgs shows no external usage of this.
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1184905
      c4b348c3
    • Hans Fugal's avatar
      (wangle) remove Future::wait · 70fb1baf
      Hans Fugal authored
      Summary: pulling the trigger
      
      Test Plan: Unit tests. Wait for contbuild and dependent unit tests
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1184842
      70fb1baf
    • Hans Fugal's avatar
      Try Contains enum as an enum class · 53bcd888
      Hans Fugal authored
      Summary: Somebody set us up the enum
      
      Test Plan: Unit tests still build and pass. Will see if dependencies build and their unit tests pass. But I don't think anyone uses this outside of `Try` (they shouldn't anyway).
      
      Reviewed By: hannesr@fb.com
      
      FB internal diff: D1184839
      53bcd888
    • Stepan Palamarchuk's avatar
      Add method, that constructs Try<T> based on the result of functor. · 7bdae299
      Stepan Palamarchuk authored
      Summary:
      Usually we construct Try<T> as a result of execution of some functor.
      And we need to treat void and non-void functors in similar way, but that requires different, yet similar pieces of code.
      
      This diff simplifies future usage of Try.
      
      Test Plan: compile only
      
      Reviewed By: andrii@fb.com
      
      FB internal diff: D1190296
      7bdae299
    • Adam Simpkins's avatar
      add operator +, ==, and != to Cursor classes · 29ba8408
      Adam Simpkins authored
      Summary:
      Add operator+, which returns a new Cursor pointing the specified number
      of bytes ahead.  Cursor already implemented a += operator.
      
      Also add == and != operators for checking to see if two cursors are
      pointing to the same location.  Note that some derived cursor classes do
      contain additional state, and we don't consider that state when
      comparing for equality.  For instance, two Appenders pointing to the
      same location will compare as equal, even if they are configured with
      different growth parameters.  It seems like this is the behavior most
      users will expect, but let me know if you have concerns about this.
      
      Test Plan: Updated the unit tests to exercise the new operators.
      
      Reviewed By: davejwatson@fb.com
      
      FB internal diff: D1183537
      29ba8408