oxblood 0.1.0.dev12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30b1991382a2df8f7fdfb18563b7da0d10b105e8
4
- data.tar.gz: af6cfe127dd7f4d0469b6a98464b30096b9ef726
3
+ metadata.gz: 27d328641bcf1ed89164aeb5288e6f9280ca6127
4
+ data.tar.gz: fbf311595af5e1bb6fc0a582f7d1a799168399f0
5
5
  SHA512:
6
- metadata.gz: 7b839abf82ef981cd459a2b2e4dad29e690788fcd33ba5b242670b19bc2ed96cce01580427a1da685a1ae89db9f53f003e9a1371ce8d853bbde5f9652df479c4
7
- data.tar.gz: c28a49faf89c1b92090c371b1d943259e80df75571522cfe8998c45f4a7fe0cfab44fa7ec8f5c346fddacc8176c6d17515b3c516ac2a2b7e5cc27e79f39db358
6
+ metadata.gz: 9876df90dcd7a807fe2bbcf9b7ef9a8068a08dd80943d7c0fd8808883ab99986d954d078215c7794a52dfeeb707b97f56e4b1f8976ee3ede87e5d5bf7b064e84
7
+ data.tar.gz: 82efd7dd0895e1275afdecdb6c47a46d95bf8b3550bbcb45e2f18a313c575a04097ad0f17f4ed284f88002ab1c2124310ce227290f22095d076d8e594218c657
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0 (2017-01-18)
2
+ * Initial public release - [@etehtsea](https://github.com/etehtsea)
@@ -11,12 +11,12 @@ def benchmark(label, &blk)
11
11
  end
12
12
 
13
13
  def redis_without
14
- r = Redis.new
14
+ r = Redis.new(driver: :ruby)
15
15
  N.times { r.ping }
16
16
  end
17
17
 
18
18
  def redis_with
19
- r = Redis.new
19
+ r = Redis.new(driver: :ruby)
20
20
  r.pipelined { N.times { r.ping } }
21
21
  end
22
22
 
data/benchmarks/pool.rb CHANGED
@@ -3,15 +3,17 @@ require 'redis'
3
3
  require 'oxblood'
4
4
  require 'benchmark'
5
5
 
6
- N = 10_000
6
+ N = 5_000
7
7
  TASKS = 1_000
8
- POOL_SIZE = 32
8
+ POOL_SIZE = Concurrent.processor_count + 1
9
+
10
+ Concurrent.use_stdlib_logger(Logger::DEBUG)
9
11
 
10
12
  def worker_pool
11
- Concurrent::FixedThreadPool.new(POOL_SIZE * 2)
13
+ Concurrent::FixedThreadPool.new(POOL_SIZE)
12
14
  end
13
15
 
14
- RedisPool = ConnectionPool.new(size: POOL_SIZE) { Redis.new }
16
+ RedisPool = ConnectionPool.new(size: POOL_SIZE) { Redis.new(driver: :ruby) }
15
17
  OxbloodPool = Oxblood::Pool.new(size: POOL_SIZE)
16
18
 
17
19
  def benchmark(label, &blk)
@@ -19,20 +21,37 @@ def benchmark(label, &blk)
19
21
  puts [label, sec.round(3)].join(': ')
20
22
  end
21
23
 
22
- def run(&blk)
24
+ def run(name, &blk)
25
+ puts "Running #{name}"
26
+
23
27
  pool = worker_pool
24
28
  TASKS.times { pool.post(&blk) }
25
- sleep 0.1 while pool.completed_task_count != TASKS
29
+ sleep 0.1 while pool.scheduled_task_count != TASKS
30
+ pool.shutdown
31
+ pool.wait_for_termination
32
+ puts "#{pool.completed_task_count} tasks finished successfully"
26
33
  end
27
34
 
28
35
  def redis
29
- RedisPool.with { |r| r.pipelined { N.times { r.ping } } }
36
+ RedisPool.with do |r|
37
+ r.pipelined do
38
+ N.times { r.ping }
39
+ end
40
+ end
30
41
  end
31
42
 
32
43
  def oxblood
33
- OxbloodPool.pipelined { |p| N.times { p.ping } }
44
+ OxbloodPool.with do |s|
45
+ s.pipelined do |p|
46
+ N.times { p.ping }
47
+ end
48
+ end
34
49
  end
35
50
 
51
+ # Check that everything is working
52
+ redis
53
+ oxblood
54
+
36
55
  # Warmup JVM
37
56
  if RUBY_ENGINE == 'jruby'
38
57
  10.times do
@@ -41,5 +60,5 @@ if RUBY_ENGINE == 'jruby'
41
60
  end
42
61
  end
43
62
 
44
- benchmark('redis-rb') { run { redis } }
45
- benchmark('oxblood') { run { oxblood } }
63
+ benchmark('redis-rb') { run('redis-rb') { redis } }
64
+ benchmark('oxblood') { run('oxblood') { oxblood } }
@@ -38,8 +38,11 @@ module Oxblood
38
38
  end
39
39
 
40
40
  # Send comand to Redis server
41
- # @example send_command('CONFIG', 'GET', '*') => 32
41
+ # @example
42
+ # send_command('CONFIG', 'GET', '*') => 32
43
+ #
42
44
  # @param [Array] command Array of command name with it's args
45
+ #
43
46
  # @return [Integer] Number of bytes written to socket
44
47
  def send_command(*command)
45
48
  @socket.write(Protocol.build_command(*command))
data/lib/oxblood/pool.rb CHANGED
@@ -42,8 +42,10 @@ module Oxblood
42
42
  session = Session.new(conn)
43
43
  yield(session)
44
44
  ensure
45
- session.discard if conn.in_transaction?
46
- @pool.checkin if conn
45
+ if conn
46
+ session.discard if conn.in_transaction?
47
+ @pool.checkin
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -1,3 +1,3 @@
1
1
  module Oxblood
2
- VERSION = '0.1.0.dev12'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxblood
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.dev12
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Shabanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -106,6 +106,7 @@ files:
106
106
  - ".rspec"
107
107
  - ".travis.yml"
108
108
  - ".yardopts"
109
+ - CHANGELOG.md
109
110
  - Gemfile
110
111
  - LICENSE.txt
111
112
  - README.md
@@ -151,9 +152,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
152
  version: 2.2.2
152
153
  required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  requirements:
154
- - - ">"
155
+ - - ">="
155
156
  - !ruby/object:Gem::Version
156
- version: 1.3.1
157
+ version: '0'
157
158
  requirements: []
158
159
  rubyforge_project:
159
160
  rubygems_version: 2.6.8