Skip to content

Stream processing: Unnecessary conversion between datum_t and cJSON #1041

Closed

Description

@danielmewes

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.

Activity

  1. danielmewes commented on Jun 19, 2013

    @danielmewes
    MemberAuthor

    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.

  2. coffeemug commented on Jun 19, 2013

    @coffeemug
    Contributor

    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).

  3. ghost assigned on Jul 27, 2013
  4. ghost assigned on Aug 15, 2013
  5. srh commented on Aug 15, 2013

    @srh
    Contributor

    Reassigned to @srh.

  6. srh commented on Aug 16, 2013

    @srh
    Contributor

    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>.

  7. Tryneus commented on Aug 16, 2013

    @Tryneus
    Member

    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.

  8. srh commented on Aug 19, 2013

    @srh
    Contributor

    Merged to next as of f6ed6cd.

  9. srh commented on Aug 19, 2013

    @srh
    Contributor

    For organizational purposes I've put @Tryneus's thing in #1326.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions