Consider reading/writing directly from BSON stream to Tuple to limit unnecessary object creation (like HashMap) by the MongoDB driver

Description

GC can slow down reads esp for collections. Many HashMap are created and we suspec the MongoDB driver for Java is the creator (DBObject is a subclass of LinkedHashMap).

We could imagine not create these BObject but directly talk to the BSON stream. That would of course be a lot of work to do that right and the MongoDB driver needs to expose BSON without parsing it first.

It more a prospective idea.

Environment

None

Activity

Show:
Sanne Grinovero
November 28, 2017, 10:22 AM

as I said above, have a look at what we did for the Infinispan / Hot Rod ("infinispan remote") dialect. It's a very similar optimisation.

Sergey Chernolyas
November 28, 2017, 10:50 AM

Hi !

Ok. I will investigate your solution.

Sergey Chernolyas
December 6, 2017, 2:02 PM

Hi colleagues!

I have some results of investigation. I describe my things. Any ideas welcome!
Main problem in the method "decode" of class below

Problem is I don't know what type is loaded. It leads to problem with mapping between field "_id" and field with annotation @Id .
I see next ways:

  1. I can prepare not fully initialized Tuple by reading BsonReader. Initialization will finished in method "getTuple" (and the like)

  2. I can add new field "_type". But .... it leads to problem if json not contains the field

Any ideas or advises are welcome

Sergey Chernolyas
December 7, 2017, 5:43 AM

Hi colleagues!

We need some object-mediator anyway.

Sanne Grinovero
December 7, 2017, 8:39 AM

Hi

sure having some intermediate objects might be necessary; we want to minimize them but a couple might be acceptable - especially as a starting point.

The main idea is to avoid JSON encoding and use BSON directly to explore performance tradeoffs caused by the serialization layer.

Assignee

Sergey Chernolyas

Reporter

Emmanuel Bernard

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

Yes, likely

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Priority

Minor
Configure