Skip to content

Do not unmarshal API requests #4078

Description

@cthulhu-rider

Is your feature request related to a problem? Please describe.

efficiency of gRPC deserialization leaves much to be desired. We've optimized handling of response messages and gained visible performance impact

any request is a protobuf message. When server accepts API call, it:

  1. allocates buffer (each one is up to 16K, multiple buffers can be needed)
  2. reads network data into it
  3. unmarshals message and passes it into registered handler like
    func (s *Server) HeadBuffered(ctx context.Context, req *protoobject.HeadRequest) any {

so, we can make similar optimizations made for responses

Describe the solution you'd like

  1. accept binary buffer list in handler
  2. iterate over its fields checking whether we face a valid protobuf and making insta app checks (CID/OID, header, tokens, etc.)
  3. memorize data needed for further processing

primitive data like CID/OID can be caught and left on stack. Structures like bearer token or object header can be transmitted in binary format. For example, we could save object header as BLOB. Or scan bearer token rules w/o allocs. Or, if new messages with same fields will be needed, we can make simple memcpy w/o extra decode-encode round

the code will definitely become more complicated. But we'll get rid of many allocations and increase RPS

it's easier to start with simpler queries like HEAD

Additional context

nspcc-dev/neofs-sdk-go#818

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I4No visible changesS3Minimally significantU4Nothing urgentenhancementImproving existing functionalityneofs-storageStorage node application issuesperformanceMore of something per second

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions