stevejgordon / ElasticSearchClient

A work in progress playground for a low alloc, high performance, low-level ElasticSearch client. Not intended for production!!
12 stars 1 forks source link

You asked for comments regarding your approach #1

Open Tornhoof opened 5 years ago

Tornhoof commented 5 years ago
  1. Change all those readonly static byte[] property names to use be ReadOnlySpan<byte> properties e.g. https://github.com/stevejgordon/ElasticSearchClient/blob/e57df08eb9aed61fcf607dd8a06e1a467e6ae5c5/src/ElasticSearch.LowLevel/BulkResponseParser.cs#L14 see https://vcsjones.com/2019/02/01/csharp-readonly-span-bytes-static/ for a detailed description.
  2. You probably want to set the buffer for json to something larger than 1024, the costs for a larger buffer are then amortized over time. This depends on you how often you expect errors and if the JSON really has a layout where your error property is fairly early (e.g. first loop), but I don't know how far that is guaranteed.
  3. About your Utf8JsonReader approach, you might want to look at https://github.com/aspnet/AspNetCore/blob/master/src/SignalR/common/Http.Connections.Common/src/NegotiateProtocol.cs#L93 on how they do it (it's afaik the first "production" use of the Ut8fJsonReader), e.g. they use jsonReader.CheckRead instead of Read()
stevejgordon commented 5 years ago

Thanks, @Tornhoof - Sorry for the delay. Didn't see a notification for this!

Great tips and references, thanks!