1. 02 3月, 2016 1 次提交
  2. 29 2月, 2016 1 次提交
  3. 26 2月, 2016 3 次提交
    • A
      BITFIELD: Fix #<index> form parsing. · 11745e09
      antirez 提交于
      11745e09
    • A
      BITFIELD: Support #<index> offsets form. · 2800d090
      antirez 提交于
      2800d090
    • A
      BITFIELD command initial implementation. · 70af626d
      antirez 提交于
      The new bitfield command is an extension to the Redis bit operations,
      where not just single bit operations are performed, but the array of
      bits composing a string, can be addressed at random, not aligned
      offsets, with any width unsigned and signed integers like u8, s5, u10
      (up to 64 bit signed integers and 63 bit unsigned integers).
      
      The BITFIELD command supports subcommands that can SET, GET, or INCRBY
      those arbitrary bit counters, with multiple overflow semantics.
      
      Trivial and credits:
      
      A similar command was imagined a few times in the past, but for
      some reason looked a bit far fetched or not well specified.
      Finally the command was proposed again in a clear form by
      Yoav Steinberg from Redis Labs, that proposed a set of commands on
      arbitrary sized integers stored at bit offsets.
      
      Starting from this proposal I wrote an initial specification of a single
      command with sub-commands similar to what Yoav envisioned, using short
      names for types definitions, and adding control on the overflow.
      
      This commit is the resulting implementation.
      
      Examples:
      
          BITFIELD mykey OVERFLOW wrap INCRBY i2 10 -1 GET i2 10
      70af626d
  4. 27 7月, 2015 2 次提交
  5. 26 7月, 2015 3 次提交
  6. 11 12月, 2014 1 次提交
    • M
      Bitops: Stop overallocating storage space on set · badf0f00
      Matt Stancliff 提交于
      Previously the string was created empty then re-sized
      to fit the offset, but sds resize causes the sds to
      over-allocate by at least 1 MB (which is a lot when
      you are operating at bit-level access).
      
      This also improves the speed of initial sets by 2% to 6%
      based on quick testing.
      
      Patch logic provided by @oranagra
      
      Fixes #1918
      badf0f00
  7. 03 12月, 2014 1 次提交
  8. 02 12月, 2014 1 次提交
  9. 13 8月, 2014 1 次提交
  10. 31 3月, 2014 1 次提交
    • A
      String value unsharing refactored into proper function. · 543ede03
      antirez 提交于
      All the Redis functions that need to modify the string value of a key in
      a destructive way (APPEND, SETBIT, SETRANGE, ...) require to make the
      object unshared (if refcount > 1) and encoded in raw format (if encoding
      is not already REDIS_ENCODING_RAW).
      
      This was cut & pasted many times in multiple places of the code. This
      commit puts the small logic needed into a function called
      dbUnshareStringValue().
      543ede03
  11. 27 2月, 2014 4 次提交
    • A
      warnigns -> warnings in redisBitpos(). · 76a6e82d
      antirez 提交于
      76a6e82d
    • A
      More consistent BITPOS behavior with bit=0 and ranges. · 0e31eaa2
      antirez 提交于
      With the new behavior it is possible to specify just the start in the
      range (the end will be assumed to be the first byte), or it is possible
      to specify both start and end.
      
      This is useful to change the behavior of the command when looking for
      zeros inside a string.
      
      1) If the user specifies both start and end, and no 0 is found inside
         the range, the command returns -1.
      
      2) If instead no range is specified, or just the start is given, even
         if in the actual string no 0 bit is found, the command returns the
         first bit on the right after the end of the string.
      
      So for example if the string stored at key foo is "\xff\xff":
      
          BITPOS foo (returns 16)
          BITPOS foo 0 -1 (returns -1)
          BITPOS foo 0 (returns 16)
      
      The idea is that when no end is given the user is just looking for the
      first bit that is zero and can be set to 1 with SETBIT, as it is
      "available". Instead when a specific range is given, we just look for a
      zero within the boundaries of the range.
      0e31eaa2
    • A
      Initial implementation of BITPOS. · 38c620b3
      antirez 提交于
      It appears to work but more stress testing, and both unit tests and
      fuzzy testing, is needed in order to ensure the implementation is sane.
      38c620b3
    • A
      Fix misaligned word access in redisPopcount(). · 746ce35f
      antirez 提交于
      746ce35f
  12. 22 7月, 2013 1 次提交
    • A
      Introduction of a new string encoding: EMBSTR · 894eba07
      antirez 提交于
      Previously two string encodings were used for string objects:
      
      1) REDIS_ENCODING_RAW: a string object with obj->ptr pointing to an sds
      stirng.
      
      2) REDIS_ENCODING_INT: a string object where the obj->ptr void pointer
      is casted to a long.
      
      This commit introduces a experimental new encoding called
      REDIS_ENCODING_EMBSTR that implements an object represented by an sds
      string that is not modifiable but allocated in the same memory chunk as
      the robj structure itself.
      
      The chunk looks like the following:
      
      +--------------+-----------+------------+--------+----+
      | robj data... | robj->ptr | sds header | string | \0 |
      +--------------+-----+-----+------------+--------+----+
                           |                       ^
                           +-----------------------+
      
      The robj->ptr points to the contiguous sds string data, so the object
      can be manipulated with the same functions used to manipulate plan
      string objects, however we need just on malloc and one free in order to
      allocate or release this kind of objects. Moreover it has better cache
      locality.
      
      This new allocation strategy should benefit both the memory usage and
      the performances. A performance gain between 60 and 70% was observed
      during micro-benchmarks, however there is more work to do to evaluate
      the performance impact and the memory usage behavior.
      894eba07
  13. 26 6月, 2013 1 次提交
  14. 17 5月, 2013 1 次提交
  15. 08 5月, 2013 1 次提交
    • A
      Revert "use long long instead of size_t make it more safe" · 0ae1b5b0
      antirez 提交于
      This reverts commit 2c75f2cf.
      
      After further analysis, it is very unlikely that we'll raise the
      string size limit to > 512MB, and at the same time such big strings
      will be used in 32 bit systems.
      
      Better to revert to size_t so that 32 bit processors will not be
      forced to use a 64 bit counter in normal operations, that is currently
      completely useless.
      0ae1b5b0
  16. 07 5月, 2013 2 次提交
  17. 28 1月, 2013 2 次提交
  18. 19 1月, 2013 1 次提交
  19. 09 11月, 2012 1 次提交
  20. 05 9月, 2012 1 次提交
    • H
      BITCOUNT: fix segmentation fault. · 749aac72
      Haruto Otake 提交于
      remove unsafe and unnecessary cast.
      until now, this cast may lead segmentation fault when end > UINT_MAX
      
      setbit foo 0 1
      bitcount  0 4294967295
      => ok
      bitcount  0 4294967296
      => cause segmentation fault.
      
      Note by @antirez: the commit was modified a bit to also change the
      string length type to long, since it's guaranteed to be at max 512 MB in
      size, so we can work with the same type across all the code path.
      
      A regression test was also added.
      749aac72
  21. 18 7月, 2012 1 次提交
    • A
      Don't assume that "char" is signed. · b62bdf1c
      antirez 提交于
      For the C standard char can be either signed or unsigned, it's up to the
      compiler, but Redis assumed that it was signed in a few places.
      
      The practical effect of this patch is that now Redis 2.6 will run
      correctly in every system where char is unsigned, notably the RaspBerry
      PI and other ARM systems with GCC.
      
      Thanks to Georgi Marinov (@eesn on twitter) that reported the problem
      and allowed me to use his RaspBerry via SSH to trace and fix the issue!
      b62bdf1c
  22. 01 6月, 2012 1 次提交
    • A
      BITOP bug when called against non existing keys fixed. · 1419406e
      antirez 提交于
      In the issue #529 an user reported a bug that can be triggered with the
      following code:
      
      flushdb
      set a
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      bitop or x a b
      
      The bug was introduced with the speed optimization in commit 8bbc0768
      that specializes every BITOP operation loop up to the minimum length of
      the input strings.
      
      However the computation of the minimum length contained an error when a
      non existing key was present in the input, after a key that was non zero
      length.
      
      This commit fixes the bug and adds a regression test for it.
      1419406e
  23. 24 5月, 2012 7 次提交
    • A
      BITOP command 10x speed improvement. · d8668038
      antirez 提交于
      This commit adds a fast-path to the BITOP that can be used for all the
      bytes from 0 to the minimal length of the string, and if there are
      at max 16 input keys.
      
      Often the intersected bitmaps are roughly the same size, so this
      optimization can provide a 10x speed boost to most real world usages
      of the command.
      
      Bytes are processed four full words at a time, in loops specialized
      for the specific BITOP sub-command, without the need to check for
      length issues with the inputs (since we run this algorithm only as far
      as there is data from all the keys at the same time).
      
      The remaining part of the string is intersected in the usual way using
      the slow but generic algorith.
      
      It is possible to do better than this with inputs that are not roughly
      the same size, sorting the input keys by length, by initializing the
      result string in a smarter way, and noticing that the final part of the
      output string composed of only data from the longest string does not
      need any proecessing since AND, OR and XOR against an empty string does
      not alter the output (zero in the first case, and the original string in
      the other two cases).
      
      More implementations will be implemented later likely, but this should
      be enough to release Redis 2.6-RC4 with bitops merged in.
      
      Note: this commit also adds better testing for BITOP NOT command, that
      is currently the faster and hard to optimize further since it just
      flips the bits of a single input string.
      d8668038
    • A
      BITOP: handle integer encoded objects correctly. · fa4a5d59
      antirez 提交于
      A bug in the implementation caused BITOP to crash the server if at least
      one one of the source objects was integer encoded.
      
      The new implementation takes an additional array of Redis objects
      pointers and calls getDecodedObject() to get a reference to a string
      encoded object, and then uses decrRefCount() to release the object.
      
      Tests modified to cover the regression and improve coverage.
      fa4a5d59
    • A
      BITCOUNT performance improved. · 7c34643f
      antirez 提交于
      At Redis's default optimization level the command is now much faster,
      always using a constant-time bit manipualtion technique to count bits
      instead of GCC builtin popcount, and unrolling the loop.
      
      The current implementation performance is 1.5GB/s in a MBA 11" (1.8 Ghz
      i7) compiled with both GCC and clang.
      
      The algorithm used is described here:
      
      http://graphics.stanford.edu/~seander/bithacks.html
      7c34643f
    • A
      bitop.c renamed bitops.c · 80f8028e
      antirez 提交于
      bitop.c contains the "Bit related string operations" so it seems more
      logical to call it bitops instead of bitop.
      This also makes it matching the name of the test (unit/bitops.tcl).
      80f8028e
    • A
      popcount() optimization for speed. · 343d3bd2
      antirez 提交于
      We run the array by 32 bit words instead of processing it byte per byte.
      If the code is compiled using GCC __builtin_popcount() builtin function
      is used instead.
      343d3bd2
    • A
      BITCOUNT refactoring. · dbbbe49e
      antirez 提交于
      The low level popualtion counting function is now separated from the
      BITCOUNT command implementation, so that the low level function can be
      further optimized and eventually used in other contexts if needed.
      dbbbe49e
    • A
      Bit-related string operations moved to bitop.c · 760e7765
      antirez 提交于
      All the general string operations are implemented in t_string.c, however
      the bit operations, while targeting the string type, are better served
      in a specific file where we have the implementations of the following
      four commands and helper functions:
      
          GETBIT
          SETBIT
          BITOP
          BITCOUNT
      
      In the future this file will probably contain more code related to
      making the BITOP and BITCOUNT operations faster.
      760e7765