Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1282

Make use of the sun.misc.Unsafe class during serialization if a JDK supports it



    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.4
    • Fix Version/s: 1.7.5, 1.8.0
    • Component/s: java
    • Labels:


      Unsafe can be used to significantly speed up serialization process, if a JDK implementation supports java.misc.Unsafe properly. Most JDKs running on PCs support it. Some platforms like Android lack a proper support for Unsafe yet.

      There are two possibilities to use Unsafe for serialization:
      1) Very quick access to the fields of objects. It is way faster than with the reflection-based approach using Field.get/set

      2) Input and Output streams can be using Unsafe to perform very quick input/output.

      3) More over, Unsafe makes it possible to serialize to/deserialize from off-heap memory directly and very quickly, without any intermediate buffers allocated on heap. There is virtually no overhead compared to the usual byte arrays.


        1. avro-1282-v1.patch
          33 kB
          Leo Romanoff
        2. avro-1282-v2.patch
          34 kB
          Leo Romanoff
        3. avro-1282-v3.patch
          29 kB
          Leo Romanoff
        4. avro-1282-v4.patch
          46 kB
          Leo Romanoff
        5. avro-1282-v5.patch
          47 kB
          Leo Romanoff
        6. avro-1282-v6.patch
          48 kB
          Leo Romanoff
        7. avro-1282-v7.patch
          45 kB
          Leo Romanoff
        8. avro-1282-v8.patch
          59 kB
          Leo Romanoff
        9. TestUnsafeUtil.java
          2 kB
          Scott Carey
        10. AVRO-1282-s1.patch
          63 kB
          Scott Carey
        11. AVRO-1282-s2.patch
          63 kB
          Scott Carey
        12. AVRO-1282-s3.patch
          66 kB
          Scott Carey
        13. AVRO-1282-s5.patch
          75 kB
          Scott Carey
        14. AVRO-1282-v9.patch
          78 kB
          Leo Romanoff
        15. AVRO-1282-s6.patch
          88 kB
          Scott Carey
        16. AVRO-1282-s7.patch
          88 kB
          Scott Carey

          Issue Links



              • Assignee:
                romixlev Leo Romanoff
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: