1. 02 Jul, 2016 1 commit
    • Aravind Anbudurai's avatar
      Moved object destructor should not log · 3df144be
      Aravind Anbudurai authored
      Summary:
      I introduced a helper method to make an AutoTimer and forced default move-ctor.
      That caused moved object's destruction to log and that is undesirable.
      This defines a custom move-ctor to set a direct the moved object to not log.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3511206
      
      fbshipit-source-id: 38ae6de5fe76077c5e5ed10f64ebe959f5674fa7
      3df144be
  2. 01 Jul, 2016 16 commits
    • Adam Simpkins's avatar
      fix the ThreadLocal test in open source builds · df7b6d2a
      Adam Simpkins authored
      Summary:
      The ThreadLocalTest has been broken in open source builds ever since D2678401,
      because Makefile.am was never updated to build the helper shared library needed
      by the test.
      
      This updates Makefile.am to build the shared library.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3511125
      
      fbshipit-source-id: 4684dbc32acf6ffbfc07079da91a1da480259502
      df7b6d2a
    • Aravind Anbudurai's avatar
      Make AutoTimer work with std::chrono::duration instead of seconds with type double · 0b14cc4f
      Aravind Anbudurai authored
      Summary:
      Currently, AutoTimer outputs duration as a double with seconds as units.
      This is limiting and I'm making it return std::chrono::duration. Users can specify the type with DurationType.
      
      This is needed for me because the library that I am going to use inside the callback I pass in using chrono::duration and it feels hacky to go from duration -> double -> duration.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506557
      
      fbshipit-source-id: 0a5e9e16181bfac3a10df6a253716c0499cff5df
      0b14cc4f
    • Christopher Dykes's avatar
      ConstantRNG should implement UniformRandomBitGenerator · ca33aa31
      Christopher Dykes authored
      Summary: As per http://en.cppreference.com/w/cpp/concept/UniformRandomBitGenerator it was almost there, except that `min()` and `max()` need to be static members.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3507595
      
      fbshipit-source-id: 5e0b321c477e37ab8a3487ad643caa83cc6cfc9d
      ca33aa31
    • Aravind Anbudurai's avatar
      clang-format AutoTimer.h · 1c1a6b45
      Aravind Anbudurai authored
      Summary:
      Somehow the formatting is messed up and it was triggering my OCD.
      Sending a diff before I go crazy
      
      Depends on D3506557
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506618
      
      fbshipit-source-id: 218ce2100cc45c5017328e97344029061fe2eff5
      1c1a6b45
    • Christopher Dykes's avatar
      Don't use named variadic macro parameters · 1880e851
      Christopher Dykes authored
      Summary: MSVC doesn't support them, so use `__VA_ARGS__` instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3507071
      
      fbshipit-source-id: 186834c87e74257c709fcbc08e3bda7b1b55d02b
      1880e851
    • Christopher Dykes's avatar
      Use asm_volatile_memory() for portable memory barriors in LifoSemTests · b9d8fba1
      Christopher Dykes authored
      Summary: The portability headers exist for a reason, so use them.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3507031
      
      fbshipit-source-id: f88c8ed37e648d38231c1d923c1d69d551beabff
      b9d8fba1
    • Christopher Dykes's avatar
      Use UTF-8 strings for strings with multi-byte Unicode code points in them · 309ac912
      Christopher Dykes authored
      Summary: Because MSVC doesn't support strings with multi-byte Unicode code points in them unless it's in a UTF-8 string.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3507197
      
      fbshipit-source-id: 27bff1efee03180716418fbfa9ef98f9c04929d9
      309ac912
    • Christopher Dykes's avatar
      Use decltype rather than typeof · 5f78f71a
      Christopher Dykes authored
      Summary: Because `typeof` is a GCC specific extension whose standardized version is called `decltype`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506960
      
      fbshipit-source-id: 0e7495028632b23f149bf8d0163d2000ebec2fcc
      5f78f71a
    • Christopher Dykes's avatar
      Rename SIZE to kSize · ef12daa2
      Christopher Dykes authored
      Summary: Because `SIZE` is a defined type on Windows.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3507144
      
      fbshipit-source-id: ee9fd9bb7c35055ca69719717aa10d8e9c8701c2
      ef12daa2
    • Christopher Dykes's avatar
      Use uint32_t rather than uint · 7a0de7ae
      Christopher Dykes authored
      Summary: Because `uint32_t` is standardized, and MSVC doesn't have `uint`.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3507011
      
      fbshipit-source-id: ac0abb4ad1b2dbaa890554589817ce75abdd987e
      7a0de7ae
    • Christopher Dykes's avatar
      Use std::vector in the CacheLocalityBenchmark rather than a VLA · 61a96501
      Christopher Dykes authored
      Summary: Because MSVC doesn't support VLAs.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506835
      
      fbshipit-source-id: 8683b5c513ed25e7f47642c8493f8b10da9906be
      61a96501
    • Christopher Dykes's avatar
      Use float literals when initializing float values · 48832457
      Christopher Dykes authored
      Summary: MSVC was correctly warning that we were initializing `float` variables with `double` literals. This just adds the explicit suffix so they are `float` literals instead.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506797
      
      fbshipit-source-id: 7eb4588958eddb984ba830e2599ac505d495783e
      48832457
    • Christopher Dykes's avatar
      Long is not long enough for a long long · 389ce43b
      Christopher Dykes authored
      Summary: Thus `1UL << 63 == 0` which is not the intended behavior.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3478480
      
      fbshipit-source-id: a31dba7f5a503be2b34a4cb66bc7039076f158a0
      389ce43b
    • Christopher Dykes's avatar
      Don't try and instantiate an invalid function in DiscriminatedPtrDetail · 788ab800
      Christopher Dykes authored
      Summary:
      THe issue is quite simple: Regardless of the control flow, the previous implementation of this was instantiating `ApplyVisitor1<V,R>` which declares a return type, but never returns.
      This refactors `ApplyVisitor1` and `ApplyConstVisitor1` so that the part of the control flow that was previously never reached simply doesn't exist anymore.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479584
      
      fbshipit-source-id: 605a48e39bba6dc14df1af1e76b55ea60f3e69d5
      788ab800
    • Christopher Dykes's avatar
      Don't use stderr as an identifier name · b0883076
      Christopher Dykes authored
      Summary: Because it is defined as a macro that calls a function to get the error stream. It is also defined as a macro in musl libc.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3506283
      
      fbshipit-source-id: 0652288adfe64010798017e46d962fdc18d2ff56
      b0883076
    • Misha Shneerson's avatar
      stop_watch is moved to folly · 8382636d
      Misha Shneerson authored
      Summary:
      moved stop_watch to folly
      defined aliases for backward compact. These alias will be removed in next diff.
      
      Reviewed By: juchem
      
      Differential Revision: D3474035
      
      fbshipit-source-id: 74ee8bb7f2db46434c937eecf121d1cba473178a
      8382636d
  3. 30 Jun, 2016 3 commits
    • Tianjiao Yin's avatar
      suppress unused variable warnings · ee542790
      Tianjiao Yin authored
      Reviewed By: yfeldblum
      
      Differential Revision: D3501266
      
      fbshipit-source-id: 2ac3b6e2785792ccc45f4568ceff7fd05f0262f3
      ee542790
    • Aravind Anbudurai's avatar
      Make AutoTimer usable with Closures · 3f09eed1
      Aravind Anbudurai authored
      Summary:
      Currently, AutoTimer works only with FunctionObjects that are default constructible because it constructs Logger each time it needs to log. This diff makes AutoTimer work with closures too. This will help in making AutoTimer more flexible because the user can capture necessary dependencies in the lambda.
      
      This diff also cleans up the constructors on AutoTimer by making it take an
      std::string&& instead of Args... that is passed into folly::to<..>. Although
      this makes the instantiation a bit harder, the simplicity of constructor seems
      worth it.
      
      This also refactors the callsites of setMinLogTime to directly pass the
      value into the ctor and changes callsites on fbcode
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3487868
      
      fbshipit-source-id: 52fa1099a5e39b791972cc0d3f678d44ea4ba288
      3f09eed1
    • Scott Michelson's avatar
      Give each eventbase a wheeltimer · 75e5507c
      Scott Michelson authored
      Summary:
      This gives each eventbase a wheeltimer. Construction is on demand, so there's no penalty if it isn't used. Why do this? 3 immediate reasons:
      
      1) some clients already do this outside of the interface: diffusion/FBS/browse/master/fbcode/servicerouter/client/common/ThriftDispatcher.h$302,607?view=highlighted
      2) inefficient timers can be easily avoided: diffusion/FBS/browse/master/fbcode/thrift/lib/cpp2/async/HeaderClientChannel.h;64fb260ea4bd235ba79414a78002fd68cf0453a8$319
      3) D2379210 indicates we can do a better job with this than cob timeout
      
      Reviewed By: andriigrynenko, djwatson
      
      Differential Revision: D3460792
      
      fbshipit-source-id: a7bb6fdd90ca95b6aef8af952d7a66dd0dc260c1
      75e5507c
  4. 29 Jun, 2016 4 commits
    • Eric Niebler's avatar
      gcc-4.8 is not decaying types correctly in lambda init captures. Help it out.... · e6aa2684
      Eric Niebler authored
      gcc-4.8 is not decaying types correctly in lambda init captures. Help it out. Fixes open source build.
      
      Summary: Trivial change gets folly::ThreadLocal building again with gcc-4.8, needed by the Open Source build.
      
      Reviewed By: chadparry, yfeldblum
      
      Differential Revision: D3498657
      
      fbshipit-source-id: cf36f2bef7f1d03d133d16bfd063f7a2ce681822
      e6aa2684
    • Mirek Klimos's avatar
      Fix FiberManager.RequestContext unit test · 235fb4c0
      Mirek Klimos authored
      Summary: with the added blocks, pointer to RequestContext needs to be captured by value, not reference
      
      Differential Revision: D3499921
      
      fbshipit-source-id: 76ff22869228fbdd7ef1651cd2814550f6abc301
      235fb4c0
    • Eric Niebler's avatar
      fix the open source ssl_test target · f285646c
      Eric Niebler authored
      Summary: 'make check' is failing since the path to OpenSSLHashTest.cpp is wrong and because ssl_test is not linked to libcrypto.
      
      Reviewed By: mhx
      
      Differential Revision: D3498207
      
      fbshipit-source-id: 0f443d1f1b76c537d211dc148df0cd3fdfb8eead
      f285646c
    • Mirek Klimos's avatar
      Replace RequestContext::create with RequestContextScopeGuard in tests · a18f2c01
      Mirek Klimos authored
      Summary: RequestContextScopeGuard should be preferred to RequestContext::create because it makes sure that RequestContext is cleared afterwards - need to create more examples of this in the codebase, migrating unit tests should be safe
      
      Reviewed By: interwq
      
      Differential Revision: D3489969
      
      fbshipit-source-id: 202fec93116db3d435c108fafecad26a4ed9b603
      a18f2c01
  5. 27 Jun, 2016 2 commits
    • Marcus Holland-Moritz's avatar
      Allow unchecked conversion from floating point to bool · 12c01784
      Marcus Holland-Moritz authored
      Summary:
      In order to be consistent with integral-to-bool conversion, this
      change allows conversion from floating point values to bool following
      the same rule that is to be consistent with C(++) conventions. Also,
      any arithmetic value can be converted to bool without potential for
      undefined behaviour, so no extra checks are required.
      
      Differential Revision: D3483760
      
      fbshipit-source-id: 024b58d348ef679079aba4d9d5277acb46aba2a1
      12c01784
    • Bo You's avatar
      Folly parseJson doesn't handle minInt properly · 6dbd5d06
      Bo You authored
      Summary:
      Right now in ##parseNumber## in ##folly/json.cpp##, when a negative number is provided, both the minus sign and the digits are stored in the variable ##integral##: https://fburl.com/362938516.
      
      This causes problem when the exact min int is provided (-9223372036854775808). Because now ##integral.size()## equals 20 (including the minus sign), which is greater than ##maxIntLen## (which is 19). We need to handle negatives separately to get the correct result.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479054
      
      fbshipit-source-id: 15c782962a5f5ee845a2a18f2145c7695ec2d546
      6dbd5d06
  6. 26 Jun, 2016 1 commit
    • David Lam's avatar
      fix typo in dynamic.md documentation · 1ce31b9a
      David Lam authored
      Summary: #accept2ship
      
      Reviewed By: Orvid
      
      Differential Revision: D3486732
      
      fbshipit-source-id: 45bfe1daa1dbd1e427fcd18e71e6b9eeb6d6b2b7
      1ce31b9a
  7. 25 Jun, 2016 1 commit
    • Eric Niebler's avatar
      folly: fix clang's -Wundefined-var-template · 6c76acfc
      Eric Niebler authored
      Summary:
      [temp] (14)/6:
      
      > A function template, member function of a class template, variable template, or static data member of a class template shall be defined in every translation unit in which it is implicitly instantiated (14.7.1) unless the corresponding specialization is explicitly instantiated (14.7.2) in some translation unit; no diagnostic is required.
      
      `-Wundefined-var-template` warns on any implicit instantiations that are needed but could not be performed because the definition is not available. In particular, for valid code, this warns on templates/temploids which have their definition and all relevant explicit instantiations tucked away in some source file (but for which no explicit instantiation declarations are provided in the relevant header file) - used a few times in folly. This seems a bad style, the static data member template should either be defined in the header file or should be explicitly instantiated in each .cpp file.
      
      Reviewed By: igorsugak
      
      Differential Revision: D3447679
      
      fbshipit-source-id: 22c90c19e2c7a9b6d772058f2c7e350b890b6c0a
      6c76acfc
  8. 24 Jun, 2016 11 commits
    • Haocheng Zhang's avatar
      fix bug for negative shift value · 7815372b
      Haocheng Zhang authored
      Reviewed By: luciang
      
      Differential Revision: D3407128
      
      fbshipit-source-id: 2c00387d6e068f9e052f539198ae2f985d265c74
      7815372b
    • Marcus Holland-Moritz's avatar
      Fix uses of std::nextafter on Android · d27a9dba
      Marcus Holland-Moritz authored
      Summary:
      On Android, std::nextafter isn't implemented. However, the C functions and
      compiler builtins are still provided.
      
      This change adds a portability abstraction as folly::nextafter.
      
      Reviewed By: mzlee, yfeldblum
      
      Differential Revision: D3478081
      
      fbshipit-source-id: 54fec1ca8bdec24ba45d51e07020259fdbae61b4
      d27a9dba
    • Huapeng Zhou's avatar
      IOBuf: add a method to signal the underlying buffer as externally shared · 523ca0ed
      Huapeng Zhou authored
      Summary:
      There are use cases where 1). the underlying buffer is externally managed (e.g. by a slab allocator) and 2). we need to do bookkeeping when the wrapped IOBuf gets destroyed (e.g. reference counting). This diff adds a another method to mark the underlying buffer as shared with the external memory management mechanism.
      
      The `takeOwnership` doesn't meet the criteria since it assumes the ownership of the buffer, while in this case we need to signal it as externally managed so that hopefully callers won't try to modify the underlying buffer.
      
      Reviewed By: simpkins
      
      Differential Revision: D2662954
      
      fbshipit-source-id: e908c3ebeeefe9a5d332c75070f377fb1dad5acb
      523ca0ed
    • Christopher Dykes's avatar
      std::aligned_storage<>::type is not a dependent type · 996d59be
      Christopher Dykes authored
      Summary: Which causes MSVC to get grumpy when you tell it that it is.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479016
      
      fbshipit-source-id: e674b210aaa5a644c5ed884a7077a5cf33b05196
      996d59be
    • Christopher Dykes's avatar
      Use FOLLY_TLS rather than __thread · acac120e
      Christopher Dykes authored
      Summary: We define `FOLLY_TLS` for a reason, so use it.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3479880
      
      fbshipit-source-id: 2aa11c2900cdb012cf96d4f084fe81a0428f53d3
      acac120e
    • Christopher Dykes's avatar
      Dear Elias Fano Bit Vector: You do not require GCC · 73e35f02
      Christopher Dykes authored
      Summary: There is nothing directly in these that requires GCC.
      
      Reviewed By: pixelb
      
      Differential Revision: D3479392
      
      fbshipit-source-id: 6b5ae0115cad666f29db6c7b123b9d1a1013e3b0
      73e35f02
    • Marcus Holland-Moritz's avatar
      Fix code for anything-to-string space estimation · 0cc632cd
      Marcus Holland-Moritz authored
      Summary:
      When looking at the benchmark for 64-bit integer-to-string conversion,
      I noticed something strange:
      
        ===================================================
        folly/test/ConvBenchmark.cpp              time/iter
        ===================================================
        u64ToStringFollyMeasure(12)                 26.59ns
        u64ToStringFollyMeasure(13)                 26.89ns
        u64ToStringFollyMeasure(14)                 28.26ns  <---
        u64ToStringFollyMeasure(15)                 52.06ns  <---
        u64ToStringFollyMeasure(16)                 54.44ns
        u64ToStringFollyMeasure(17)                 55.96ns
        ===================================================
      
      There was a sudden, unexpected jump in latency going from 14 digits to
      15 digits. Profiling showed that this was due to malloc() and free()
      calls for the 15 digit benchmark that didn't occur when converting
      only 14 digit numbers. This was surprising, knowing that fbstrings
      should be able to store up to 23 digits inline.
      
      Even though the code to estimate the number of digits is correct, the
      code to estimate the space needed within the string was off by 9 bytes.
      
      The reason for that is that reserveInTarget() and reserveInTargetDelim()
      are called with the target string as the last parameter. However, the
      parameter processing in estimateSpaceToReserve() didn't consider this,
      and so reserved space for the size of the pointer + 1, which explains
      the wrap at 15 digits.
      
      The fix is to make all overloads of estimateSpaceToReserve() consider
      the target parameter correctly.
      
      The benchmark shows there's no jump in latency with the fix:
      
        ==============================================================
        folly/test/ConvBenchmark.cpp             time/iter   time/iter
        ==============================================================
        preallocateTestNoFloat                    590.12ns    599.20ns
        preallocateTestFloat                      580.25ns    581.72ns
        preallocateTestInt8                       116.27ns    119.08ns
        preallocateTestInt16                      130.03ns    131.89ns
        preallocateTestInt32                      156.24ns    154.91ns
        preallocateTestInt64                      210.66ns    207.04ns
        preallocateTestInt128                       4.56us      4.54us
        preallocateTestNoFloatWithInt128            4.27us      4.26us
        --------------------------------------------------------------
        u64ToStringFollyMeasure(1)                 15.49ns     15.19ns
        u64ToStringFollyMeasure(2)                 16.10ns     15.80ns
        u64ToStringFollyMeasure(3)                 17.32ns     17.01ns
        u64ToStringFollyMeasure(4)                 18.53ns     18.23ns
        u64ToStringFollyMeasure(5)                 18.84ns     18.53ns
        u64ToStringFollyMeasure(6)                 20.19ns     19.83ns
        u64ToStringFollyMeasure(7)                 21.42ns     21.11ns
        u64ToStringFollyMeasure(8)                 22.48ns     22.33ns
        u64ToStringFollyMeasure(9)                 22.94ns     22.63ns
        u64ToStringFollyMeasure(10)                24.12ns     23.82ns
        u64ToStringFollyMeasure(11)                25.53ns     25.25ns
        u64ToStringFollyMeasure(12)                26.59ns     26.36ns
        u64ToStringFollyMeasure(13)                26.89ns     26.67ns
        u64ToStringFollyMeasure(14)                28.26ns     28.01ns
        u64ToStringFollyMeasure(15)                52.06ns     29.44ns
        u64ToStringFollyMeasure(16)                54.44ns     31.05ns
        u64ToStringFollyMeasure(17)                55.96ns     34.64ns
        u64ToStringFollyMeasure(18)                57.69ns     35.10ns
        u64ToStringFollyMeasure(19)                59.45ns     36.46ns
        u64ToStringFollyMeasure(20)                60.91ns     38.17ns
        ==============================================================
      
      Reviewed By: meyering
      
      Differential Revision: D3455825
      
      fbshipit-source-id: 0146cbfc0105f0d709b64bcf1ed297c4e27d1129
      0cc632cd
    • Marcus Holland-Moritz's avatar
      Simplify unsigned-to-string conversion code and improve performance · d51ca176
      Marcus Holland-Moritz authored
      Summary:
      This seemingly trivial change has a surprisingly significant performance
      impact. It changes the call to append() on a string-like object from using
      an iterator pair to using a char* / length pair for 64-bit unsigned-to-string
      conversion. This brings it in line with code for signed-to-string conversion,
      which had already been using this overload of append.
      
        =============================================================
        folly/test/ConvBenchmark.cpp            time/iter   time/iter
        =============================================================
        preallocateTestNoFloat                   640.47ns    590.12ns
        preallocateTestFloat                     569.32ns    580.25ns
        preallocateTestInt8                      133.65ns    116.27ns
        preallocateTestInt16                     147.05ns    130.03ns
        preallocateTestInt32                     169.98ns    156.24ns
        preallocateTestInt64                     228.31ns    210.66ns
        preallocateTestInt128                      4.53us      4.56us
        preallocateTestNoFloatWithInt128           4.32us      4.27us
        -------------------------------------------------------------
        u64ToStringFollyMeasure(1)                17.32ns     15.49ns
        i64ToStringFollyMeasurePos(1)             15.80ns     15.80ns
        i64ToStringFollyMeasureNeg(1)             21.91ns     21.91ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(2)                18.23ns     16.10ns
        i64ToStringFollyMeasurePos(2)             16.71ns     16.71ns
        i64ToStringFollyMeasureNeg(2)             21.90ns     21.90ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(3)                19.44ns     17.32ns
        i64ToStringFollyMeasurePos(3)             17.01ns     17.01ns
        i64ToStringFollyMeasureNeg(3)             21.96ns     21.96ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(4)                20.35ns     18.53ns
        i64ToStringFollyMeasurePos(4)             18.23ns     18.23ns
        i64ToStringFollyMeasureNeg(4)             22.19ns     22.22ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(5)                20.66ns     18.84ns
        i64ToStringFollyMeasurePos(5)             19.47ns     19.54ns
        i64ToStringFollyMeasureNeg(5)             22.66ns     22.68ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(6)                21.89ns     20.19ns
        i64ToStringFollyMeasurePos(6)             20.74ns     20.72ns
        i64ToStringFollyMeasureNeg(6)             23.81ns     23.83ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(7)                23.09ns     21.42ns
        i64ToStringFollyMeasurePos(7)             21.11ns     21.12ns
        i64ToStringFollyMeasureNeg(7)             24.92ns     24.92ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(8)                24.00ns     22.48ns
        i64ToStringFollyMeasurePos(8)             22.18ns     22.18ns
        i64ToStringFollyMeasureNeg(8)             26.20ns     26.20ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(9)                24.31ns     22.94ns
        i64ToStringFollyMeasurePos(9)             23.39ns     23.53ns
        i64ToStringFollyMeasureNeg(9)             26.44ns     26.44ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(10)               25.52ns     24.12ns
        i64ToStringFollyMeasurePos(10)            24.69ns     24.69ns
        i64ToStringFollyMeasureNeg(10)            27.77ns     27.80ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(11)               26.74ns     25.53ns
        i64ToStringFollyMeasurePos(11)            25.07ns     25.07ns
        i64ToStringFollyMeasureNeg(11)            28.87ns     28.87ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(12)               28.25ns     26.59ns
        i64ToStringFollyMeasurePos(12)            26.21ns     26.34ns
        i64ToStringFollyMeasureNeg(12)            30.08ns     30.08ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(13)               29.38ns     26.89ns
        i64ToStringFollyMeasurePos(13)            27.60ns     27.65ns
        i64ToStringFollyMeasureNeg(13)            30.62ns     30.69ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(14)               30.91ns     28.26ns
        i64ToStringFollyMeasurePos(14)            28.58ns     28.57ns
        i64ToStringFollyMeasureNeg(14)            55.27ns     55.27ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(15)               54.71ns     52.06ns
        i64ToStringFollyMeasurePos(15)            52.79ns     52.84ns
        i64ToStringFollyMeasureNeg(15)            57.45ns     57.50ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(16)               57.14ns     54.44ns
        i64ToStringFollyMeasurePos(16)            55.26ns     55.29ns
        i64ToStringFollyMeasureNeg(16)            59.18ns     59.19ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(17)               58.89ns     55.96ns
        i64ToStringFollyMeasurePos(17)            57.10ns     57.14ns
        i64ToStringFollyMeasureNeg(17)            60.89ns     60.88ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(18)               60.33ns     57.69ns
        i64ToStringFollyMeasurePos(18)            58.59ns     58.63ns
        i64ToStringFollyMeasureNeg(18)            62.46ns     62.50ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(19)               62.22ns     59.45ns
        i64ToStringFollyMeasurePos(19)            60.23ns     60.25ns
        i64ToStringFollyMeasureNeg(19)            64.21ns     64.20ns
        -------------------------------------------------------------
        u64ToStringFollyMeasure(20)               63.79ns     60.91ns
        =============================================================
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3455819
      
      fbshipit-source-id: bc57a0e5bd1d1dca22a37c8b7306e05493e6bd5f
      d51ca176
    • Marcus Holland-Moritz's avatar
      Fix undefined behaviour in 128-bit integer-to-string conversion · f97b156e
      Marcus Holland-Moritz authored
      Summary:
      The code to convert signed 128-bit integer values to strings would trigger
      undefined behaviour when trying to convert the most negative possible value,
      as exposed by the new test cases.
      
      The fix is to negate the corresponding unsigned value (just like it's already
      done for the 64-bit code).
      
      This change doesn't have any performance impact.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3455817
      
      fbshipit-source-id: 83782992324f443789760a0e61cd9b889faaf317
      f97b156e
    • Marcus Holland-Moritz's avatar
      Add more benchmarks for integer-to-string conversion · 05a4c221
      Marcus Holland-Moritz authored
      Summary:
      In preparation for some changes to the integer-to-string conversion
      code, this change adds, this adds some more benchmarks, and attempts
      to update the existing ones to be less prone to the optimizations
      where the compiler already knows about the constant values being
      passed in.
      
      There also were a couple of flaws in the existing benchmarks, where
      instead of computing the value to be converted from a start value
      and the loop counter, it rather added the (constant) total iteration
      count to the value, ending up with a constant. But, worse than just
      using a constant, the code that was trying to evaluate the cost of
      converting a single-digit would generally end up computing the cost
      of a five-digit number, which resulted in the benchmarks showing
      identical figures regardless of the number of digits for small digit
      counts.
      
      The change also adds benchmarks for positive/negative signed integers
      and 128-bit integers.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3455815
      
      fbshipit-source-id: a20821c7d460bc05453655d0c848a0c9a47520fd
      05a4c221
    • Marcus Holland-Moritz's avatar
      Fix conversion from bool to floating point value · 29c7ba51
      Marcus Holland-Moritz authored
      Summary:
      Due to the definition of how floating point values convert to boolean,
      the check for undefined behaviour wouldn't work correctly. The result
      of (1 - 0.9999999999999999) would yield 0 when converted to an integer,
      but yields true (1) when converted to a boolean.
      
      As all floating point values can thus be converted to boolean without
      triggering undefined behaviour, this change overloads checkConversion()
      appropriately
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3477368
      
      fbshipit-source-id: 5b2aeb6194629cf3a6195529aac2362c0d35799c
      29c7ba51
  9. 23 Jun, 2016 1 commit
    • Marcus Holland-Moritz's avatar
      Clean up Conv.cpp / Conv.h · 1186ac53
      Marcus Holland-Moritz authored
      Summary:
      A bit of tidying up:
      
      - Remove unused digit1 / digit2 arrays
      - Remove unused MaxString<bool>
      - Move MaxString<> entirely to Conv.cpp, as it's not used in Conv.h
      - Extend anonymous namespace in Conv.cpp
      - Sort headers in Conv.h
      
      Reviewed By: yfeldblum
      
      Differential Revision: D3433767
      
      fbshipit-source-id: 224a68f22505c0f2014ac376154d004eca1658a9
      1186ac53