Skip to main content
Version: dev

Java Benchmarks

System Environment

  • Operation System:4.9.151-015.x86_64
  • CPU:Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
  • Byte Order:Little Endian
  • L1d cache: 32K
  • L1i cache:32K
  • L2 cache: 1024K
  • L3 cache: 33792K

JMH params

Don't skip warm up, otherwise the results aren't accurate.

 -f 1 -wi 3 -i 3 -t 1 -w 2s -r 2s -rf cs

Benchmark Data

Struct

Struct is a class with 100 primitive fields:

public class Struct {
public int f1;
public long f2;
public float f3;
public double f4;
// ...
public double f99;
}

Struct2

Struct2 is a class with 100 boxed fields:

public class Struct {
public Integer f1;
public Long f2;
public Float f3;
public Double f4;
// ...
public Double f99;
}

MediaContent

MEDIA_CONTENT is a class from jvm-serializers.

Sample

SAMPLE is a class from kryo benchmark

Benchmark Plots

Serialize to heap buffer

Serialize data java byte array.

Java schema consistent serialization

The deserialization peer must have same class definition with the serialization peer. No class forward/backward compatibility are supported in this mode.

Java Heap Schema Consistent Serialization

Java schema compatible serialization

The deserialization peer can have different class definition with the serialization peer. Class forward/backward compatibility are supported in this mode.

Java Heap Schema Compatible Serialization

Java schema consistent deserialization

The deserialization peer must have same class definition with the serialization peer. No class forward/backward compatibility are supported in this mode.

Java Heap Schema Consistent Deserialization

Java schema compatible deserialization

The deserialization peer can have different class definition with the serialization peer. Class forward/backward compatibility are supported in this mode.

Java Heap Schema Compatible Deserialization

Off-heap serialization

Serialize data off-heap memory.

Java schema consistent serialization

The deserialization peer must have same class definition with the serialization peer. No class forward/backward compatibility are supported in this mode.

Java Off Heap Schema Consistent Serialization

Java schema compatible serialization

The deserialization peer can have different class definition with the serialization peer. Class forward/backward compatibility are supported in this mode.

Java Off Heap Schema Compatible Serialization

Java schema consistent deserialization

The deserialization peer must have same class definition with the serialization peer. No class forward/backward compatibility are supported in this mode.

Java Off Heap Schema Consistent Deserialization

Java schema compatible deserialization

The deserialization peer can have different class definition with the serialization peer. Class forward/backward compatibility are supported in this mode.

Java Off Heap Schema Compatible Deserialization

Zero-copy serialization

Note that zero-copy serialization just avoid the copy in serialization, if you send data to other machine, there may be copies.

But if you serialize data between processes on same node and use shared-memory, if the data are in off-heap before serialization, then other processes can read this buffer without any copies.

Java zero-copy serialize to heap buffer

Java Zero Copy Serialization

Java zero-copy serialize to direct buffer

Java Zero Copy Deserialization

Benchmark Data

Java Serialization

BenchmarkobjectTypebufferTypereferencesForyForyMetaSharedKryoFstHessionJdkProtostuff
serializeSTRUCTarrayFalse7501415.567260558194.100861882178.995727258233.998931155908.244240330975.350403
serializeSTRUCTarrayTrue6264439.154428557542.628765757753.756691260845.209485151258.539369
serializeSTRUCTdirectBufferFalse9834223.2432041078046.011115807847.663261266481.009225154875.908438340262.650047
serializeSTRUCTdirectBufferTrue7551780.823133853350.408656762088.935404261762.594966156404.686214
serializeSTRUCT2arrayFalse3586126.623874325172.969175371762.98266156056.08007536846.049162322563.440433
serializeSTRUCT2arrayTrue3306474.506382259863.332448380638.70026760038.87979038183.705811
serializeSTRUCT2directBufferFalse2643155.135327355688.882786365317.70537655924.31944237444.967981325093.716261
serializeSTRUCT2directBufferTrue2391110.083108338960.426033370851.88071156674.06560435798.679246
serializeMEDIA_CONTENTarrayFalse3031642.924542730792.521676751892.023189367782.358049137989.198821780618.761219
serializeMEDIA_CONTENTarrayTrue2250384.600246445251.084327583859.907758329427.470680140260.668888
serializeMEDIA_CONTENTdirectBufferFalse2479862.129632608972.517580728001.080250372477.138150138567.623369805941.345157
serializeMEDIA_CONTENTdirectBufferTrue1938527.588331359875.473951595679.580108353376.085025140158.673910
serializeSAMPLEarrayFalse3570966.4690871105365.931217915907.574306220386.502846118374.836631663272.710783
serializeSAMPLEarrayTrue1767693.835090734215.482291731869.156376192414.014211119858.140625
serializeSAMPLEdirectBufferFalse3684487.7605911376560.302168902302.261168220981.308085118273.584257693641.589806
serializeSAMPLEdirectBufferTrue1826456.709478932887.968348723614.066770211949.960255108263.040839
serialize_compatibleSTRUCTarrayFalse3530406.1088699204444.777172145964.199559258650.663523
serialize_compatibleSTRUCTarrayTrue3293059.0981277064625.291374136180.832879263564.913879
serialize_compatibleSTRUCTdirectBufferFalse2653169.56837411650229.648715106695.800225249221.452137
serialize_compatibleSTRUCTdirectBufferTrue2393817.7629388702412.752357106458.212005263623.143601
serialize_compatibleSTRUCT2arrayFalse2773368.9976802575824.143864125807.74800458509.125342
serialize_compatibleSTRUCT2arrayTrue2564174.5502763543082.528217114983.54634355552.977735
serialize_compatibleSTRUCT2directBufferFalse1912402.9378792714748.57224892130.67236158908.567439
serialize_compatibleSTRUCT2directBufferTrue1848338.9680581866073.03185188989.72476855524.373547
serialize_compatibleMEDIA_CONTENTarrayFalse1679272.0362232992288.235281188911.259146377195.903772
serialize_compatibleMEDIA_CONTENTarrayTrue1406736.5387162058738.716953145782.916427351657.879556
serialize_compatibleMEDIA_CONTENTdirectBufferFalse1710680.9373872291443.556971185363.714829371729.727192
serialize_compatibleMEDIA_CONTENTdirectBufferTrue1149999.4739941804349.244125142836.961878343834.954942
serialize_compatibleSAMPLEarrayFalse3604596.4656254409055.687063378907.663184234454.975158
serialize_compatibleSAMPLEarrayTrue1619648.3372931840705.439334320815.567701206174.173039
serialize_compatibleSAMPLEdirectBufferFalse3484533.2183055043538.364886296102.615094194761.224263
serialize_compatibleSAMPLEdirectBufferTrue1730822.6306481859289.705838276757.392449212840.483308
deserializeSTRUCTarrayFalse4595230.434552607750.343557357887.23531184709.10882129603.066599517381.168594
deserializeSTRUCTarrayTrue4634753.596131552802.227807353480.55403591050.37022429727.744196
deserializeSTRUCTdirectBufferFalse5012002.859236910534.169114352441.59714791151.63358328717.004518538922.947147
deserializeSTRUCTdirectBufferTrue4864329.316938914404.107564334574.30348491037.20590129549.998286
deserializeSTRUCT2arrayFalse1126298.359550275984.042401280131.09106869758.76778314888.805111416212.973861
deserializeSTRUCT2arrayTrue1046649.083082222710.554833260649.30801668616.02924814034.100664
deserializeSTRUCT2directBufferFalse1117586.457565319247.256793262519.85881066866.10865314652.043788425523.315814
deserializeSTRUCT2directBufferTrue1018277.848128249105.828416234973.63709665338.34518514425.886048
deserializeMEDIA_CONTENTarrayFalse2054066.903469577631.234369363455.785182118156.07228438536.250402951662.019963
deserializeMEDIA_CONTENTarrayTrue1507767.206603365530.417232304371.728638120016.59417138957.191090
deserializeMEDIA_CONTENTdirectBufferFalse1502746.028159389473.174523311691.658687111067.94262640512.632076964664.641598
deserializeMEDIA_CONTENTdirectBufferTrue1290593.975753306995.220799251820.171513121820.82126037030.594632
deserializeSAMPLEarrayFalse2069988.624415979173.981159473409.796491119471.51838829309.573998619338.385412
deserializeSAMPLEarrayTrue1797942.442313716438.884369428315.502365121106.00297827466.003923
deserializeSAMPLEdirectBufferFalse2229791.078395983538.936801441027.550809117806.91658928128.457935624804.978534
deserializeSAMPLEdirectBufferTrue1958815.397807762889.302732420523.770904121940.78359728221.014735
deserialize_compatibleSTRUCTarrayFalse2110335.0392754978833.20680678771.63530988617.486795
deserialize_compatibleSTRUCTarrayTrue2135681.9826744807963.88252072805.93764990206.654212
deserialize_compatibleSTRUCTdirectBufferFalse1596464.2481415149070.65783058574.90422589580.561575
deserialize_compatibleSTRUCTdirectBufferTrue1684681.0742425137500.62128860685.32029984407.472531
deserialize_compatibleSTRUCT2arrayFalse849507.1762631201998.14247460602.28574363703.763814
deserialize_compatibleSTRUCT2arrayTrue815120.3191551058423.61415662729.90834769521.573119
deserialize_compatibleSTRUCT2directBufferFalse784036.5893631131212.58695354637.32913469342.030965
deserialize_compatibleSTRUCT2directBufferTrue782679.6620831089162.40816551761.56959168542.055543
deserialize_compatibleMEDIA_CONTENTarrayFalse1441671.7063202279742.810882180882.860363121619.090797
deserialize_compatibleMEDIA_CONTENTarrayTrue1121136.0396271623938.202345154311.211540119994.104050
deserialize_compatibleMEDIA_CONTENTdirectBufferFalse1256034.7325141718098.363961134485.160300107594.474890
deserialize_compatibleMEDIA_CONTENTdirectBufferTrue1054942.7518161333345.536684119311.787329116531.023438
deserialize_compatibleSAMPLEarrayFalse2296046.8958612485564.396196255086.928308121898.105768
deserialize_compatibleSAMPLEarrayTrue1834139.3957572002938.794909238811.995510121297.485903
deserialize_compatibleSAMPLEdirectBufferFalse2308111.6336612289261.533644201993.787890124044.417439
deserialize_compatibleSAMPLEdirectBufferTrue1820490.5856481927548.827586174534.710870120276.449497

Java Zero-copy

Benchmarkarray_sizebufferTypedataTypeForyKryoFst
serialize200arrayBUFFER5123572.9140451985187.9776332400193.220466
serialize200arrayPRIMITIVE_ARRAY8297232.942927147342.606262313986.053417
serialize200directBufferBUFFER5400346.8901261739454.5197702282550.111756
serialize200directBufferPRIMITIVE_ARRAY8335248.350301972683.763633294132.218623
serialize1000arrayBUFFER4979590.9291271616159.6712301805557.477810
serialize1000arrayPRIMITIVE_ARRAY8772856.92102831395.72151467209.107012
serialize1000directBufferBUFFER5376191.7750071377272.5685101644789.427010
serialize1000directBufferPRIMITIVE_ARRAY8207563.785251209183.09086866108.014322
serialize5000arrayBUFFER5018916.322770711287.533377811029.402136
serialize5000arrayPRIMITIVE_ARRAY8027439.5802266248.00696714997.400124
serialize5000directBufferBUFFER5330897.682960707092.956534477148.540850
serialize5000directBufferPRIMITIVE_ARRAY7695981.98831643565.67861615000.378818
deserialize200arrayBUFFER3302149.3831351296284.787720657754.887247
deserialize200arrayPRIMITIVE_ARRAY986136.067809146675.360652219333.990504
deserialize200directBufferBUFFER3113115.4717581004844.498712598421.278941
deserialize200directBufferPRIMITIVE_ARRAY991807.969328518713.299422179604.045774
deserialize1000arrayBUFFER2831942.848999721266.541130422147.154601
deserialize1000arrayPRIMITIVE_ARRAY205671.99273630409.83502353100.903684
deserialize1000directBufferBUFFER3397690.327371592972.713203298929.116572
deserialize1000directBufferPRIMITIVE_ARRAY202275.242341112132.00460938572.001768
deserialize5000arrayBUFFER3296658.120035147251.846111136934.604328
deserialize5000arrayPRIMITIVE_ARRAY40312.5901726122.35122810672.872798
deserialize5000directBufferBUFFER3284441.570594148614.47682977950.612503
deserialize5000directBufferPRIMITIVE_ARRAY40413.74371721826.0404108561.694533