Skip to content

Slow BsonDocumentCodec instantiation while decoding #247

@hborchardt

Description

@hborchardt

Version 4.8.3
Hi, while profiling my application I saw that 50% of the time spent in JacksonCodec.decode() is actually spent constructing an instance of BsonDocumentCodec.

It is constructed here:

protected final BsonJavaScriptWithScopeCodec withScopeCodec = new BsonJavaScriptWithScopeCodec(new BsonDocumentCodec(MongoClientSettings.getDefaultCodecRegistry()));

Having one JsonParserAdapter instance per decode() call makes sense, because it holds parsing state. But I think the withScopeCodec property and its parameters have no state and just static arguments, so withScopeCodec could also be a static variable.

It would be cool to significantly speed up decoding by reusing this instance.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions