Skip to content

Commit c806e95

Browse files
lemireDaniel LemireFranciscoThiesen
authored
C++26 static reflection (simdjson#2282)
* Initial work on JSON builder * moving the files back to ondemand for now. * tweak * more later * update * minor edits * dropping vs arm (missing support) * adding tests. we still specialized write_string_escaped * tweaking * fix typo * tweaking the approach * minor fix * missing store * another missing store * Attempt at fixing failing serialization tests. (simdjson#2292) * Fixing appeand_float typo (simdjson#2294) * applying a couple of fixes * updating single header * fix for pre C++17 if constexpr * Fixing unused argument problem and updating the singleheader file * various pedantic fixes * Sketch of builder * reordering. * simplify * Adding draft of static reflection based deserialization * Updating simdjson singleheader * patching the automated deserialization. * automated * Adding support for smart pointers of user defined types. * Adding specialization for smart pointers for basic types. I think it is highly likely that this can be done in a more generic way. * Referncing a later version of rapidjson that fixed the issue related with assignment attempt of a const variable for GenericStringRef class. * guarding the tests * adding documentation for string_builder * saving * rename to 'append' * saving * non-functional benchmarks (simdjson#2342) * non-functional benchmarks * Fix typo * various fixes * tweaking --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> Co-authored-by: Francisco Geiman Thiesen <franciscogthiesen@gmail.com> * tuning * various minor fixes * minor tweak * minor simplification * updating amal * adding a cast * update * fancy casting * removing dead code * Pushing latest changes. CITM benchmark is still not working. * Still not working, but now I am getting only 10 errors. * add static reflection benchmark to 'large random' benchmark and allows (simdjson#2349) deserialization (with static reflection) from objects and arrays. Co-authored-by: Daniel Lemire <dlemire@lemire.me> * Removing std::map from CitmCatalog definition, since that is not currently supported. * Added free to rust bench, segfault is still happening.. * The syntax changed: ^E became ^^E. (simdjson#2350) * The syntax changed: ^E became ^^E. * guarding --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> * Adding support for string_view_keyed_map types. * Adding concepts as a conditional include. * updating single-header * Adding concepts to ondemand deps * rust benchmark is finally working * Fixing small typo in docs. * adding docker config and instructions so that our users can test the static reflection (simdjson#2358) * adding docker config and instructions so that our users can test the static reflection * completing the instructions * pruning white spaces --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> * minor optimizations on the JSON builder branch * avoiding undef behaviour * saving * somewhat nicer builder * make it possible to run just one benchmark * adding linux perf * fixing minor issue * updating swar * Adding real world compilation benchmark (simdjson#2379) * Adding compilation benchmark for json parsing with and without reflection * Moving it to the benchmark folder, also reducing a bit the number of iterations. * Removing script from root folder. * Reducing number of iterations * Update benchmark/benchmark_reflection_usage_compilation.sh Co-authored-by: Daniel Lemire <daniel@lemire.me> * Update benchmark/benchmark_reflection_usage_compilation.sh Co-authored-by: Daniel Lemire <daniel@lemire.me> * Update benchmark/benchmark_reflection_usage_compilation.sh Co-authored-by: Daniel Lemire <daniel@lemire.me> * Making the script more customizable and also test whether the compiler being used supports reflection before actually running the benchmark --------- Co-authored-by: Daniel Lemire <daniel@lemire.me> * Using define_static_string from https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r2.html (simdjson#2389) * Applying changes needed after latest reflection paper updates. * Working, but no template for yet. * Updating single-header to incldue the use of define_static_string. * copying over master --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> Co-authored-by: Francisco Geiman Thiesen <franciscogthiesen@gmail.com>
1 parent 4acaf2e commit c806e95

85 files changed

Lines changed: 55496 additions & 40 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CMakeLists.txt‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ if(SIMDJSON_DISABLE_DEPRECATED_API)
4545
)
4646
endif()
4747

48+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25.0")
49+
option(SIMDJSON_STATIC_REFLECTION "Enables static reflection (experimental), requires C++26" OFF)
50+
else()
51+
set(SIMDJSON_STATIC_REFLECTION OFF CACHE BOOL "Enables static reflection (experimental)" FORCE)
52+
message(WARNING "SIMDJSON_STATIC_REFLECTION is disabled because your CMake version is below 3.25")
53+
endif()
54+
55+
if(SIMDJSON_STATIC_REFLECTION)
56+
simdjson_add_props(
57+
target_compile_definitions PUBLIC
58+
SIMDJSON_STATIC_REFLECTION=1
59+
)
60+
endif()
61+
4862
option(SIMDJSON_DEVELOPMENT_CHECKS "Enable development-time aids, such as \
4963
checks for incorrect API usage. Enabled by default in DEBUG." OFF)
5064
if(SIMDJSON_DEVELOPMENT_CHECKS)
@@ -100,7 +114,16 @@ simdjson_add_props(
100114
PRIVATE "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>"
101115
)
102116

103-
simdjson_add_props(target_compile_features PUBLIC cxx_std_11)
117+
if(SIMDJSON_STATIC_REFLECTION)
118+
# We would like to require C++26, but no compiler supports that!
119+
# This is a hack:
120+
simdjson_add_props(
121+
target_compile_options PUBLIC
122+
-freflection -fexpansion-statements -stdlib=libc++ -std=c++26
123+
)
124+
else()
125+
simdjson_add_props(target_compile_features PUBLIC cxx_std_11)
126+
endif()
104127

105128
# workaround for GNU GCC poor AVX load/store code generation
106129
if(

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Documentation
109109
Usage documentation is available:
110110
111111
* [Basics](doc/basics.md) is an overview of how to use simdjson and its APIs.
112+
* [Builder](doc/builder.md) is an overview of how to efficiently write JSON strings using simdjson.
112113
* [Performance](doc/performance.md) shows some more advanced scenarios and how to tune for them.
113114
* [Implementation Selection](doc/implementation-selection.md) describes runtime CPU detection and
114115
how you can work with it.

‎benchmark/CMakeLists.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ add_subdirectory(dom)
44
include_directories( . linux )
55
link_libraries(simdjson-windows-headers test-data)
66
link_libraries(simdjson)
7+
if(SIMDJSON_STATIC_REFLECTION)
8+
add_compile_definitions(SIMDJSON_STATIC_REFLECTION=1)
9+
endif(SIMDJSON_STATIC_REFLECTION)
710

811
add_executable(benchfeatures benchfeatures.cpp)
912
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
@@ -32,3 +35,6 @@ if (TARGET benchmark::benchmark)
3235
endif()
3336
endif()
3437

38+
if(SIMDJSON_STATIC_REFLECTION)
39+
add_subdirectory(static_reflect)
40+
endif(SIMDJSON_STATIC_REFLECTION)

0 commit comments

Comments
 (0)