Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-1788

reduce copies on read, write paths

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 1.0.0
    • None
    • None

    Description

      Currently, we do three unnecessary copies (that is, writing to the socket is necessary; any other copies made are overhead) for each message:

      • constructing the Message body byte[] (this is typically a call to a ICompactSerializer[2] serialize method, but sometimes we cheat e.g. in SchemaCheckVerbHandler's reply)
      • which is copied to a buffer containing the entire Message (i.e. including Header) when sendOneWay calls Message.serializer.serialize()
      • which is copied to a newly-allocated ByteBuffer when sendOneWay calls packIt
      • which is what we write to the socket

      For deserialize we perform a similar orgy of copies:

      • IncomingTcpConnection reads the Message length, allocates a byte[], and reads the serialized Message into it
      • ITcpC then calls Message.serializer().deserialize, which allocates a new byte[] for the body and copies that part
      • finally, the verbHandler (determined by the now-deserialized Message header) deserializes the actual object represented by the body

      Most of these are out of scope for 0.7 but I think we can at least elide the last copy on the write path and the first on the read.

      Attachments

        1. 1788.txt
          7 kB
          Jonathan Ellis
        2. 1788-v2.txt
          13 kB
          Jonathan Ellis
        3. 1788-v3.txt
          13 kB
          Jonathan Ellis
        4. 1788-v4.txt
          13 kB
          Jonathan Ellis
        5. 1788-v6.txt
          38 kB
          Jonathan Ellis
        6. 1788-v7.txt
          37 kB
          Brandon Williams
        7. ASF.LICENSE.NOT.GRANTED--0001-setup.txt
          11 kB
          Jonathan Ellis
        8. ASF.LICENSE.NOT.GRANTED--0002-remove-copies-from-network-path.txt
          18 kB
          Jonathan Ellis

        Activity

          People

            jbellis Jonathan Ellis
            jbellis Jonathan Ellis
            Jonathan Ellis
            Brandon Williams
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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