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

ENH: Use RapidJSON instead of JsonCPP for performance improvement #646

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ENH: Use RapidJSON instead of JsonCPP for performance improvement
RapidJSON is mganitudes faster than JsonCPP (https://github.com/miloyip/nativejson-benchmark).
This is important, because when terminologies (rather large json documents) are parsed/searched/modified then each operation may take hundreds of milliseconds
with JsonCPP. Multiple calls easily accumulate to user-perceivable delays (magnitude of seconds). By keep using JsonCPP we would constantly have to
optimize number of logic calls to make sure only json access is minimized. Also, JsonCPP was unbearably slow in debug mode in Windows (simple operations took
tens of seconds).

To minimize development time and optimize speed we switch to RapidJSON instead. RapidJSON's advantages compared to jsoncpp (https://github.com/miloyip/nativejson-benchmark):
* Magnitudes faster, also, its API facilitates writing efficient application code
* CMake-ified
* Header-only (no need to install DLLs, ...)
* More conform to json standard
* Library is much smaller (31k vs 243k)
  • Loading branch information
lassoan committed Jan 16, 2017
commit a62af11ff981898e5915b3070a75210cedc9234c
2 changes: 1 addition & 1 deletion CMake/SlicerGenerateSlicerConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ set(Slicer_EP_COMPONENT_VARS_CONFIG
"set(Slicer_VTK_COMPONENTS \"${Slicer_VTK_COMPONENTS}\")")

# List all required external project
set(Slicer_EXTERNAL_PROJECTS_CONFIG CTK ITK CURL Teem VTK)
set(Slicer_EXTERNAL_PROJECTS_CONFIG CTK ITK CURL Teem VTK RapidJSON)
set(Slicer_EXTERNAL_PROJECTS_NO_USEFILE_CONFIG CURL)
if(Slicer_USE_QtTesting)
list(APPEND Slicer_EXTERNAL_PROJECTS_CONFIG QtTesting)
Expand Down
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,6 @@ mark_as_superbuild(Slicer_INSTALL_ITKPython)
option(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT "Build Slicer with parameter serializer support" ON)
mark_as_superbuild(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT)

if(NOT Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT)
# Terminologies modules requires JSON, which is provided by parameter serializer.
# Therefore, Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT is required for Slicer build.
# It could be possible to disable Terminologies module and all features that use it.
message(FATAL_ERROR "Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT option required to be enabled. ")
endif()


#
# SimpleITK has large internal libraries, which take an extremely long
# time to link on windows when they are static. Creating shared
Expand Down
5 changes: 3 additions & 2 deletions Modules/Loadable/Terminologies/Logic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ project(vtkSlicer${MODULE_NAME}ModuleLogic)

set(KIT ${PROJECT_NAME})

find_package(RapidJSON REQUIRED)

set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_LOGIC_EXPORT")

set(${KIT}_INCLUDE_DIRECTORIES
${JsonCpp_INCLUDE_DIR}
${RapidJSON_INCLUDE_DIR}
)

set(${KIT}_SRCS
Expand All @@ -20,7 +22,6 @@ set(${KIT}_SRCS
)

set(${KIT}_TARGET_LIBRARIES
${JsonCpp_LIBRARY}
)

#-----------------------------------------------------------------------------
Expand Down
Loading