You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stream processing: Unnecessary conversion between datum_t and cJSON #1041
Every json_stream_t stream is expected to return a scoped_cJSON_t. For many operations (most prominently filter I think?) that means that the operation gets a cJSON object, has to convert it into a datum_t, and then convert it back into a cJSON.
It is probably a good idea to avoid this back-and-forth conversion, as especially the conversion to a datum_t is very costly.
I yet have to confirm that this specific behaviour is a bottleneck in any query, so I don't think we should give it a high priority just yet.
An instance of cJSON->datum_t conversion where I actually could confirm that it causes slow queries is #1042 .
However the query tested there didn't actually suffer from the repeated conversion back into a cJSON object, which this issue is about. It could have been circumvented this issue because the expensive getAll() was followed up immediately by a filter which might have removed most of the documents.
Currently implemented in sam_1041 and in code review 837.
This is "done" -- we only convert from datum_t to cJSON when talking to a Javascript process (possibly with little to no convenience benefit, I haven't investigated how we create objects for v8) and we convert from cJSON to datum_t when reading from r.json, presumably. Also we convert to cJSON in parser.cc when doing some HTTP request/response thing.
In other words, I haven't implemented direct json string <-> datum_t conversion.
We still have the streams.hpp and datum_streams.hpp files -- we still have lazy_json_stream_t wrapping the old stream type. The type json_stream_t and everything in streams.hpp now deals with counted_t<datum_t> objects instead of boost::shared_ptr<scoped_cJSON_t>.
I've also changed the vestigial uses of boost::shared_ptr<scoped_cJSON_t> to std::shared_ptr<const scoped_cJSON_t>.
I could take a look at changing the js extproc code to take counted_t<datum_t> instead of shared_ptr<scoped_cJSON_t>, if you want to assign this to me when you're done.
Activity
danielmewes commentedon Jun 19, 2013
An instance of cJSON->datum_t conversion where I actually could confirm that it causes slow queries is #1042 .
However the query tested there didn't actually suffer from the repeated conversion back into a cJSON object, which this issue is about. It could have been circumvented this issue because the expensive getAll() was followed up immediately by a filter which might have removed most of the documents.
coffeemug commentedon Jun 19, 2013
This was a hack that allowed us to convert the old code base to the new one and ship quicker. We're going to take cJSON out (hopefully in 1.8).
srh commentedon Aug 15, 2013
Reassigned to @srh.
srh commentedon Aug 16, 2013
Currently implemented in sam_1041 and in code review 837.
This is "done" -- we only convert from datum_t to cJSON when talking to a Javascript process (possibly with little to no convenience benefit, I haven't investigated how we create objects for v8) and we convert from cJSON to datum_t when reading from
r.json, presumably. Also we convert to cJSON in parser.cc when doing some HTTP request/response thing.In other words, I haven't implemented direct json string <-> datum_t conversion.
We still have the streams.hpp and datum_streams.hpp files -- we still have lazy_json_stream_t wrapping the old stream type. The type json_stream_t and everything in streams.hpp now deals with
counted_t<datum_t>objects instead ofboost::shared_ptr<scoped_cJSON_t>.I've also changed the vestigial uses of
boost::shared_ptr<scoped_cJSON_t>tostd::shared_ptr<const scoped_cJSON_t>.Tryneus commentedon Aug 16, 2013
I could take a look at changing the js extproc code to take
counted_t<datum_t>instead ofshared_ptr<scoped_cJSON_t>, if you want to assign this to me when you're done.srh commentedon Aug 19, 2013
Merged to next as of f6ed6cd.
srh commentedon Aug 19, 2013
For organizational purposes I've put @Tryneus's thing in #1326.