active_model_serializers
active_model_serializers copied to clipboard
Invalid JSON document
Expected behavior vs actual behavior
Expected Behavior
-- create_table("comments", {:force=>:cascade})
-> 0.0066s
-- create_table("posts", {:force=>:cascade})
-> 0.0029s
-- create_table("users", {:force=>:cascade})
-> 0.0017s
Warming up --------------------------------------
ams 2.000 i/100ms
jsonapi-rb 7.000 i/100ms
ams eager 2.000 i/100ms
jsonapi-rb eager 12.000 i/100ms
Calculating -------------------------------------
ams 20.397 (± 1.7%) i/s - 204.000 in 10.097255s
jsonapi-rb 74.981 (± 0.8%) i/s - 756.000 in 10.100857s
ams eager 23.117 (± 0.6%) i/s - 232.000 in 10.047664s
jsonapi-rb eager 125.521 (± 0.8%) i/s - 1.260k in 10.054734s
with 95.0% confidence
Comparison:
jsonapi-rb eager: 125.5 i/s
jsonapi-rb : 75.0 i/s - 1.67x (± 0.02) slower
ams eager: 23.1 i/s - 5.43x (± 0.05) slower
ams : 20.4 i/s - 6.15x (± 0.12) slower
with 95.0% confidence
Calculating -------------------------------------
ams 2.688M memsize ( 188.498k retained)
33.331k objects ( 2.554k retained)
50.000 strings ( 50.000 retained)
jsonapi-rb 1.038M memsize ( 0.000 retained)
11.784k objects ( 0.000 retained)
50.000 strings ( 0.000 retained)
ams eager 2.470M memsize ( 184.410k retained)
30.534k objects ( 2.439k retained)
50.000 strings ( 50.000 retained)
jsonapi-rb eager 715.124k memsize ( 0.000 retained)
7.500k objects ( 0.000 retained)
50.000 strings ( 0.000 retained)
Comparison:
jsonapi-rb eager: 715124 allocated
jsonapi-rb : 1037676 allocated - 1.45x more
ams eager: 2469640 allocated - 3.45x more
ams : 2688112 allocated - 3.76x more
Actual Behavior
-- create_table("comments", {:force=>:cascade})
-> 0.4065s
-- create_table("posts", {:force=>:cascade})
-> 0.3665s
-- create_table("users", {:force=>:cascade})
-> 0.1777s
## [ams] :test_render. Invalid JSON document.
Diff:
"birthday": "2017-07-01 05:00:00 UTC", | "birthday": "2017-06-30 19:00:00 UTC",
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"
"created_at": "2017-07-01 05:00:00 UTC", | "created_at": "2017-06-30 19:00:00 UTC",
"updated_at": "2017-07-01 05:00:00 UTC" | "updated_at": "2017-06-30 19:00:00 UTC"}
Steps to reproduce
[email protected]:rails-api/active_model_serializers.git
cd benchmarks/serialization_libraries
bundle install
bundle exec ruby benchmark.rb
Environment
active_model_serializers (0.10.3)
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
OS Type & Version: Ubuntu 16.06
Hi @wonderer007 Thanks for include more info than in https://github.com/rails-api/active_model_serializers/issues/2248
For what it's worth, It still took me a bit to understand the issue. I think what you mean to say is you got an 'invalid json' error when running the benchmarks on the benchmarks branch. 'Invalid JSON document' could mean anything.
I tried Ruby 2.3.3 and didn't reproduce the issue even when I hard-coded the version to be 0.10.3 like yours. Why are you using such an old version instead of the latest, 0.10.7?
My guess is some other gem you have is different. Try rm -f Gemfile.lock; bundle
Would you share your Gemfile.lock?
What have you tried?
I tried
rm -f Gemfile.lock
bundle
bundle exec ruby benchmark.rb
but result is same
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.6)
actionpack (= 5.1.6)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.6)
actionpack (= 5.1.6)
actionview (= 5.1.6)
activejob (= 5.1.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.6)
actionview (= 5.1.6)
activesupport (= 5.1.6)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.6)
activesupport (= 5.1.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
active_model_serializers (0.10.7)
actionpack (>= 4.1, < 6)
activemodel (>= 4.1, < 6)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (5.1.6)
activesupport (= 5.1.6)
globalid (>= 0.3.6)
activemodel (5.1.6)
activesupport (= 5.1.6)
activerecord (5.1.6)
activemodel (= 5.1.6)
activesupport (= 5.1.6)
arel (~> 8.0)
activesupport (5.1.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (8.0.0)
awesome_print (1.8.0)
benchmark-ips (2.7.2)
benchmark-memory (0.1.2)
memory_profiler (~> 0.9)
builder (3.2.3)
byebug (10.0.2)
case_transform (0.2)
activesupport
coderay (1.1.2)
concurrent-ruby (1.0.5)
crass (1.0.3)
erubi (1.7.1)
fast_jsonapi (1.1.1)
activesupport (>= 4.2)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (1.0.0)
concurrent-ruby (~> 1.0)
jsonapi-deserializable (0.2.0)
jsonapi-rb (0.5.0)
jsonapi-deserializable (~> 0.2.0)
jsonapi-serializable (~> 0.3.0)
jsonapi-renderer (0.2.0)
jsonapi-serializable (0.3.0)
jsonapi-renderer (~> 0.2.0)
kalibera (0.1)
memoist (~> 0.11.0)
rbzip2 (~> 0.2.0)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
memoist (0.11.0)
memory_profiler (0.9.10)
method_source (0.9.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
oj (3.5.0)
oj_mimic_json (1.0.1)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-byebug (3.6.0)
byebug (~> 10.0)
pry (~> 0.10)
rack (2.0.4)
rack-test (1.0.0)
rack (>= 1.0, < 3)
rails (5.1.6)
actioncable (= 5.1.6)
actionmailer (= 5.1.6)
actionpack (= 5.1.6)
actionview (= 5.1.6)
activejob (= 5.1.6)
activemodel (= 5.1.6)
activerecord (= 5.1.6)
activesupport (= 5.1.6)
bundler (>= 1.3.0)
railties (= 5.1.6)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.6)
actionpack (= 5.1.6)
activesupport (= 5.1.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
rbzip2 (0.2.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.20.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
active_model_serializers
awesome_print
benchmark-ips
benchmark-memory
fast_jsonapi
jsonapi-rb
kalibera
oj
oj_mimic_json
pry-byebug
rails (> 5)
sqlite3
BUNDLED WITH
1.16.1
Any stack trace you can share? I can't really debug it if I can't reproduce it.