Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3864

Reuse heap allocations of handler results

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Go - Compiler, Go - Library
    • Labels:
      None

      Description

      I have a service (Golang) with a handler that returns a large slice. A new one is allocated every time, resulting in large heap allocations per client call, while it could be reused through a sync.Pool and improve the overall performance through fewer GC calls.

      (.thrift example)
      struct Slice {
      1: required list<Element> element
      }
      service MyService {
      Slice GetSlice() throws (...)
      }

      I have experimented with modifying the auto-generated code and got this functionality through adding a
      (.go) pool.Put(*Slice) // adding the newly generated return value to a pool)
      call in https://github.com/apache/thrift/blob/master/compiler/cpp/src/generate/t_go_generator.cc#L2798 but doing so creates a nasty dependency between the handler and the processor.

      Modifying the signature of the handler should also work
      (.go) GetSlice(*Slice) (*Slice, error)
      but does breaks all compatibility with previous compilers...

      Has some solution to this problem been explored?
      If nothing else some optional Release(retval) after oprot.Flush() in https://github.com/apache/thrift/blob/master/compiler/cpp/src/generate/t_go_generator.cc#L2798 would be very helpful

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              JavierZunzunegui Javier Zunzunegui

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment