- 06 Jun, 2017 12 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Rename `exception_wrapper::get_object` to `get_exception`. This will be a template overload of the existing non-template member `get_exception`, but it should just work. Reviewed By: spacedentist Differential Revision: D5180845 fbshipit-source-id: 28e16e039ec6a7939b38f217b4ad5c6bc803f515
-
Adam Simpkins authored
Summary: - Fix TimePoint to use steady_clock rather than system_clock - Use nanoseconds instead of milliseconds in most locations This code should probably also be moved into a folly::testing namespace or something. This class is pretty specific to unit tests, and `folly::TimePoint` seems like too generic of a name for it. However, just to keep things simple I'm not doing that as part of this diff yet. Reviewed By: yfeldblum Differential Revision: D5175630 fbshipit-source-id: 26490fc7ff1b25fb86f09309e81108828cd0f091
-
Adam Simpkins authored
Summary: Use the newly introduced getOSThreadID() function to get a thread ID for determining thread scheduling information on Linux. Reviewed By: yfeldblum Differential Revision: D5173596 fbshipit-source-id: 3e6fa352c3774986b0ac1f93bd6c7e4a29e08471
-
Adam Simpkins authored
Summary: Some of the code in TimeUtil.cpp computes how long the current thread has spent waiting to be schedule on the CPU, so we can discount this time when testing timeout behavior. It appears that this code has been broken for a fairly long time. Older Linux kernels reported values in /proc/<pid>/schedstat using jiffies. However, it appears that this was changed in Linux 2.6.23 to report values using nanoseconds. (It looks to me like this was changed in commit 425e0968a25f, which purports to simply be moving code from sched.c to sched_stats.h, but it appears to also have also changed this behavior.) This updates TimeUtil.cpp to compute the value correctly in modern Linux kernels. Reviewed By: yfeldblum Differential Revision: D5173598 fbshipit-source-id: 98436d3a687400bf68661156ffce93eea7232632
-
Dave Watson authored
Summary: Adds a core-local allocator to CacheLocality. Multiple objects using cache locality may share the same allocator, and allocate things less than cacheline sized, without incurring additional false-sharing overhead. Reviewed By: nbronson, ot Differential Revision: D5139886 fbshipit-source-id: a9804662d6339829a12e0791f418dabd9678f1bf
-
Christopher Dykes authored
Summary: `kDecayCmd` was guarded such that it wasn't being defined at all if JEMalloc wasn't available. Closes https://github.com/facebook/folly/issues/608 Reviewed By: interwq Differential Revision: D5193721 fbshipit-source-id: 1a2666de70e90eac1e9f2e130d0452b01b3239fa
-
Victor Zverovich authored
Summary: This diff adds a Traits template parameter to IndexedMemPool that allows more control over the lifetime management of individual elements, including mixes of lazy and eager recycle semantics (or colocation of different classes of data inside a single element). It also arranges that an index is not reported as isAllocated() until it has been passed to Traits::initialize and passed to Traits::onAllocate at least once, so code that is traversing valid indexes doesn't need to deal with the post-initialize but pre-onAllocate state (it must still deal with indexes that reported isAllocated() as true but have since been passed to onRecycle). The default behavior is unchanged. Reviewed By: nbronson Differential Revision: D5177462 fbshipit-source-id: e7d22c860ab6bf25083977dfb5a63955641c9cfb
-
Christopher Dykes authored
Summary: MemoryMapping doesn't use fbstring directly at all, so this include isn't needed. Reviewed By: yfeldblum Differential Revision: D5188209 fbshipit-source-id: d86b876a96343c830295bea1162580215a340815
-
Adam Simpkins authored
Summary: The syscall() function is defined in <unistd.h> <sys/syscall.h> apparently only defines IDs to be used with syscall(), but does not define the syscall() function itself. This caused build failures for files that included ThreadId.h before unistd.h Reviewed By: Orvid Differential Revision: D5189658 fbshipit-source-id: 2ec8ea1d58f3fc14cf458a53ecaa811978527398
-
Nathan Bronson authored
Summary: This diff adds helper functions that can resize std::string or std::vector without constructing or initializing new elements. They are designed for retroactively optimizing code where touching every element twice (or touching never-used elements once) shows up in profiling, and where restructuring the code to use fixed-length arrays or IOBuf-s would be difficult. Implementations are provided for 5 string implementations (pre-c++11 libstdc++, libstdc++ with SSO, libc++, std::basic_fbstring, and MSVC) and 3 vector implementations (libstdc++, libc++, and MSVC). On an unsupported platform you will hopefully get a #warn if you include UninitializedMemoryHacks.h followed by a linker error if you actually use it. Reviewed By: yfeldblum Differential Revision: D5102679 fbshipit-source-id: 536c00eabae4cdb8a0affe3e919a372f4dc51ac5
-
Qi Wang authored
Summary: Update decay time API to be jemalloc 4 & 5 compatible. Reviewed By: yfeldblum Differential Revision: D5188574 fbshipit-source-id: 8e3c26c8b6431efdd0ec7ff492a065bddb816b4b
-
Adam Simpkins authored
Summary: Add a getOSThreadID() call. This is similar to getCurrentThreadID(), but returns the OS-level thread ID. Reviewed By: yfeldblum Differential Revision: D5173627 fbshipit-source-id: 0e8695ecfc1e382d12526c1b7d1717be114c9f4a
-
- 05 Jun, 2017 6 commits
-
-
Christopher Dykes authored
Summary: These builtins are available on all platforms under GCC, using the instruction directly when available and a fallback implementation otherwise. They are implemented in the builtins portability header for MSVC. Reviewed By: yfeldblum Differential Revision: D5185106 fbshipit-source-id: a58305a6b99eb49bd165876a4a60c512a259b225
-
Christopher Dykes authored
Summary: This makes the name of the header match the source file. Reviewed By: yfeldblum Differential Revision: D5186193 fbshipit-source-id: b1f9041fb730eacb91ad167e500c25df8f8ba947
-
Yedidya Feldblum authored
Summary: [Folly] Let map-related functions be templated over key types. This supports the case where map members like `find` may be overloaded or templated on types other than the map's `key_type const&`. In C++14, standard library map types gain template overloads for `find` and for other members, permitting lookups without constructing `key_type` instances. This is useful primarily when `key_type` is expensive but another object type comparable with `key_type` is inexpensive. As a common example, a `key_type` of `std::string` is expensive in the general case because it allocates storage on the heap but `std::string_view` (C++17), when constructed with non-allocated `char const*, std::size_t`, would be inexpensive. Reviewed By: terrelln Differential Revision: D5145879 fbshipit-source-id: 979b75bfe55661aab11d5302da1bcd7830abd5af
-
Peter Goldsborough authored
Summary: The docs give `ThreadLocalPRNG rng = Random::threadLocalPRNG()` as an example of creating a thread local PRNG, but `Random::threadLocalPRNG()` does not/no longer exist. I think it's just `folly::ThreadLocalPRNG` right now. Reviewed By: yfeldblum Differential Revision: D5184992 fbshipit-source-id: 63a9ef62b32fca42088abec419ae53531910cc82
-
Qi Wang authored
Summary: Destroy created arena which has extent_hooks linked. Reviewed By: jasone Differential Revision: D5177535 fbshipit-source-id: 7d75f4276fc174c4d4ce1102dfb8ec8c27c1f56d
-
Phil Willoughby authored
Summary: Add `count()` and `swap()` methods. Ensure that `operator==` works. Reviewed By: yfeldblum Differential Revision: D5169393 fbshipit-source-id: a8025f6fdf251e38b0d2f27733d18967a55c6a15
-
- 04 Jun, 2017 3 commits
-
-
Christopher Dykes authored
Summary: We are fully on C++14 now, so these warnings should never be firing. Reviewed By: yfeldblum Differential Revision: D5179124 fbshipit-source-id: 31c6ddbce5c45b60fe73990f49d65ac95d17fe87
-
Christopher Dykes authored
Summary: Do this by moving the two helpers that need to refer to them into `folly/futures/helpers.h`. Reviewed By: yfeldblum Differential Revision: D5179109 fbshipit-source-id: bdb319ff3432d3629a955c1390dc8bf6f27f4ce6
-
Christopher Dykes authored
Summary: It's deprecated, so use the non-deprecated form instead. Reviewed By: yfeldblum Differential Revision: D5179133 fbshipit-source-id: 91440bc3768ee68d2aada2299fbfbcdd852f946c
-
- 03 Jun, 2017 1 commit
-
-
Yedidya Feldblum authored
Summary: [Folly] Apply `clang-format` to `folly/gen/` (partial: namespace). With some manual rearrangement in the places where `clang-format` does awkward things, with the result that clang-format over `folly/gen/` becomes a no-op. Reviewed By: Orvid Differential Revision: D5177428 fbshipit-source-id: 17f51d00454a7be7f29dcf1a2ff3d0eaf1de72ab
-
- 02 Jun, 2017 4 commits
-
-
Yedidya Feldblum authored
Summary: [Folly] Apply `clang-format` to `folly/portability/`. With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/portability/` becomes a no-op. Reviewed By: igorsugak Differential Revision: D5170107 fbshipit-source-id: ceadd96740b4877cbae947846f0e738e6aaf5ed1
-
Qi Wang authored
Summary: Using extent_hooks mallctl to update hooks. Reviewed By: jasone Differential Revision: D5174623 fbshipit-source-id: 9313ee9ae55c85d973736077727e54a5825f4c3d
-
Maged Michael authored
Hazard pointers: Optimize memory order, add bulk reclamation control, add stats, add implementation switches, add benchmarks. Summary: Make the implementation partially performant by optimizing memory order and using asymmetric memory barrier for full fences. Also added more control for bulk reclamation implementation, stats, and quality of implementation switches. Reviewed By: djwatson Differential Revision: D5129614 fbshipit-source-id: c597edf711fdc8f16f80523bd8cae42c51fbe140
-
Qi Wang authored
Summary: jemalloc 5.0 comes replaced chunks with extents APIs. Make the API compatible with both jemalloc 4 and 5. Reviewed By: yfeldblum Differential Revision: D5170925 fbshipit-source-id: ce25723975729b0b63371f89a96842a1b2e3b3cc
-
- 01 Jun, 2017 6 commits
-
-
Christopher Dykes authored
Summary: It is nothing but a file with the license header in it and has been since it was introduced nearly 4 years ago. Reviewed By: yfeldblum Differential Revision: D5163176 fbshipit-source-id: f510411cbb3d9d4c90d68c9b8d1f04d9f97fcb89
-
Tom Jackson authored
Reviewed By: yfeldblum Differential Revision: D5105818 fbshipit-source-id: e3926a0c70a68855e0180bdd44cb0ec76e66bb94
-
Phil Willoughby authored
Summary: Add a few keywords people search for when looking for this that won't otherwise find this file. Add a reference to the usage notes for Singleton which are a good description of how you should operate SingletoThreadLocal as well. Reviewed By: nbronson Differential Revision: D5094598 fbshipit-source-id: 9980850805e1564e5c394af713e2fa17fe8844fe
-
Tom Jackson authored
Summary: Test output before the fix is applied: ``` folly/experimental/Bits.h:247:59: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int' #0 folly/experimental/Bits.h:247 folly::Bits<...>::set(int*, unsigned long, unsigned long, int) #1 folly/experimental/test/BitsTest.cpp:228 std::enable_if<...>::type (anonymous namespace)::testSet<...>(unsigned char*, unsigned long, unsigned long, int) #2 folly/experimental/test/BitsTest.cpp:263 Bits_Boundaries_Test::TestBody() #17 folly/experimental/test/BitsTest.cpp:381 main ``` Reviewed By: philippv Differential Revision: D5160789 fbshipit-source-id: 43f1926d58f1a5c019d4f8794d10a7a80a5c4749
-
Christopher Dykes authored
Summary: All functions in this file are defined in `folly/fibers/FiberManager-inl.h`. There are no remaining references to this file. Reviewed By: yfeldblum Differential Revision: D5163160 fbshipit-source-id: 2fcb782a4de78f5c067610c876d0cf98f3b69e63
-
Yedidya Feldblum authored
Summary: Code may pass a callback which captures an object with a destructor which mutates through a stored reference, triggering heap-use-after-free or stack-use-after-scope. ```lang=c++ void performDataRace() { auto number = std::make_unique<int>(0); auto guard = folly::makeGuard([&number] { *number = 1; }); folly::via(getSomeExecutor(), [guard = std::move(guard)]() mutable {}).wait(); // data race - we may wake and destruct number before guard is destructed on the // executor thread, which is both stack-use-after-scope and heap-use-after-free! } ``` We can avoid this condition by always destructing the provided functor before setting any result on the promise. Retry at {D4982969}. Reviewed By: andriigrynenko Differential Revision: D5058750 fbshipit-source-id: 4d1d878b4889e5e6474941187f03de5fa84d3061
-
- 31 May, 2017 4 commits
-
-
Christopher Dykes authored
Summary: The dirty hack I was using to link `folly_base` into `folly` doesn't work in newer versions of CMake :( This refactors the makefile to not need to dirty hack by using an object library rule instead. It also makes the compiler version detection more generic. Reviewed By: yfeldblum Differential Revision: D5158919 fbshipit-source-id: cd052a5f58ed3d88c377c68cca07ca8497ca0c7a
-
Sven Over authored
Summary: Callables that are passed as rvalues to makeFutureWith should be executed as rvalues. Generally callables that get captured by value should be executed as rvalues, to allow passing e.g. folly::Partial objects that contain move-only objects like unique_ptr or folly::Promise. `collect` would move out of parameters passed as lvalues. Reviewed By: fugalh Differential Revision: D5120420 fbshipit-source-id: 1633c6b7e3fbb562f4d31e21d28c98b053de9912
-
Jon Maltiel Swenson authored
Summary: In mcrouter code, we would like a non-throwing alternative to `decodeVarint()`. There are real, expected scenarios where only part of a serialized varint fits into a packet, in which case mcrouter fails to decode the varint and throws. In these scenarios, throwing too many exceptions can lead to lock contention and degrade performance. Reviewed By: yfeldblum Differential Revision: D5153823 fbshipit-source-id: 138273af832903f0b04bee0bcacddd66b4274129
-
Bi Xue authored
Summary: Add `equals` interface to StringPiece (Range class). To support following case insensitive compare case: ``` folly::StringPiece a("hello"); if (a.equals("HELLO", folly::AsciiCaseInsensitive())) { // Do something. } ``` Reviewed By: ot Differential Revision: D5150495 fbshipit-source-id: 26816820f93959678f550768396f55293b5588cb
-
- 28 May, 2017 4 commits
-
-
Qinfan Wu authored
Summary: [Folly] Fix `tryTo` to support conversion to enumerations. `tryTo` should return `Expected<Tgt, ConversionCode>` instead of `Tgt`. Reviewed By: yfeldblum Differential Revision: D5144706 fbshipit-source-id: cd23f3cf75de7c5a26bc569f3cb47fff360f6e2a
-
Yiding Jia authored
Summary: `#include` inside a namespace is disallowed when using clang modules. Here I just unconditionally include them at top level, since they are available in all the relevant platforms. Reviewed By: yfeldblum, Orvid Differential Revision: D5140355 fbshipit-source-id: bb87225c1d8f4ac64b90a7aff5f912c13e150e3a
-
Maxim Georgiev authored
Summary: allow-large-files Moving DestructorCheck from proxygen library to folly. Reviewed By: djwatson Differential Revision: D5110897 fbshipit-source-id: 02a6cf6336000e8c36484e75d2da820588baf2df
-
Christopher Dykes authored
Summary: This has always been the design rule for what belongs in `folly/portability/`, but was never written down anywhere except in my head, so put it somewhere people can actually find it so I can free that space in my head for other things. Reviewed By: yfeldblum Differential Revision: D5140587 fbshipit-source-id: 1f09c17b7ccfff780e1825670a7ffaa75cd1b1d5
-