stephenberry / json_performance

Performance profiling of JSON libraries
MIT License
17 stars 11 forks source link

Optimize RapidJSON benchmark #6

Closed Oipo closed 1 year ago

Oipo commented 1 year ago

Although it's "only" about 10% read improvement, it does paint a better picture of the best RapidJSON has to offer. For write, it seems that the noise in measurement makes it hard to paint a clearer picture.

Before:

oipo@oipo-X670E-AORUS-MASTER:~/Programming/json_performance/build$ taskset 0x1 ../json_performance_old 
Glaze json roundtrip: 0.909552 s
Glaze json byte length: 616
Glaze json write: 0.34468 s, 1704.37 MB/s
Glaze json read: 0.476036 s, 1234.07 MB/s

Glaze binary roundtrip: 0.17668 s
Glaze binary byte length: 350
Glaze binary write: 0.082596 s, 4041.19 MB/s
Glaze binary read: 0.089616 s, 3724.63 MB/s

---

simdjson (on demand) json byte length: 617
simdjson (on demand) json read: 0.30734 s, 1914.55 MB/s

---

daw_json_link json roundtrip: 1.9158 s
daw_json_link json byte length: 618
daw_json_link json write: 0.974278 s, 604.931 MB/s
daw_json_link json read: 0.831569 s, 708.745 MB/s

---

RapidJSON json roundtrip: 2.00913 s
RapidJSON json byte length: 694
RapidJSON json write: 1.02072 s, 648.417 MB/s
RapidJSON json read: 0.919124 s, 720.088 MB/s

---

json_struct json roundtrip: 3.41012 s
json_struct json byte length: 616
json_struct json write: 1.81378 s, 323.888 MB/s
json_struct json read: 1.31156 s, 447.911 MB/s

---

nlohmann json roundtrip: 10.2245 s
nlohmann json byte length: 695
nlohmann json write: 4.41752 s, 150.04 MB/s
nlohmann json read: 5.47521 s, 121.055 MB/s

---

Glaze json roundtrip: 2.06549 s
Glaze json byte length: 101297
Glaze json write: 0.436738 s, 2211.95 MB/s
Glaze json read: 1.62964 s, 592.797 MB/s

---

simdjson (on demand) json byte length: 101297
simdjson (on demand) json read: 35.8402 s, 26.9542 MB/s

---

After:

oipo@oipo-X670E-AORUS-MASTER:~/Programming/json_performance/build$ taskset 0x1 ../json_performance_new_insitu 
Glaze json roundtrip: 0.919169 s
Glaze json byte length: 616
Glaze json write: 0.343012 s, 1712.66 MB/s
Glaze json read: 0.495572 s, 1185.42 MB/s

Glaze binary roundtrip: 0.173884 s
Glaze binary byte length: 350
Glaze binary write: 0.082901 s, 4026.32 MB/s
Glaze binary read: 0.08958 s, 3726.12 MB/s

---

simdjson (on demand) json byte length: 617
simdjson (on demand) json read: 0.314004 s, 1873.92 MB/s

---

daw_json_link json roundtrip: 1.99827 s
daw_json_link json byte length: 618
daw_json_link json write: 0.881563 s, 668.552 MB/s
daw_json_link json read: 0.824215 s, 715.069 MB/s

---

RapidJSON json roundtrip: 1.96398 s
RapidJSON json byte length: 694
RapidJSON json write: 1.07056 s, 618.23 MB/s
RapidJSON json read: 0.811009 s, 816.082 MB/s

---

json_struct json roundtrip: 3.39369 s
json_struct json byte length: 616
json_struct json write: 1.85363 s, 316.926 MB/s
json_struct json read: 1.37011 s, 428.771 MB/s

---

nlohmann json roundtrip: 10.2876 s
nlohmann json byte length: 695
nlohmann json write: 4.46004 s, 148.609 MB/s
nlohmann json read: 5.51013 s, 120.288 MB/s

---

Glaze json roundtrip: 2.0633 s
Glaze json byte length: 101297
Glaze json write: 0.436987 s, 2210.69 MB/s
Glaze json read: 1.62957 s, 592.821 MB/s

---

simdjson (on demand) json byte length: 101297
simdjson (on demand) json read: 34.0108 s, 28.404 MB/s

---
stephenberry commented 1 year ago

Thanks for this pull request! I optimized it more by eliminating a string allocation.