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 +4 -4
- data/CHANGELOG.md +2 -0
- data/benchmarks/pipeline.rb +2 -2
- data/benchmarks/pool.rb +29 -10
- data/lib/oxblood/connection.rb +4 -1
- data/lib/oxblood/pool.rb +4 -2
- data/lib/oxblood/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27d328641bcf1ed89164aeb5288e6f9280ca6127
|
4
|
+
data.tar.gz: fbf311595af5e1bb6fc0a582f7d1a799168399f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9876df90dcd7a807fe2bbcf9b7ef9a8068a08dd80943d7c0fd8808883ab99986d954d078215c7794a52dfeeb707b97f56e4b1f8976ee3ede87e5d5bf7b064e84
|
7
|
+
data.tar.gz: 82efd7dd0895e1275afdecdb6c47a46d95bf8b3550bbcb45e2f18a313c575a04097ad0f17f4ed284f88002ab1c2124310ce227290f22095d076d8e594218c657
|
data/CHANGELOG.md
ADDED
data/benchmarks/pipeline.rb
CHANGED
@@ -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 =
|
6
|
+
N = 5_000
|
7
7
|
TASKS = 1_000
|
8
|
-
POOL_SIZE =
|
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
|
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.
|
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
|
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.
|
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 } }
|
data/lib/oxblood/connection.rb
CHANGED
@@ -38,8 +38,11 @@ module Oxblood
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Send comand to Redis server
|
41
|
-
# @example
|
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
data/lib/oxblood/version.rb
CHANGED
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
|
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-
|
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:
|
157
|
+
version: '0'
|
157
158
|
requirements: []
|
158
159
|
rubyforge_project:
|
159
160
|
rubygems_version: 2.6.8
|