Skip to content

es6/es7 clients triple-parse every scroll page (serialize→re-parse removed for es8/es9 in #227) #228

Description

@fupelaqu

The es6 and es7 clients still process every scroll / search_after page in three passes: the client library parses the HTTP response into its typed form, the bridge re-serializes that typed form to a JSON string, and core parseResponse re-parses the string into the Jackson tree the row parser actually consumes. PR #227 removed this triple pass for es8/es9 (document type ObjectNode + TokenBuffer, single parse), where it was measured at ~19% of Flight sidecar CPU during JOIN leg extraction (softclient4es-arrow#160) — a cost that scales with the number and width of the selected columns, string columns worst.

Evidence

  • es7 RESTes7/rest/src/main/scala/app/softnetwork/elastic/client/rest/RestHighLevelClientApi.scala:1672 and :1810: extractHitsOnly(response.toString, …). The RHLC parsed the HTTP response into its typed SearchResponse (pass 1); response.toString re-serializes it via XContent (pass 2); core parseResponse re-parses with Jackson (pass 3).
  • es6 RESTes6/rest/src/main/scala/app/softnetwork/elastic/client/rest/RestHighLevelClientApi.scala:1639 plus extractAllResults at :1493/:1528: same shape.
  • es6 Jestes6/jest/src/main/scala/app/softnetwork/elastic/client/jest/JestScrollApi.scala:218 (and the extractAllResults call sites at :83/:112): result.getJsonObject.toString — Gson already parsed the response (pass 1), .toString re-serializes it (pass 2), Jackson re-parses (pass 3).

Why the #227 technique does not transplant directly

The es8/es9 fix re-parents already-parsed Jackson _source trees into the envelope. RHLC holds XContent objects and Jest holds a Gson tree — there is no Jackson node to re-parent. Candidate approaches, per client:

  • es7 / es6 REST: issue the paging search/scroll over the RHLC's low-level RestClient and Jackson-parse the raw response entity bytes once → parseSingleSearchResponse (the node-level core entry perf(client): parse each Elasticsearch page once on the scroll hits path (softclient4es-arrow#160) #227 already uses). This removes even the typed parse — one pass total. The typed request builders can still build the request body; only the response side changes. Care: shard-failure checks and _scroll_id/sort cursor extraction currently read the typed response and would need to read the tree instead.
  • es6 Jest: check whether JestResult.getJsonString retains the raw response body — if so, getJsonString → Jackson readTree drops the Gson re-serialization for a one-line win (two parses instead of three). The full fix is a direct Gson→Jackson tree walk (no string at all), or bypassing Jest's Gson parse for the scroll action.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions