1. 25 5月, 2012 1 次提交
    • A
      Four new persistence fields in INFO. A few renamed. · 33e1db36
      antirez 提交于
      The 'persistence' section of INFO output now contains additional four
      fields related to RDB and AOF persistence:
      
       rdb_last_bgsave_time_sec       Duration of latest BGSAVE in sec.
       rdb_current_bgsave_time_sec    Duration of current BGSAVE in sec.
       aof_last_rewrite_time_sec      Duration of latest AOF rewrite in sec.
       aof_current_rewrite_time_sec   Duration of current AOF rewrite in sec.
      
      The 'current' fields are set to -1 if a BGSAVE / AOF rewrite is not in
      progress. The 'last' fileds are set to -1 if no previous BGSAVE / AOF
      rewrites were performed.
      
      Additionally a few fields in the persistence section were renamed for
      consistency:
      
       changes_since_last_save -> rdb_changes_since_last_save
       bgsave_in_progress -> rdb_bgsave_in_progress
       last_save_time -> rdb_last_save_time
       last_bgsave_status -> rdb_last_bgsave_status
       bgrewriteaof_in_progress -> aof_rewrite_in_progress
       bgrewriteaof_scheduled -> aof_rewrite_scheduled
      
      After the renaming, fields in the persistence section start with rdb_ or
      aof_ prefix depending on the persistence method they describe.
      The field 'loading' and related fields are not prefixed because they are
      unique for both the persistence methods.
      33e1db36
  2. 24 5月, 2012 3 次提交
    • A
      New commands: BITOP and BITCOUNT. · 0bd6d68e
      antirez 提交于
      The motivation for this new commands is to be search in the usage of
      Redis for real time statistics. See the article "Fast real time metrics
      using Redis".
      
      http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/
      
      In general Redis strings when used as bitmaps using the SETBIT/GETBIT
      command provide a very space-efficient and fast way to store statistics.
      For instance in a web application with users, every user can be
      associated with a key that shows every day in which the user visited the
      web service. This information can be really valuable to extract user
      behaviour information.
      
      With Redis bitmaps doing this is very simple just saying that a given
      day is 0 (the data the service was put online) and all the next days are
      1, 2, 3, and so forth. So with SETBIT it is possible to set the bit
      corresponding to the current day every time the user visits the site.
      
      It is possible to take the count of the bit sets on the run, this is
      extremely easy using a Lua script. However a fast bit count native
      operation can be useful, especially if it can operate on ranges, or when
      the string is small like in the case of days (even if you consider many
      years it is still extremely little data).
      
      For this reason BITOP was introduced. The command counts the number of
      bits set to 1 in a string, with optional range:
      
      BITCOUNT key [start end]
      
      The start/end parameters are similar to GETRANGE. If omitted the whole
      string is tested.
      
      Population counting is more useful when bit-level operations like AND,
      OR and XOR are avaialble. For instance I can test multiple users to see
      the number of days three users visited the site at the same time. To do
      this we can take the AND of all the bitmaps, and then count the set bits.
      
      For this reason the BITOP command was introduced:
      
      BITOP [AND|OR|XOR|NOT] dest_key src_key1 src_key2 src_key3 ... src_keyN
      
      In the special case of NOT (that inverts the bits) only one source key
      can be passed.
      
      The judicious use of BITCOUNT and BITOP combined can lead to interesting
      use cases with very space efficient representation of data.
      
      The implementation provided is still not tested and optimized for speed,
      next commits will introduce unit tests. Later the implementation will be
      profiled to see if it is possible to gain an important amount of speed
      without making the code much more complex.
      0bd6d68e
    • A
      Add aof_rewrite_buffer_length INFO field. · 6f05a653
      antirez 提交于
      The INFO output, persistence section, already contained the field
      describing the size of the current AOF buffer to flush on disk. However
      the other AOF buffer, used to accumulate changes during an AOF rewrite,
      was not mentioned in the INFO output.
      
      This commit introduces a new field called aof_rewrite_buffer_length with
      the length of the rewrite buffer.
      6f05a653
    • A
      Allow an AOF rewrite buffer > 2GB (Fix for issue #504). · 47ca4b6e
      antirez 提交于
      During the AOF rewrite process, the parent process needs to accumulate
      the new writes in an in-memory buffer: when the child will terminate the
      AOF rewriting process this buffer (that ist the difference between the
      dataset when the rewrite was started, and the current dataset) is
      flushed to the new AOF file.
      
      We used to implement this buffer using an sds.c string, but sds.c has a
      2GB limit. Sometimes the dataset can be big enough, the amount of writes
      so high, and the rewrite process slow enough that we overflow the 2GB
      limit, causing a crash, documented on github by issue #504.
      
      In order to prevent this from happening, this commit introduces a new
      system to accumulate writes, implemented by a linked list of blocks of
      10 MB each, so that we also avoid paying the reallocation cost.
      
      Note that theoretically modern operating systems may implement realloc()
      simply as a remaping of the old pages, thus with very good performances,
      see for instance the mremap() syscall on Linux. However this is not
      always true, and jemalloc by default avoids doing this because there are
      issues with the current implementation of mremap().
      
      For this reason we are using a linked list of blocks instead of a single
      block that gets reallocated again and again.
      
      The changes in this commit lacks testing, that will be performed before
      merging into the unstable branch. This fix will not enter 2.4 because it
      is too invasive. However 2.4 will log a warning when the AOF rewrite
      buffer is near to the 2GB limit.
      47ca4b6e
  3. 14 5月, 2012 2 次提交
    • A
      activeExpireCycle(): better precision in max time used. · b3624f5a
      antirez 提交于
      activeExpireCycle() can consume no more than a few milliseconds per
      iteration. This commit improves the precision of the check for the time
      elapsed in two ways:
      
      1) We check every 16 iterations instead of the main loop instead of 256.
      2) We reset iterations at the start of the function and not every time
         we switch to the next database, so the check is correctly performed
         every 16 iterations.
      b3624f5a
    • A
      Impovements for: Redis timer, hashes rehashing, keys collection. · 61daf891
      antirez 提交于
      A previous commit introduced REDIS_HZ define that changes the frequency
      of calls to the serverCron() Redis function. This commit improves
      different related things:
      
      1) Software watchdog: now the minimal period can be set according to
      REDIS_HZ. The minimal period is two times the timer period, that is:
      
          (1000/REDIS_HZ)*2 milliseconds
      
      2) The incremental rehashing is now performed in the expires dictionary
      as well.
      
      3) The activeExpireCycle() function was improved in different ways:
      
      - Now it checks if it already used too much time using microseconds
        instead of milliseconds for better precision.
      - The time limit is now calculated correctly, in the previous version
        the division was performed before of the multiplication resulting in
        a timelimit of 0 if HZ was big enough.
      - Databases with less than 1% of buckets fill in the hash table are
        skipped, because getting random keys is too expensive in this
        condition.
      
      4) tryResizeHashTables() is now called at every timer call, we need to
         match the number of calls we do to the expired keys colleciton cycle.
      
      5) REDIS_HZ was raised to 100.
      61daf891
  4. 13 5月, 2012 1 次提交
    • A
      Redis timer interrupt frequency configurable as REDIS_HZ. · 94343492
      antirez 提交于
      Redis uses a function called serverCron() that is very similar to the
      timer interrupt of an operating system. This function is used to handle
      a number of asynchronous things, like active expired keys collection,
      clients timeouts, update of statistics, things related to the cluster
      and replication, triggering of BGSAVE and AOF rewrite process, and so
      forth.
      
      In the past the timer was called 1 time per second. At some point it was
      raised to 10 times per second, but it still was fixed and could not be
      changed even at compile time, because different functions called from
      serverCron() assumed a given fixed frequency.
      
      This commmit makes the frequency configurable, so that it is simpler to
      pick a good tradeoff between overhead of this function (that is usually
      very small) and the responsiveness of Redis during a few critical
      circumstances where a lot of work is done inside the timer.
      
      An example of such a critical condition is mass-expire of a lot of keys
      in the same second. Up to a given percentage of CPU time is used to
      perform expired keys collection per expire cylce. Now changing the
      REDIS_HZ macro it is possible to do less work but more times per second
      in order to block the server for less time.
      
      If this patch will work well in our tests it will enter Redis 2.6-final.
      94343492
  5. 12 5月, 2012 2 次提交
    • A
      f333788f
    • A
      More incremental active expired keys collection process. · 1dcc95d0
      antirez 提交于
      If a large amonut of keys are all expiring about at the same time, the
      "active" expired keys collection cycle used to block as far as the
      percentage of already expired keys was >= 25% of the total population of
      keys with an expire set.
      
      This could block the server even for many seconds in order to reclaim
      memory ASAP. The new algorithm uses at max a small amount of
      milliseconds per cycle, even if this means reclaiming the memory less
      promptly it also means a more responsive server.
      1dcc95d0
  6. 03 5月, 2012 1 次提交
  7. 26 4月, 2012 1 次提交
    • A
      Don't use an alternative stack for SIGSEGV & co. · 3ada43e7
      antirez 提交于
      This commit reverts most of c5757662, in
      order to use back main stack for signal handling.
      
      The main reason is that otherwise it is completely pointless that we do
      a lot of efforts to print the stack trace on crash, and the content of
      the stack and registers as well. Using an alternate stack broken this
      feature completely.
      3ada43e7
  8. 20 4月, 2012 1 次提交
  9. 18 4月, 2012 1 次提交
  10. 13 4月, 2012 2 次提交
    • A
      Stop access to global vars. Not configurable. · 6663653f
      antirez 提交于
      After considering the interaction between ability to delcare globals in
      scripts using the 'global' function, and the complexities related to
      hanlding replication and AOF in a sane way with globals AND ability to
      turn protection On and Off, we reconsidered the design. The new design
      makes clear that there is only one good way to write Redis scripts, that
      is not using globals. In the rare cases state must be retained across
      calls a Redis key can be used.
      6663653f
    • A
      Scripting: globals protection can now be switched on/off. · 37b29ef2
      antirez 提交于
      37b29ef2
  11. 12 4月, 2012 1 次提交
  12. 11 4月, 2012 1 次提交
  13. 10 4月, 2012 2 次提交
  14. 07 4月, 2012 2 次提交
  15. 05 4月, 2012 1 次提交
  16. 04 4月, 2012 3 次提交
  17. 03 4月, 2012 2 次提交
  18. 30 3月, 2012 1 次提交
  19. 28 3月, 2012 2 次提交
  20. 27 3月, 2012 2 次提交
  21. 25 3月, 2012 1 次提交
    • A
      New INFO field aof_delayed_fsync introduced. · c1d01b3c
      antirez 提交于
      This new field counts all the times Redis is configured with AOF enabled and
      fsync policy 'everysec', but the previous fsync performed by the
      background thread was not able to complete within two seconds, forcing
      Redis to perform a write against the AOF file while the fsync is still
      in progress (likely a blocking operation).
      c1d01b3c
  22. 24 3月, 2012 1 次提交
  23. 21 3月, 2012 3 次提交
    • A
      Correctly create shared.oomerr as an sds string. · b22eab8f
      antirez 提交于
      b22eab8f
    • A
      DEBUG should not be flagged as w otherwise we can not call DEBUG DIGEST and... · 7dcdd281
      antirez 提交于
      DEBUG should not be flagged as w otherwise we can not call DEBUG DIGEST and other commands against read only slaves.
      7dcdd281
    • A
      Support for read-only slaves. Semantical fixes. · f3fd419f
      antirez 提交于
      This commit introduces support for read only slaves via redis.conf and CONFIG GET/SET commands. Also various semantical fixes are implemented here:
      
      1) MULTI/EXEC with only read commands now work where the server is into a state where writes (or commands increasing memory usage) are not allowed. Before this patch everything inside a transaction would fail in this conditions.
      
      2) Scripts just calling read-only commands will work against read only
      slaves, when the server is out of memory, or when persistence is into an
      error condition. Before the patch EVAL always failed in this condition.
      f3fd419f
  24. 20 3月, 2012 1 次提交
  25. 19 3月, 2012 2 次提交