build(json): migrate nlohmann/json → Glaze v7.6.0 (~9-15x parse speedup)#7
Merged
Conversation
…dup)
Replaces the nlohmann/json v3.11.3 FetchContent dep with Glaze v7.6.0.
The public client surface (CDOClient::get_*, DataServiceClient::get_*,
parse_csv_data / parse_ssv_data) is unchanged; internal
`from_json(const nlohmann::json&, T&)` overloads and the transitional
`json_string` / `json_int` / `json_double` / `json_bool` helpers are
replaced with `deserialize_<T>(std::string_view, T&) -> Result<void>`
in the `ncei::` namespace.
Static-shape model structs (Dataset, DataCategory, DataType,
LocationCategory, Location, CDOStation, DataRecord, DatasetField,
DatasetMetadata, DataSearchResult, DatasetSearchResult) get
`glz::meta` specializations in their per-model `.cpp` files. The CDO
list-response envelope (`{metadata: {resultset: {...}}, results:
[...]}`) is parsed via a single templated meta in the internal-only
`src/models/pagination_detail.hpp` — every endpoint shares it. The
DataPoint family (user-driven TMAX/TMIN/PRCP columns -> attribute
pairs) uses `glz::generic` AST walking and is flagged with
`TODO(glaze):` markers.
`ncei::detail::kReadOpts` carries the CDO-friendly opts combo
(`error_on_unknown_keys = false` + `skip_null_members_on_read = true`)
since Glaze v7.6.0's `glz::opts` doesn't ship `skip_null_members_on_read`
as a base-struct member.
Benchmark (x86_64-v3, GCC 13.3, -O3 -DNDEBUG, 21 KB CDO stations
envelope, 1k iters):
- nlohmann/json v3.11.3 : ~360-590 us/op (pre-migration baseline)
- glaze v7.6.0 : ~32-40 us/op (post-migration)
- speedup : 9-15x
Removed `src/core/pagination.cpp` (its `from_json(ResultSetMetadata)`
overload is now redundant — the templated envelope meta handles it).
Added `tests/glaze_test.cpp` (parse-shape parity) and
`tests/parse_benchmark.cpp` (200 us/op regression cap, 30s ctest
timeout).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
common_glaze_detail.hpp+pagination_detail.hpp(templatedglz::meta<CDOResponseEnvelope<T>>)from_response) ported toglz::genericdispatchCDOClient/DataServiceClientAPI unchangedBenchmark
x86_64-v3, GCC 13.3, -O3 -DNDEBUG, 21 KB CDO
/stations?limit=100envelope, 1k iters:glz::generic fallbacks
DataPoint/DataPointCollection— user-driven TMAX/TMIN/PRCP/SNOW columns sit as siblings to fixed DATE/STATION keys, no staticglz::metapossible. TaggedTODO(glaze):.core/error.cpp::from_response— 3 error shapes (CDO + Data Service + RFC 7807) dispatched via runtime branching.Test plan
make format && make lint && cmake --build build && ctest --output-on-failure166/166 passcpp_auto_auditclean