Skip to content

JsonpUtils#objectParser toString roundtrip to deserialise object uses ~30%more CPU #471

Closed
@pchudzik

Description

@pchudzik

Java API client version

<= 7.17

Java version

17

Elasticsearch Version

7.17 and 8.5

Problem description

Hey

I'm in the process of migrating from the old elastic search client that has been deprecated.

While testing we've noticed higher CPU load when running servers.

From observations I'd say ~30% higher cpu load to what we have with deprecated client.
If we decide to pull the trigger on migration it'll mean we'll have to run more replicas of the service which is talking to elastic and it means more $$$ we'll have to spend on infrastructure.

We use multi search requests which I think is important at this point as running regular search requests has no performance penalty.

Looking at profiler cpu sampling I've noticed that around 30% of deserialising multi search response is spend in co.elastic.clients.json.JsonpUtils#objectParser and current implementation of this method is some kind of a workaround put in there around one year ago:

String strObject = object.toString();
return mapper.jsonProvider().createParser(new StringReader(strObject));

This is not very CPU friendly (and as a result cost effective implementation).

I'm wondering if this workaround is still necessary or if there is any better way of doing this now.

I'll be happy to do some testing but at this point I think I know too little about json providers, factories, parsers, mappers and other things that are going on with json serialisation and deserialisation to be of any real help.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions