Slow to_json with oj gem in Rails 4.2
<p>I upgraded my Rails app from Rails 3.2 to Rails 4.2. The to_json performance in my views is terrible. In my Rails 3.2 app I used multi_json and the Oj gem to get great performance. With Rails 4.2 I setup the oj gem this way:</p>

<pre><code>gem 'oj', '~&gt; 2.14', '&gt;= 2.14.2'
gem 'oj_mimic_json', '~&gt; 1.0', '&gt;= 1.0.1'
</code></pre>

<p>However, the to_json performance doesn't seem to be nearly as good as with the Rails 3.2 app. One to_json call takes about 50% of CPU time.</p>

<p>The Oj gem documentation mentions adding:</p>

<pre><code>serialize :metadata, Oj
</code></pre>

<p>to make it work with ActiveRecord. Is this line supposed to go in the models that I use?</p>

<p><a href="https://i.stack.imgur.com/iDwPb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iDwPb.jpg" alt="enter image description here"></a></p>