Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework: make PMR permeate the nlohmann JSON parser #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guoci
Copy link

@guoci guoci commented Dec 26, 2024

From: https://youtu.be/R5PHRY5Pnlg?si=eSqaT0wj4_bGwHNi&t=949

  • I used a stateless allocator method and left the nlohmann JSON library unmodified.
  • This allows the std::pmr::memory_resource instance to permeate the nlohmann JSON parser, and std::pmr::polymorphic_allocator is not involved.
  • There are some improvements in parsing speed over the default parse.
Benchmark                                                                        Time             CPU   Iterations UserCounters...
----------------------------------------------------------------------------------------------------------------------------------
JSON_Perf/nlohmann_JSON_Default-"citm_catalog.json"                       17851651 ns     17780746 ns           36 bytes_per_second=92.639Mi/s
JSON_Perf/nlohmann_JSON_MBR_stateless_alloc-"citm_catalog.json"           14170186 ns     14104444 ns           47 bytes_per_second=116.785Mi/s
JSON_Perf/nlohmann_JSON_MBR_stateless_alloc_devirt-"citm_catalog.json"    11097326 ns     11069338 ns           59 bytes_per_second=148.807Mi/s
JSON_Perf/nlohmann_JSON_Default-"gsoc-2018.json"                          39429436 ns     39326477 ns           21 bytes_per_second=80.7005Mi/s
JSON_Perf/nlohmann_JSON_MBR_stateless_alloc-"gsoc-2018.json"              37385009 ns     37279595 ns           22 bytes_per_second=85.1315Mi/s
JSON_Perf/nlohmann_JSON_MBR_stateless_alloc_devirt-"gsoc-2018.json"       39008590 ns     38931608 ns           18 bytes_per_second=81.519Mi/s
JSON_Perf/nlohmann_JSON_Default-"github_events.json"                       1073415 ns      1071191 ns          607 bytes_per_second=57.9866Mi/s
JSON_Perf/nlohmann_JSON_MBR_stateless_alloc-"github_events.json"            752468 ns       750393 ns         1019 bytes_per_second=82.7762Mi/s
JSON_Perf/nlohmann_JSON_MBR_stateless_alloc_devirt-"github_events.json"     724156 ns       722657 ns          954 bytes_per_second=85.9532Mi/s```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant