1# Protobuf Performance 2The following benchmark test results were produced on a workstation utilizing an Intel® Xeon® Processor E5-2630 with 32GB of RAM. 3 4This table contains the results of three separate languages: 5 6* **C++** - For C++, there are three parsing methods: 7 * **new** - This is for using a new operator for creating a message instance. 8 * **new arena** - This is for using arena for creating a new message instance. 9 * **reuse** - This is for reusing the same message instance for parsing. 10* **Java** - For Java, there are three parsing/serialization methods: 11 * **byte[]** - This is for parsing from a Byte Array. 12 * **ByteString** - This is for parsing from a 13 com.google.protobuf.ByteString. 14 * **InputStream** - This is for parsing from an InputStream. 15* **Python** - For Python, there are three types of Python protobuf for testing: 16 * **C++-generated-code** - This is for using C++ generated code of the 17 proto file as a dynamic linked library. 18 * **C++-reflection** - This is for using C++ reflection, for which there's no 19 generated code, but still using C++ protobuf library as a dynamic linked 20 library. 21 * **pure-Python** - This is for the pure version of Python, which does not link with 22 any C++ protobuf library. 23 24## Parsing performance 25 26<table> 27<tbody><tr> 28<th rowspan="2"> </th> 29<th colspan="3" rowspan="1">C++</th> 30<th colspan="3" rowspan="1">C++ with tcmalloc</th> 31<th colspan="3" rowspan="1">java</th> 32<th colspan="3" rowspan="1">python</th> 33</tr> 34<tr> 35<th colspan="1">new</th> 36<th colspan="1">new arena</th> 37<th colspan="1">reuse</th> 38<th colspan="1">new</th> 39<th colspan="1">new arena</th> 40<th colspan="1">reuse</th> 41<th colspan="1">byte[]</th> 42<th colspan="1">ByteString</th> 43<th colspan="1">InputStream</th> 44<th colspan="1">C++-generated-code</th> 45<th colspan="1">C++-reflection</th> 46<th colspan="1">pure-Python</th> 47</tr> 48<tr> 49<td>google_message1_proto2</td> 50<td>368.717MB/s</td> 51<td>261.847MB/s</td> 52<td>799.403MB/s</td> 53<td>645.183MB/s</td> 54<td>441.023MB/s</td> 55<td>1.122GB/s</td> 56<td>425.437MB/s</td> 57<td>425.937MB/s</td> 58<td>251.018MB/s</td> 59<td>82.8314MB/s</td> 60<td>47.6763MB/s</td> 61<td>3.76299MB/s</td> 62</tr> 63<tr> 64<td>google_message1_proto3</td> 65<td>294.517MB/s</td> 66<td>229.116MB/s</td> 67<td>469.982MB/s</td> 68<td>434.510MB/s</td> 69<td>394.701MB/s</td> 70<td>591.931MB/s</td> 71<td>357.597MB/s</td> 72<td>378.568MB/s</td> 73<td>221.676MB/s</td> 74<td>82.0498MB/s</td> 75<td>39.9467MB/s</td> 76<td>3.77751MB/s</td> 77</tr> 78<tr> 79<td>google_message2</td> 80<td>277.242MB/s</td> 81<td>347.611MB/s</td> 82<td>793.67MB/s</td> 83<td>503.721MB/s</td> 84<td>596.333MB/s</td> 85<td>922.533MB/s</td> 86<td>416.778MB/s</td> 87<td>419.543MB/s</td> 88<td>367.145MB/s</td> 89<td>241.46MB/s</td> 90<td>71.5723MB/s</td> 91<td>2.73538MB/s</td> 92</tr> 93<tr> 94<td>google_message3_1</td> 95<td>213.478MB/s</td> 96<td>291.58MB/s</td> 97<td>543.398MB/s</td> 98<td>539.704MB/s</td> 99<td>717.300MB/s</td> 100<td>927.333MB/s</td> 101<td>684.241MB/s</td> 102<td>704.47MB/s</td> 103<td>648.624MB/s</td> 104<td>209.036MB/s</td> 105<td>142.356MB/s</td> 106<td>15.3324MB/s</td> 107</tr> 108<tr> 109<td>google_message3_2</td> 110<td>672.685MB/s</td> 111<td>802.767MB/s</td> 112<td>1.21505GB/s</td> 113<td>985.790MB/s</td> 114<td>1.136GB/s</td> 115<td>1.367GB/s</td> 116<td>1.54439GB/s</td> 117<td>1.60603GB/s</td> 118<td>1.33443GB/s</td> 119<td>573.835MB/s</td> 120<td>314.33MB/s</td> 121<td>15.0169MB/s</td> 122</tr> 123<tr> 124<td>google_message3_3</td> 125<td>207.681MB/s</td> 126<td>140.591MB/s</td> 127<td>535.181MB/s</td> 128<td>369.743MB/s</td> 129<td>262.301MB/s</td> 130<td>556.644MB/s</td> 131<td>279.385MB/s</td> 132<td>304.853MB/s</td> 133<td>107.575MB/s</td> 134<td>32.248MB/s</td> 135<td>26.1431MB/s</td> 136<td>2.63541MB/s</td> 137</tr> 138<tr> 139<td>google_message3_4</td> 140<td>7.96091GB/s</td> 141<td>7.10024GB/s</td> 142<td>9.3013GB/s</td> 143<td>8.518GB/s</td> 144<td>8.171GB/s</td> 145<td>9.917GB/s</td> 146<td>5.78006GB/s</td> 147<td>5.85198GB/s</td> 148<td>4.62609GB/s</td> 149<td>2.49631GB/s</td> 150<td>2.35442GB/s</td> 151<td>802.061MB/s</td> 152</tr> 153<tr> 154<td>google_message3_5</td> 155<td>76.0072MB/s</td> 156<td>51.6769MB/s</td> 157<td>237.856MB/s</td> 158<td>178.495MB/s</td> 159<td>111.751MB/s</td> 160<td>329.569MB/s</td> 161<td>121.038MB/s</td> 162<td>132.866MB/s</td> 163<td>36.9197MB/s</td> 164<td>10.3962MB/s</td> 165<td>8.84659MB/s</td> 166<td>1.25203MB/s</td> 167</tr> 168<tr> 169<td>google_message4</td> 170<td>331.46MB/s</td> 171<td>404.862MB/s</td> 172<td>427.99MB/s</td> 173<td>589.887MB/s</td> 174<td>720.367MB/s</td> 175<td>705.373MB/s</td> 176<td>606.228MB/s</td> 177<td>589.13MB/s</td> 178<td>530.692MB/s</td> 179<td>305.543MB/s</td> 180<td>174.834MB/s</td> 181<td>7.86485MB/s</td> 182</tr> 183</tbody></table> 184 185## Serialization performance 186 187<table> 188<tbody><tr> 189<th rowspan="2"> </th> 190<th colspan="1" rowspan="2">C++</th> 191<th colspan="1" rowspan="2">C++ with tcmalloc</th> 192<th colspan="3" rowspan="1">java</th> 193<th colspan="3" rowspan="1">python</th> 194</tr> 195<tr> 196<th colspan="1">byte[]</th> 197<th colspan="1">ByteString</th> 198<th colspan="1">InputStream</th> 199<th colspan="1">C++-generated-code</th> 200<th colspan="1">C++-reflection</th> 201<th colspan="1">pure-Python</th> 202</tr> 203<tr> 204<td>google_message1_proto2</td> 205<td>1.39698GB/s</td> 206<td>1.701GB/s</td> 207<td>1.12915GB/s</td> 208<td>1.13589GB/s</td> 209<td>758.609MB/s</td> 210<td>260.911MB/s</td> 211<td>58.4815MB/s</td> 212<td>5.77824MB/s</td> 213</tr> 214<tr> 215<td>google_message1_proto3</td> 216<td>959.305MB/s</td> 217<td>939.404MB/s</td> 218<td>1.15372GB/s</td> 219<td>1.07824GB/s</td> 220<td>802.337MB/s</td> 221<td>239.4MB/s</td> 222<td>33.6336MB/s</td> 223<td>5.80524MB/s</td> 224</tr> 225<tr> 226<td>google_message2</td> 227<td>1.27429GB/s</td> 228<td>1.402GB/s</td> 229<td>1.01039GB/s</td> 230<td>1022.99MB/s</td> 231<td>798.736MB/s</td> 232<td>996.755MB/s</td> 233<td>57.9601MB/s</td> 234<td>4.09246MB/s</td> 235</tr> 236<tr> 237<td>google_message3_1</td> 238<td>1.31916GB/s</td> 239<td>2.049GB/s</td> 240<td>991.496MB/s</td> 241<td>860.332MB/s</td> 242<td>662.88MB/s</td> 243<td>1.48625GB/s</td> 244<td>421.287MB/s</td> 245<td>18.002MB/s</td> 246</tr> 247<tr> 248<td>google_message3_2</td> 249<td>2.15676GB/s</td> 250<td>2.632GB/s</td> 251<td>2.14736GB/s</td> 252<td>2.08136GB/s</td> 253<td>1.55997GB/s</td> 254<td>2.39597GB/s</td> 255<td>326.777MB/s</td> 256<td>16.0527MB/s</td> 257</tr> 258<tr> 259<td>google_message3_3</td> 260<td>650.456MB/s</td> 261<td>1.040GB/s</td> 262<td>593.52MB/s</td> 263<td>580.667MB/s</td> 264<td>346.839MB/s</td> 265<td>123.978MB/s</td> 266<td>35.893MB/s</td> 267<td>2.32834MB/s</td> 268</tr> 269<tr> 270<td>google_message3_4</td> 271<td>8.70154GB/s</td> 272<td>9.825GB/s</td> 273<td>5.88645GB/s</td> 274<td>5.93946GB/s</td> 275<td>2.44388GB/s</td> 276<td>5.9241GB/s</td> 277<td>4.05837GB/s</td> 278<td>876.87MB/s</td> 279</tr> 280<tr> 281<td>google_message3_5</td> 282<td>246.33MB/s</td> 283<td>443.993MB/s</td> 284<td>283.278MB/s</td> 285<td>259.167MB/s</td> 286<td>206.37MB/s</td> 287<td>37.0285MB/s</td> 288<td>12.2228MB/s</td> 289<td>1.1979MB/s</td> 290</tr> 291<tr> 292<td>google_message4</td> 293<td>1.56674GB/s</td> 294<td>2.19601GB/s</td> 295<td>776.907MB/s</td> 296<td>770.707MB/s</td> 297<td>702.931MB/s</td> 298<td>1.49623GB/s</td> 299<td>205.116MB/s</td> 300<td>8.93428MB/s</td> 301</tr> 302</tbody></table> 303 304\* The cpp performance can be improved by using [tcmalloc](https://gperftools.github.io/gperftools/tcmalloc.html), please follow the (instruction)[https://github.com/protocolbuffers/protobuf/blob/master/benchmarks/README.md] to link with tcmalloc to get the faster result. 305