1. 12 8月, 2013 4 次提交
    • A
      replicationFeedSlave() reworked for correctness and speed. · dcc48a81
      antirez 提交于
      The previous code using a static buffer as an optimization was lame:
      
      1) Premature optimization, actually it was *slower* than naive code
         because resulted into the creation / destruction of the object
         encapsulating the output buffer.
      2) The code was very hard to test, since it was needed to have specific
         tests for command lines exceeding the size of the static buffer.
      3) As a result of "2" the code was bugged as the current tests were not
         able to stress specific corner cases.
      
      It was replaced with easy to understand code that is safer and faster.
      dcc48a81
    • A
      Fix a PSYNC bug caused by a variable name typo. · aa05128f
      antirez 提交于
      aa05128f
    • A
      Fix sdsempty() prototype in sds.h. · 610224d0
      antirez 提交于
      610224d0
    • A
      Replication: better way to send a preamble before RDB payload. · 89ffba91
      antirez 提交于
      During the replication full resynchronization process, the RDB file is
      transfered from the master to the slave. However there is a short
      preamble to send, that is currently just the bulk payload length of the
      file in the usual Redis form $..length..<CR><LF>.
      
      This preamble used to be sent with a direct write call, assuming that
      there was alway room in the socket output buffer to hold the few bytes
      needed, however this does not scale in case we'll need to send more
      stuff, and is not very robust code in general.
      
      This commit introduces a more general mechanism to send a preamble up to
      2GB in size (the max length of an sds string) in a non blocking way.
      89ffba91
  2. 08 8月, 2013 2 次提交
    • A
      redis-benchmark: changes to random arguments substitution. · db862e8e
      antirez 提交于
      Before this commit redis-benchmark supported random argumetns in the
      form of :rand:000000000000. In every string of that form, the zeros were
      replaced with a random number of 12 digits at every command invocation.
      
      However this was far from perfect as did not allowed to generate simply
      random numbers as arguments, there was always the :rand: prefix.
      
      Now instead every argument in the form __rand_int__ is replaced with a
      12 digits number. Note that "__rand_int__" is 12 characters itself.
      
      In order to implement the new semantic, it was needed to change a few
      thigns in the internals of redis-benchmark, as new clients are created
      cloning old clients, so without a stable prefix such as ":rand:" the old
      way of cloning the client was no longer able to understand, from the old
      command line, what was the position of the random strings to substitute.
      
      Now instead a client structure is passed as a reference for cloning, so
      that we can directly clone the offsets inside the command line.
      db862e8e
    • A
      redis-benchmark: replace snprintf()+memcpy with faster code. · 92ab77f8
      antirez 提交于
      This change was profiler-driven, but the actual effect is hard to
      measure in real-world redis benchmark runs.
      92ab77f8
  3. 07 8月, 2013 6 次提交
  4. 06 8月, 2013 4 次提交
    • A
      Add per-db average TTL information in INFO output. · 112fa479
      antirez 提交于
      Example:
      
      db0:keys=221913,expires=221913,avg_ttl=655
      
      The algorithm uses a running average with only two samples (current and
      previous). Keys found to be expired are considered at TTL zero even if
      the actual TTL can be negative.
      
      The TTL is reported in milliseconds.
      112fa479
    • A
      activeExpireCycle(): fix about fast cycle early start. · 4befe73b
      antirez 提交于
      We don't want to repeat a fast cycle too soon, the previous code was
      broken, we need to wait two times the period *since* the start of the
      previous cycle in order to avoid there is an even space between cycles:
      
      .-> start                   .-> second start
      |                           |
      +-------------+-------------+--------------+
      | first cycle |    pause    | second cycle |
      +-------------+-------------+--------------+
      
      The second and first start must be PERIOD*2 useconds apart hence the *2
      in the new code.
      4befe73b
    • A
      Some activeExpireCycle() refactoring. · 6500fabf
      antirez 提交于
      6500fabf
    • A
      Remove dead code and fix comments for new expire code. · d398f388
      antirez 提交于
      d398f388
  5. 05 8月, 2013 2 次提交
    • A
      Darft #2 for key collection algo: more improvements. · 66a26471
      antirez 提交于
      This commit makes the fast collection cycle time configurable, at
      the same time it does not allow to run a new fast collection cycle
      for the same amount of time as the max duration of the fast
      collection cycle.
      66a26471
    • A
      Draft #1 of a new expired keys collection algorithm. · b09ea1bd
      antirez 提交于
      The main idea here is that when we are no longer to expire keys at the
      rate the are created, we can't block more in the normal expire cycle as
      this would result in too big latency spikes.
      
      For this reason the commit introduces a "fast" expire cycle that does
      not run for more than 1 millisecond but is called in the beforeSleep()
      hook of the event loop, so much more often, and with a frequency bound
      to the frequency of executed commnads.
      
      The fast expire cycle is only called when the standard expiration
      algorithm runs out of time, that is, consumed more than
      REDIS_EXPIRELOOKUPS_TIME_PERC of CPU in a given cycle without being able
      to take the number of already expired keys that are yet not collected
      to a number smaller than 25% of the number of keys.
      
      You can test this commit with different loads, but a simple way is to
      use the following:
      
      Extreme load with pipelining:
      
      redis-benchmark -r 100000000 -n 100000000  \
              -P 32 set ele:rand:000000000000 foo ex 2
      
      Remove the -P32 in order to avoid the pipelining for a more real-world
      load.
      
      In another terminal tab you can monitor the Redis behavior with:
      
      redis-cli -i 0.1 -r -1 info keyspace
      
      and
      
      redis-cli --latency-history
      
      Note: this commit will make Redis printing a lot of debug messages, it
      is not a good idea to use it in production.
      b09ea1bd
  6. 29 7月, 2013 1 次提交
  7. 28 7月, 2013 2 次提交
  8. 25 7月, 2013 2 次提交
  9. 24 7月, 2013 2 次提交
  10. 23 7月, 2013 4 次提交
  11. 22 7月, 2013 3 次提交
    • A
      Fixed a possible bug in client->reply_bytes computation. · 7ed76528
      antirez 提交于
      7ed76528
    • A
      a3169341
    • 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
  12. 17 7月, 2013 1 次提交
  13. 16 7月, 2013 3 次提交
    • A
      Fixed typo in rio.h, simgle -> single. · f590dd82
      antirez 提交于
      f590dd82
    • Y
    • A
      Make sure that ZADD can accept the full range of double values. · 9d520a7f
      antirez 提交于
      This fixes issue #1194, that contains many details.
      
      However in short, it was possible for ZADD to not accept as score values
      that was however possible to obtain with multiple calls to ZINCRBY, like
      in the following example:
      
      redis 127.0.0.1:6379> zadd k 2.5e-308 m
      (integer) 1
      redis 127.0.0.1:6379> zincrby k -2.4e-308 m
      "9.9999999999999694e-310"
      redis 127.0.0.1:6379> zscore k m
      "9.9999999999999694e-310"
      redis 127.0.0.1:6379> zadd k 9.9999999999999694e-310 m1
      (error) ERR value is not a valid float
      
      The problem was due to strtod() returning ERANGE in the following case
      specified by POSIX:
      
      "If the correct value would cause an underflow, a value whose magnitude
      is no greater than the smallest normalized positive number in the return
      type shall be returned and errno set to [ERANGE].".
      
      Now instead the returned value is accepted even when ERANGE is returned
      as long as the return value of the function is not negative or positive
      HUGE_VAL or zero.
      9d520a7f
  14. 13 7月, 2013 2 次提交
  15. 12 7月, 2013 2 次提交