msgpack 1.3.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +57 -0
  3. data/.gitignore +3 -1
  4. data/.rubocop.yml +2 -2
  5. data/ChangeLog +86 -0
  6. data/Gemfile +3 -0
  7. data/README.md +266 -0
  8. data/Rakefile +1 -9
  9. data/bench/bench.rb +78 -0
  10. data/bin/console +8 -0
  11. data/doclib/msgpack/factory.rb +47 -3
  12. data/doclib/msgpack/packer.rb +5 -4
  13. data/doclib/msgpack/time.rb +1 -1
  14. data/doclib/msgpack/unpacker.rb +2 -2
  15. data/ext/java/org/msgpack/jruby/Buffer.java +23 -16
  16. data/ext/java/org/msgpack/jruby/Decoder.java +46 -23
  17. data/ext/java/org/msgpack/jruby/Encoder.java +68 -30
  18. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +37 -49
  19. data/ext/java/org/msgpack/jruby/ExtensionValue.java +5 -8
  20. data/ext/java/org/msgpack/jruby/Factory.java +47 -7
  21. data/ext/java/org/msgpack/jruby/Packer.java +29 -17
  22. data/ext/java/org/msgpack/jruby/Unpacker.java +72 -37
  23. data/ext/msgpack/buffer.c +42 -68
  24. data/ext/msgpack/buffer.h +59 -14
  25. data/ext/msgpack/buffer_class.c +90 -52
  26. data/ext/msgpack/compat.h +1 -111
  27. data/ext/msgpack/extconf.rb +45 -19
  28. data/ext/msgpack/factory_class.c +133 -43
  29. data/ext/msgpack/packer.c +60 -36
  30. data/ext/msgpack/packer.h +27 -25
  31. data/ext/msgpack/packer_class.c +84 -77
  32. data/ext/msgpack/packer_class.h +11 -0
  33. data/ext/msgpack/packer_ext_registry.c +24 -32
  34. data/ext/msgpack/packer_ext_registry.h +40 -33
  35. data/ext/msgpack/sysdep.h +5 -2
  36. data/ext/msgpack/unpacker.c +132 -115
  37. data/ext/msgpack/unpacker.h +23 -10
  38. data/ext/msgpack/unpacker_class.c +83 -81
  39. data/ext/msgpack/unpacker_class.h +11 -0
  40. data/ext/msgpack/unpacker_ext_registry.c +42 -18
  41. data/ext/msgpack/unpacker_ext_registry.h +23 -16
  42. data/lib/msgpack/bigint.rb +69 -0
  43. data/lib/msgpack/factory.rb +103 -0
  44. data/lib/msgpack/symbol.rb +21 -4
  45. data/lib/msgpack/time.rb +1 -1
  46. data/lib/msgpack/timestamp.rb +1 -1
  47. data/lib/msgpack/version.rb +4 -7
  48. data/lib/msgpack.rb +6 -12
  49. data/msgpack.gemspec +4 -7
  50. data/spec/bigint_spec.rb +26 -0
  51. data/spec/cruby/buffer_spec.rb +17 -0
  52. data/spec/factory_spec.rb +351 -12
  53. data/spec/msgpack_spec.rb +1 -1
  54. data/spec/packer_spec.rb +18 -0
  55. data/spec/spec_helper.rb +37 -3
  56. data/spec/timestamp_spec.rb +42 -0
  57. data/spec/unpacker_spec.rb +157 -4
  58. metadata +32 -62
  59. data/.travis.yml +0 -43
  60. data/README.rdoc +0 -225
  61. data/bench/pack.rb +0 -23
  62. data/bench/pack_log.rb +0 -33
  63. data/bench/pack_log_long.rb +0 -65
  64. data/bench/pack_symbols.rb +0 -28
  65. data/bench/run.sh +0 -14
  66. data/bench/run_long.sh +0 -35
  67. data/bench/run_symbols.sh +0 -26
  68. data/bench/unpack.rb +0 -21
  69. data/bench/unpack_log.rb +0 -34
  70. data/bench/unpack_log_long.rb +0 -67
@@ -1,65 +0,0 @@
1
- # viiite report --regroup bench,threads bench/pack_log_long.rb
2
-
3
- require 'viiite'
4
- require 'msgpack'
5
-
6
- data_plain = { 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"' }
7
- data_structure = {
8
- 'remote_host' => '127.0.0.1',
9
- 'remote_user' => '-',
10
- 'date' => '10/Oct/2000:13:55:36 -0700',
11
- 'request' => 'GET /apache_pb.gif HTTP/1.0',
12
- 'method' => 'GET',
13
- 'path' => '/apache_pb.gif',
14
- 'protocol' => 'HTTP/1.0',
15
- 'status' => 200,
16
- 'bytes' => 2326,
17
- 'referer' => 'http://www.example.com/start.html',
18
- 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
19
- }
20
-
21
- seconds = 3600 # 1 hour
22
-
23
- Viiite.bench do |b|
24
- b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
25
- b.report(:plain) do
26
- ths = []
27
- end_at = Time.now + seconds
28
- threads.times do
29
- t = Thread.new do
30
- packs = 0
31
- while Time.now < end_at
32
- 10000.times do
33
- MessagePack.pack(data_plain)
34
- end
35
- packs += 10000
36
- end
37
- packs
38
- end
39
- ths.push t
40
- end
41
- sum = ths.reduce(0){|r,t| r + t.value }
42
- puts "MessagePack.pack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
43
- end
44
-
45
- b.report(:structure) do
46
- ths = []
47
- end_at = Time.now + seconds
48
- threads.times do
49
- t = Thread.new do
50
- packs = 0
51
- while Time.now < end_at
52
- 10000.times do
53
- MessagePack.pack(data_structure)
54
- end
55
- packs += 10000
56
- end
57
- packs
58
- end
59
- ths.push t
60
- end
61
- sum = ths.reduce(0){|r,t| r + t.value }
62
- puts "MessagePack.pack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
63
- end
64
- end
65
- end
@@ -1,28 +0,0 @@
1
- require 'viiite'
2
- require 'msgpack'
3
-
4
- data = :symbol
5
-
6
- Viiite.bench do |b|
7
- b.variation_point :branch, `git rev-parse --abbrev-ref HEAD`
8
-
9
- b.range_over([:symbol, :none], :reg_type) do |reg_type|
10
- packer = MessagePack::Packer.new
11
- packer.register_type(0x00, Symbol, :to_msgpack_ext) if reg_type == :symbol
12
-
13
- b.range_over([100_000, 1_000_000, 10_000_000], :count) do |count|
14
- packer.clear
15
- b.report(:multi_run) do
16
- count.times do
17
- packer.pack(data)
18
- end
19
- end
20
-
21
- packer.clear
22
- items_data = [].fill(data, 0, count)
23
- b.report(:large_run) do
24
- packer.pack(items_data)
25
- end
26
- end
27
- end
28
- end
data/bench/run.sh DELETED
@@ -1,14 +0,0 @@
1
- #!/bin/sh
2
-
3
- # prerequisites
4
- # $ rbenv shell 2.2.1 (or jruby-x.x.x or ...)
5
- # $ rake install
6
-
7
- echo "pack"
8
- viiite report --regroup bench,runs bench/pack.rb
9
- echo "unpack"
10
- viiite report --regroup bench,runs bench/unpack.rb
11
- echo "pack log"
12
- viiite report --regroup bench,runs bench/pack_log.rb
13
- echo "unpack log"
14
- viiite report --regroup bench,runs bench/unpack_log.rb
data/bench/run_long.sh DELETED
@@ -1,35 +0,0 @@
1
- #!/bin/sh
2
-
3
- # prerequisites
4
- # $ sudo apt-get install sysstat
5
- # $ rbenv shell 2.2.1 (or jruby-x.x.x or ...)
6
- # $ rake install
7
-
8
- # 60 * 600 : 60*60 * 5[threads] * 2[bench]
9
-
10
- ruby -v
11
-
12
- echo "pack log long"
13
- viiite report --regroup bench,threads bench/pack_log_long.rb &
14
- sar -o pack_log_long.sar -r 60 600 > /dev/null 2>&1 &
15
-
16
- declare -i i=0
17
- while [ $i -lt 600 ]; do
18
- ps auxww | grep ruby | grep -v grep | awk '{print $5,$6;}' >> pack_log_long.mem.txt
19
- i=i+1
20
- sleep 60
21
- done
22
-
23
- sleep 120 # cool down
24
-
25
- echo "unpack log long"
26
- viiite report --regroup bench,threads bench/unpack_log_long.rb &
27
- sar -o unpack_log_long.sar -r 60 600 > /dev/null 2>&1 &
28
-
29
- i=0
30
- while [ $i -lt 600 ]; do
31
- ps auxww | grep ruby | grep -v grep | awk '{print $5,$6;}' >> pack_log_long.mem.txt
32
- i=i+1
33
- sleep 60
34
- done
35
-
data/bench/run_symbols.sh DELETED
@@ -1,26 +0,0 @@
1
- #!/bin/sh
2
-
3
- # so master and this branch have the benchmark file in any case
4
- cp bench/pack_symbols.rb bench/pack_symbols_tmp.rb
5
-
6
- benchmark=""
7
- current_branch=`git rev-parse --abbrev-ref HEAD`
8
-
9
- for branch in master $current_branch; do
10
- echo "Testing branch $branch"
11
- git checkout $branch
12
-
13
- echo "Installing gem..."
14
- rake install
15
-
16
- echo "Running benchmark..."
17
- if [ "$benchmark" ]; then
18
- benchmark+=$'\n'
19
- fi
20
- benchmark+=$(viiite run bench/pack_symbols_tmp.rb)
21
- echo
22
- done
23
-
24
- rm bench/pack_symbols_tmp.rb
25
-
26
- echo "$benchmark" | viiite report --regroup bench,reg_type,count,branch
data/bench/unpack.rb DELETED
@@ -1,21 +0,0 @@
1
- require 'viiite'
2
- require 'msgpack'
3
-
4
- data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}])
5
-
6
- Viiite.bench do |b|
7
- b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
8
- b.report(:strings) do
9
- runs.times do
10
- MessagePack.unpack(data)
11
- end
12
- end
13
-
14
- b.report(:symbols) do
15
- options = {:symbolize_keys => true}
16
- runs.times do
17
- MessagePack.unpack(data, options)
18
- end
19
- end
20
- end
21
- end
data/bench/unpack_log.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'viiite'
2
- require 'msgpack'
3
-
4
- data_plain = MessagePack.pack({ 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"' })
5
-
6
- data_structure = MessagePack.pack({
7
- 'remote_host' => '127.0.0.1',
8
- 'remote_user' => '-',
9
- 'date' => '10/Oct/2000:13:55:36 -0700',
10
- 'request' => 'GET /apache_pb.gif HTTP/1.0',
11
- 'method' => 'GET',
12
- 'path' => '/apache_pb.gif',
13
- 'protocol' => 'HTTP/1.0',
14
- 'status' => 200,
15
- 'bytes' => 2326,
16
- 'referer' => 'http://www.example.com/start.html',
17
- 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
18
- })
19
-
20
- Viiite.bench do |b|
21
- b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
22
- b.report(:plain) do
23
- runs.times do
24
- MessagePack.unpack(data_plain)
25
- end
26
- end
27
-
28
- b.report(:structure) do
29
- runs.times do
30
- MessagePack.unpack(data_structure)
31
- end
32
- end
33
- end
34
- end
@@ -1,67 +0,0 @@
1
- # viiite report --regroup bench,threads bench/pack_log_long.rb
2
-
3
- require 'viiite'
4
- require 'msgpack'
5
-
6
- data_plain = MessagePack.pack({
7
- 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"'
8
- })
9
- data_structure = MessagePack.pack({
10
- 'remote_host' => '127.0.0.1',
11
- 'remote_user' => '-',
12
- 'date' => '10/Oct/2000:13:55:36 -0700',
13
- 'request' => 'GET /apache_pb.gif HTTP/1.0',
14
- 'method' => 'GET',
15
- 'path' => '/apache_pb.gif',
16
- 'protocol' => 'HTTP/1.0',
17
- 'status' => 200,
18
- 'bytes' => 2326,
19
- 'referer' => 'http://www.example.com/start.html',
20
- 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
21
- })
22
-
23
- seconds = 3600 # 1 hour
24
-
25
- Viiite.bench do |b|
26
- b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
27
- b.report(:plain) do
28
- ths = []
29
- end_at = Time.now + seconds
30
- threads.times do
31
- t = Thread.new do
32
- packs = 0
33
- while Time.now < end_at
34
- 10000.times do
35
- MessagePack.unpack(data_plain)
36
- end
37
- packs += 10000
38
- end
39
- packs
40
- end
41
- ths.push t
42
- end
43
- sum = ths.reduce(0){|r,t| r + t.value }
44
- puts "MessagePack.unpack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
45
- end
46
-
47
- b.report(:structure) do
48
- ths = []
49
- end_at = Time.now + seconds
50
- threads.times do
51
- t = Thread.new do
52
- packs = 0
53
- while Time.now < end_at
54
- 10000.times do
55
- MessagePack.unpack(data_structure)
56
- end
57
- packs += 10000
58
- end
59
- packs
60
- end
61
- ths.push t
62
- end
63
- sum = ths.reduce(0){|r,t| r + t.value }
64
- puts "MessagePack.unpack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
65
- end
66
- end
67
- end