david 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/benchmarks/data/jruby-1.7.19-rack +84 -0
  4. data/benchmarks/data/jruby-1.7.19-rack.csv +29 -0
  5. data/benchmarks/data/jruby-1.7.19-rails +84 -0
  6. data/benchmarks/data/jruby-1.7.19-rails.csv +29 -0
  7. data/benchmarks/data/jruby-9.0.0.0-pre1-rack +84 -0
  8. data/benchmarks/data/jruby-9.0.0.0-pre1-rack.csv +29 -0
  9. data/benchmarks/data/jruby-9.0.0.0-pre1-rails +84 -0
  10. data/benchmarks/data/jruby-9.0.0.0-pre1-rails.csv +29 -0
  11. data/benchmarks/data/mri-2.2.0p0-rack +84 -0
  12. data/benchmarks/data/mri-2.2.0p0-rack.csv +29 -0
  13. data/benchmarks/data/mri-2.2.0p0-rails +84 -0
  14. data/benchmarks/data/mri-2.2.0p0-rails.csv +29 -0
  15. data/benchmarks/data/mri-2.3.0-dev-rack +84 -0
  16. data/benchmarks/data/mri-2.3.0-dev-rack.csv +29 -0
  17. data/benchmarks/data/mri-2.3.0-dev-rails +84 -0
  18. data/benchmarks/data/mri-2.3.0-dev-rails.csv +29 -0
  19. data/benchmarks/interop.sh +2 -0
  20. data/benchmarks/max.rb +3 -0
  21. data/benchmarks/plot.frameworks.r +30 -0
  22. data/benchmarks/plot.loss.r +35 -0
  23. data/benchmarks/plot.vms.r +37 -0
  24. data/benchmarks/rackup/Gemfile.lock +7 -1
  25. data/benchmarks/rackup/interop.ru +17 -0
  26. data/experiments/concurrency/stub.rb +5 -5
  27. data/lib/david/etsi.rb +5 -0
  28. data/lib/david/etsi/mandatory.rb +4 -0
  29. data/lib/david/{interop/mandatory_etsi → etsi/mandatory}/grape.rb +1 -1
  30. data/lib/david/{interop/mandatory_etsi → etsi/mandatory}/hobbit.rb +1 -1
  31. data/lib/david/{interop/mandatory_etsi → etsi/mandatory}/nyny.rb +1 -1
  32. data/lib/david/{interop/mandatory_etsi → etsi/mandatory}/rack.rb +3 -3
  33. data/lib/david/{interop/mandatory_etsi → etsi/mandatory}/sinatra.rb +1 -1
  34. data/lib/david/etsi/optional.rb +4 -0
  35. data/lib/david/etsi/optional/rack.rb +26 -0
  36. data/lib/david/registry.rb +5 -3
  37. data/lib/david/server.rb +5 -6
  38. data/lib/david/server/utility.rb +8 -0
  39. data/lib/david/version.rb +1 -1
  40. data/spec/interop/mandatory_spec.rb +5 -9
  41. data/spec/interop/optional_spec.rb +113 -0
  42. data/spec/spec_helper.rb +1 -1
  43. metadata +35 -10
  44. data/benchmarks/plot.r +0 -24
  45. data/lib/david/interop.rb +0 -4
  46. data/lib/david/interop/mandatory_etsi.rb +0 -4
@@ -0,0 +1,29 @@
1
+ concurrent,loss,throughput
2
+ 10.0,0.0,5192.0
3
+ 20.0,0.0,6229.33333
4
+ 30.0,0.0,7727.66667
5
+ 40.0,0.0,8624.33333
6
+ 50.0,0.0,8949.0
7
+ 60.0,0.0,9122.66667
8
+ 70.0,0.0,9349.0
9
+ 80.0,0.0,9672.66667
10
+ 90.0,0.0,9836.66667
11
+ 100.0,0.0,9978.0
12
+ 200.0,0.0,10871.0
13
+ 300.0,0.01345,10903.33333
14
+ 400.0,0.07517,10819.66667
15
+ 500.0,0.13742,10777.0
16
+ 600.0,0.22956,10749.33333
17
+ 700.0,0.31443,10773.66667
18
+ 800.0,0.40563,10772.66667
19
+ 900.0,0.48934,10780.33333
20
+ 1000.0,0.59199,10720.33333
21
+ 2000.0,1.52498,10651.0
22
+ 3000.0,2.48929,10700.33333
23
+ 4000.0,3.44407,10638.33333
24
+ 5000.0,4.25959,10850.33333
25
+ 6000.0,5.28891,10764.33333
26
+ 7000.0,6.10506,10903.0
27
+ 8000.0,7.1729,10730.66667
28
+ 9000.0,7.99336,10855.0
29
+ 10000.0,8.86836,10892.33333
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ java -jar coapbench/californium/run/cf-plugtest-checker-1.0.0-SNAPSHOT.jar -s "coap://[::1]:5683" CC01 CC02 CC03 CC04 CC05 CC06 CC07 CC08 CC10 CC11 CC12 CC13 CB01 CB02 CO01_12
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'csv'
3
+ puts CSV.parse(File.read(ARGV[0])).map { |x| x[2].to_f }.unshift.max
@@ -0,0 +1,30 @@
1
+ #!/usr/lib/R/bin/Rscript
2
+
3
+ library(methods)
4
+ library(ggplot2)
5
+ library(reshape2)
6
+
7
+ args = commandArgs(T)
8
+ rack = read.table(file=args[1], sep=',', header=T)
9
+ rails = read.table(file=args[2], sep=',', header=T)
10
+
11
+ Concurrent = rack$concurrent
12
+ Rack = rack$throughput
13
+ Rails = rails$throughput
14
+
15
+ df = data.frame(Concurrent, Rack, Rails)
16
+ df.long = melt(df, id.vars='Concurrent')
17
+
18
+ g = ggplot(df.long, aes(Concurrent, value, shape=variable)) +
19
+ scale_x_log10(breaks=c(10, 50, 100, 500, 1000, 5000, 10000)) +
20
+ scale_y_continuous(breaks=round(seq(1000, 15000, by=1000), 1)) +
21
+ scale_shape(name='Framework') +
22
+ ylab('Requests per second') +
23
+ xlab('Concurrent clients (log.)') +
24
+ geom_line() +
25
+ geom_point() +
26
+ theme_bw()
27
+
28
+ path = paste(args[1], 'frameworks', 'pdf', sep='.')
29
+ print(path)
30
+ ggsave(g, file=path)
@@ -0,0 +1,35 @@
1
+ #!/usr/lib/R/bin/Rscript
2
+
3
+ library(methods)
4
+ library(ggplot2)
5
+ library(reshape2)
6
+
7
+ args = commandArgs(T)
8
+
9
+ mri22_data = read.table(file=args[1], sep=',', header=T)
10
+ mri23_data = read.table(file=args[2], sep=',', header=T)
11
+ jruby17_data = read.table(file=args[3], sep=',', header=T)
12
+ jruby9_data = read.table(file=args[4], sep=',', header=T)
13
+ # rbx25_data = read.table(file=args[5], sep=',', header=T)
14
+
15
+ x = mri22_data$concurrent
16
+ mri22 = mri22_data$loss
17
+ mri23 = mri23_data$loss
18
+ jruby17 = jruby17_data$loss
19
+ jruby9 = jruby9_data$loss
20
+ # rbx25 = rbx25_data$loss
21
+
22
+ df = data.frame(x, mri22, mri23, jruby17, jruby9) #, rbx25)
23
+ df.long = melt(df, id.vars='x')
24
+
25
+ g = ggplot(df.long, aes(x, value, shape=variable)) +
26
+ scale_shape(name='Ruby VM') +
27
+ ylab('Percentage of lost messages') +
28
+ xlab('Concurrent clients') +
29
+ geom_line() +
30
+ geom_point() +
31
+ theme_bw()
32
+
33
+ path = paste(args[1], 'loss', 'pdf', sep='.')
34
+ print(path)
35
+ ggsave(g, file=path)
@@ -0,0 +1,37 @@
1
+ #!/usr/lib/R/bin/Rscript
2
+
3
+ library(methods)
4
+ library(ggplot2)
5
+ library(reshape2)
6
+
7
+ args = commandArgs(T)
8
+
9
+ mri22_data = read.table(file=args[1], sep=',', header=T)
10
+ mri23_data = read.table(file=args[2], sep=',', header=T)
11
+ jruby17_data = read.table(file=args[3], sep=',', header=T)
12
+ jruby9_data = read.table(file=args[4], sep=',', header=T)
13
+ # rbx25_data = read.table(file=args[5], sep=',', header=T)
14
+
15
+ x = mri22_data$concurrent
16
+ mri22 = mri22_data$throughput
17
+ mri23 = mri23_data$throughput
18
+ jruby17 = jruby17_data$throughput
19
+ jruby9 = jruby9_data$throughput
20
+ # rbx25 = rbx25_data$throughput
21
+
22
+ df = data.frame(x, mri22, mri23, jruby17, jruby9) #, rbx25)
23
+ df.long = melt(df, id.vars='x')
24
+
25
+ g = ggplot(df.long, aes(x, value, shape=variable)) +
26
+ scale_x_log10(breaks=c(10, 50, 100, 500, 1000, 5000, 10000)) +
27
+ scale_y_continuous(breaks=round(seq(1000, 15000, by=1000), 1)) +
28
+ scale_shape(name='Ruby VM') +
29
+ ylab('Requests per second') +
30
+ xlab('Concurrent clients (log.)') +
31
+ geom_line() +
32
+ geom_point() +
33
+ theme_bw()
34
+
35
+ path = paste(args[1], 'vms', 'pdf', sep='.')
36
+ print(path)
37
+ ggsave(g, file=path)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- david (0.4.1.pre)
4
+ david (0.4.2.pre)
5
5
  celluloid-io (~> 0.16, >= 0.16.1)
6
6
  coap (>= 0.1)
7
7
  rack (~> 1.6)
@@ -79,9 +79,11 @@ GEM
79
79
  hashie (3.4.0)
80
80
  hike (1.2.3)
81
81
  hitimes (1.2.2)
82
+ hitimes (1.2.2-java)
82
83
  i18n (0.7.0)
83
84
  ice_nine (0.11.1)
84
85
  json (1.8.2)
86
+ json (1.8.2-java)
85
87
  loofah (2.0.1)
86
88
  nokogiri (>= 1.5.9)
87
89
  mail (2.6.3)
@@ -92,8 +94,10 @@ GEM
92
94
  multi_json (1.10.1)
93
95
  multi_xml (0.5.5)
94
96
  nio4r (1.1.0)
97
+ nio4r (1.1.0-java)
95
98
  nokogiri (1.6.6.2)
96
99
  mini_portile (~> 0.6.0)
100
+ nokogiri (1.6.6.2-java)
97
101
  rack (1.6.0)
98
102
  rack-accept (0.4.5)
99
103
  rack (>= 0.4)
@@ -138,6 +142,7 @@ GEM
138
142
  sprockets (>= 2.8, < 4.0)
139
143
  thor (0.19.1)
140
144
  thread_safe (0.3.4)
145
+ thread_safe (0.3.4-java)
141
146
  tilt (1.4.1)
142
147
  timers (4.0.1)
143
148
  hitimes
@@ -150,6 +155,7 @@ GEM
150
155
  equalizer (~> 0.0, >= 0.0.9)
151
156
 
152
157
  PLATFORMS
158
+ java
153
159
  ruby
154
160
 
155
161
  DEPENDENCIES
@@ -0,0 +1,17 @@
1
+ #\ -o ::1 -p 5683 -O Block=true -O Multicast=false -O Observe=false -O Log=debug -E none
2
+
3
+ module David; module ETSI; end; end
4
+
5
+ require 'bundler/setup'
6
+ Bundler.setup
7
+
8
+ require 'david'
9
+ require 'david/etsi/mandatory/rack'
10
+ require 'david/etsi/optional/rack'
11
+
12
+ apps = [
13
+ David::ETSI::Optional::Rack.new,
14
+ David::ETSI::Mandatory::Rack.new,
15
+ ]
16
+
17
+ run Rack::Cascade.new(apps)
@@ -10,13 +10,12 @@ class Listener
10
10
  @socket = socket
11
11
  @cache = cache
12
12
  @app = Rack::HelloWorld.new
13
- @block = true
14
- @observe = true
13
+ @options = David::AppConfig.new
15
14
  end
16
15
 
17
16
  def run
18
17
  loop do
19
- if defined?(JRuby) || @mode == :prefork || @mode == :threaded
18
+ if defined?(JRuby) || defined?(Rubinius) || @mode == :prefork || @mode == :threaded
20
19
  data, sender = @socket.recvfrom(1152)
21
20
  port, _, host = sender[1..3]
22
21
  else
@@ -73,15 +72,16 @@ case ARGV[0]
73
72
  socket.bind('::', 5683)
74
73
  4.times { fork { Listener.new(:prefork, socket, cache).run } }
75
74
  when 'threaded'
76
- # ~16000
75
+ # ~17500
77
76
  socket = UDPSocket.new(Socket::AF_INET6)
78
77
  socket.bind('::', 5683)
79
78
  Listener.send(:include, Celluloid)
80
79
  Listener.pool(size: 8, args: [:threaded, socket, cache]).run
81
80
  else
82
- # ~14000
81
+ # ~17000
83
82
  socket = Celluloid::IO::UDPSocket.new(Socket::AF_INET6)
84
83
  socket.bind('::', 5683)
84
+ Listener.send(:include, Celluloid::IO)
85
85
  Listener.new(:sped, socket, cache).run
86
86
  end
87
87
 
@@ -0,0 +1,5 @@
1
+ module David::ETSI
2
+ end
3
+
4
+ require 'david/etsi/mandatory'
5
+ require 'david/etsi/optional'
@@ -0,0 +1,4 @@
1
+ module David::ETSI::Mandatory
2
+ path = File.expand_path('../mandatory', __FILE__)
3
+ Dir["#{path}/*.rb"].each { |file| require file }
4
+ end
@@ -1,4 +1,4 @@
1
- module David::Interop::MandatoryETSI
1
+ module David::ETSI::Mandatory
2
2
  class Grape < ::Grape::API
3
3
  content_type :txt, 'text/plain'
4
4
  default_format :txt
@@ -1,4 +1,4 @@
1
- module David::Interop::MandatoryETSI
1
+ module David::ETSI::Mandatory
2
2
  class Hobbit < ::Hobbit::Base
3
3
  get '/test' do
4
4
  response.status = 2.05
@@ -1,4 +1,4 @@
1
- module David::Interop::MandatoryETSI
1
+ module David::ETSI::Mandatory
2
2
  class NYNY < ::NYNY::App
3
3
  before { headers['Content-Type'] = 'text/plain' }
4
4
 
@@ -1,6 +1,6 @@
1
- module David::Interop::MandatoryETSI
1
+ module David::ETSI::Mandatory
2
2
  class Rack
3
- EMPTY_CONTENT = [2.05, {'Content-Type' => 'text/plain'}, []]
3
+ EMPTY_CONTENT = [2.05, {'Content-Type' => 'text/plain'}, ['foo']]
4
4
 
5
5
  def call(env)
6
6
  return case request(env)
@@ -13,7 +13,7 @@ module David::Interop::MandatoryETSI
13
13
  when 'DELETE /test'
14
14
  [2.02, {}, []]
15
15
  else
16
- [4.04, {}, []]
16
+ [404, {}, []]
17
17
  end
18
18
  end
19
19
 
@@ -1,4 +1,4 @@
1
- module David::Interop::MandatoryETSI
1
+ module David::ETSI::Mandatory
2
2
  class Sinatra < ::Sinatra::Base
3
3
  before { content_type 'text/plain' }
4
4
 
@@ -0,0 +1,4 @@
1
+ module David::ETSI::Optional
2
+ path = File.expand_path('../optional', __FILE__)
3
+ Dir["#{path}/*.rb"].each { |file| require file }
4
+ end
@@ -0,0 +1,26 @@
1
+ module David::ETSI::Optional
2
+ class Rack
3
+ def call(env)
4
+ return case request(env)
5
+ when 'GET /large'
6
+ [2.05, {'Content-Type' => 'text/plain'}, ['*'*1025]]
7
+ when 'GET /obs'
8
+ [2.05,
9
+ {
10
+ 'Content-Type' => 'text/plain',
11
+ 'ETag' => rand(0xffff).to_s
12
+ },
13
+ [Time.now.to_s]
14
+ ]
15
+ else
16
+ [404, {}, []]
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def request(env)
23
+ env['REQUEST_METHOD'] + ' ' + env['PATH_INFO']
24
+ end
25
+ end
26
+ end
@@ -15,9 +15,11 @@ module David
15
15
  # Celluloid::Actor[:gc]
16
16
  # end
17
17
 
18
- # def observe
19
- # Celluloid::Actor[:observe]
20
- # end
18
+ def observe
19
+ # Supervision is only initialized from here in tests.
20
+ Observe.supervise_as(:observe) if Celluloid::Actor[:observe].nil?
21
+ Celluloid::Actor[:observe]
22
+ end
21
23
 
22
24
  def server
23
25
  Celluloid::Actor[:server]
@@ -1,7 +1,9 @@
1
1
  require 'david/app_config'
2
+
2
3
  require 'david/server/mid_cache'
3
4
  require 'david/server/multicast'
4
5
  require 'david/server/respond'
6
+ require 'david/server/utility'
5
7
 
6
8
  module David
7
9
  class Server
@@ -10,6 +12,7 @@ module David
10
12
  include MidCache
11
13
  include Multicast
12
14
  include Respond
15
+ include Utility
13
16
 
14
17
  attr_reader :log, :socket
15
18
 
@@ -36,7 +39,7 @@ module David
36
39
 
37
40
  def run
38
41
  loop do
39
- if defined?(JRuby) || defined?(Rubinius)
42
+ if jruby_or_rbx?
40
43
  dispatch(*@socket.recvfrom(1152))
41
44
  else
42
45
  begin
@@ -66,7 +69,7 @@ module David
66
69
  def dispatch(*args)
67
70
  data, sender, _, anc = args
68
71
 
69
- if defined?(JRuby) || defined?(Rubinius)
72
+ if jruby_or_rbx?
70
73
  port, _, host = sender[1..3]
71
74
  else
72
75
  host, port = sender.ip_address, sender.ip_port
@@ -106,10 +109,6 @@ module David
106
109
  end
107
110
  end
108
111
 
109
- def ipv6?
110
- IPAddr.new(@options[:Host]).ipv6?
111
- end
112
-
113
112
  def pong(exchange)
114
113
  exchange.message.tt = :ack
115
114
  answer(exchange)
@@ -10,6 +10,14 @@ module David
10
10
  body.close if body.respond_to?(:close)
11
11
  s.chomp
12
12
  end
13
+
14
+ def ipv6?
15
+ @ipv6 ||= IPAddr.new(@options[:Host]).ipv6?
16
+ end
17
+
18
+ def jruby_or_rbx?
19
+ @jruby_or_rbx ||= !!(defined?(JRuby) || defined?(Rubinius))
20
+ end
13
21
  end
14
22
  end
15
23
  end
@@ -1,7 +1,7 @@
1
1
  module David
2
2
  MAJOR = 0
3
3
  MINOR = 4
4
- PATCH = 1
4
+ PATCH = 2
5
5
  SUFFIX = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, PATCH, SUFFIX].compact.join('.')
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  [
4
- Interop::MandatoryETSI::Grape,
5
- Interop::MandatoryETSI::Hobbit,
6
- Interop::MandatoryETSI::NYNY,
7
- Interop::MandatoryETSI::Rack,
8
- Interop::MandatoryETSI::Sinatra,
4
+ ETSI::Mandatory::Grape,
5
+ ETSI::Mandatory::Hobbit,
6
+ ETSI::Mandatory::NYNY,
7
+ ETSI::Mandatory::Rack,
8
+ ETSI::Mandatory::Sinatra,
9
9
  Rails.application
10
10
  ].each do |app|
11
11
  describe "ETSI Plugstests, Mandatory, #{app.to_s.split('::').last}" do
@@ -50,10 +50,6 @@ require 'spec_helper'
50
50
  end
51
51
  end
52
52
 
53
- context 'TD_COAP_CORE_09' do
54
- pending
55
- end
56
-
57
53
  it 'TD_COAP_CORE_10' do
58
54
  token = rand(0xffffffff)
59
55
  mid, response = req(:get, '/test', token: token)