Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-4718

Removing unnecessary heap memory allocation in serialization can help reduce GC pressure.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.8.1
    • 3.9.0
    • server

    Description

      For each request, we will serialize it to a byte array.
      In SerializeUtils#serializeRequest, before serializing the request, it always allocates 32 byte array. It's unnecessary; we can allocate the byte array in the catch code block.

          public static byte[] serializeRequest(Request request) {
              if (request == null || request.getHdr() == null) {
                  return null;
              }
              byte[] data = new byte[32];
              try {
                  data = Util.marshallTxnEntry(request.getHdr(), request.getTxn(), request.getTxnDigest());
              } catch (IOException e) {
                  LOG.error("This really should be impossible", e);
              }
              return data;
          }
      

      Attachments

        Issue Links

          Activity

            People

              tison Zili Chen
              horizonzy Yan Zhao
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h