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

Use ryu and fastfloat for double serialization/deserialization #49

Merged
merged 20 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 24 additions & 14 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ jobs:
cd build
GEOARROW_TESTING_DIR=$GITHUB_WORKSPACE/testing ctest -T test --output-on-failure .

- name: Install lcov
run: |
sudo apt-get install lcov

- name: Calculate coverage
run: |
cd build
lcov --capture --directory . \
--exclude "*_test.cc" \
--exclude "/usr/*" \
--exclude "*/gtest/*" \
--exclude "*/ryu/*" \
--exclude "*/fast_float.h" \
--exclude "*/nanoarrow.*" \
--output-file coverage.info

lcov --list coverage.info

- name: Upload coverage
if: success()
uses: codecov/codecov-action@v2
with:
files: build/coverage.info

- name: Test with memcheck
run: |
cd build
Expand All @@ -56,17 +80,3 @@ jobs:
with:
name: geoarrow-memcheck
path: build/Testing/Temporary/MemoryChecker.*.log

- name: Calculate coverage
run: |
SOURCE_PREFIX=`pwd`
mkdir build/cov
cd build/cov
gcov -abcfu --source-prefix=$SOURCE_PREFIX `find ../CMakeFiles/geoarrow.dir/ -name "*.gcno"`
rm nanoarrow.h.gcov nanoarrow.c.gcov

- name: Upload coverage
if: success()
uses: codecov/codecov-action@v2
with:
directory: build/cov
34 changes: 32 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

set(GEOARROW_VERSION "0.2.0-SNAPSHOT")
set(GEOARROW_VERSION "0.1.0-SNAPSHOT")
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" GEOARROW_BASE_VERSION "${GEOARROW_VERSION}")
project(geoarrow VERSION "${GEOARROW_BASE_VERSION}")

Expand All @@ -16,6 +16,8 @@ set(GEOARROW_VERSION_PATCH "${geoarrow_VERSION_PATCH}")

option(GEOARROW_BUILD_TESTS "Build tests" OFF)
option(GEOARROW_CODE_COVERAGE "Enable coverage reporting" OFF)
option(GEOARROW_USE_FAST_FLOAT "Use fast_float for numeric value parsing" ON)
option(GEOARROW_USE_RYU "Use ryu for numeric value printing" ON)

add_library(coverage_config INTERFACE)

Expand All @@ -24,6 +26,27 @@ if(GEOARROW_CODE_COVERAGE)
target_link_options(coverage_config INTERFACE --coverage)
endif()

if(GEOARROW_USE_FAST_FLOAT)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
set(GEOARROW_DOUBLE_PARSE_SOURCE src/geoarrow/double_parse_fast_float.cc)
set(GEOARROW_USE_FAST_FLOAT_DEFINE "#define GEOARROW_USE_FAST_FLOAT 1")
else()
set(GEOARROW_DOUBLE_PARSE_SOURCE src/geoarrow/double_parse_std.c)
set(GEOARROW_USE_FAST_FLOAT_DEFINE "#define GEOARROW_USE_FAST_FLOAT 0")
endif()

if(GEOARROW_USE_RYU)
set(GEOARROW_DOUBLE_PRINT_SOURCE src/geoarrow/double_print.c src/geoarrow/ryu/d2s.c)
set(GEOARROW_USE_RYU_DEFINE "#define GEOARROW_USE_RYU 1")
else()
set(GEOARROW_DOUBLE_PRINT_SOURCE src/geoarrow/double_print.c)
set(GEOARROW_USE_RYU_DEFINE "#define GEOARROW_USE_RYU 0")
endif()

configure_file(src/geoarrow/geoarrow_config.h.in generated/geoarrow_config.h)

add_library(
geoarrow
src/geoarrow/schema.c
Expand All @@ -38,11 +61,16 @@ add_library(
src/geoarrow/wkb_writer.c
src/geoarrow/wkt_reader.c
src/geoarrow/wkt_writer.c
${GEOARROW_DOUBLE_PARSE_SOURCE}
${GEOARROW_DOUBLE_PRINT_SOURCE}
src/geoarrow/nanoarrow.c)

target_include_directories(geoarrow PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geoarrow>
$<INSTALL_INTERFACE:include>)
target_include_directories(geoarrow
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
)
target_compile_definitions(geoarrow PUBLIC
"$<$<CONFIG:Debug>:NANOARROW_DEBUG>"
"$<$<CONFIG:Debug>:GEOARROW_DEBUG>")
Expand Down Expand Up @@ -75,6 +103,8 @@ endif()

install(TARGETS geoarrow DESTINATION lib)
install(DIRECTORY src/ DESTINATION include FILES_MATCHING PATTERN "*.h")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/geoarrow_config.h
DESTINATION include/geoarrow)

if(GEOARROW_BUILD_TESTS)
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --suppressions=${CMAKE_CURRENT_LIST_DIR}/valgrind.supp --error-exitcode=1")
Expand Down
24 changes: 14 additions & 10 deletions python/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@
import glob
import shutil

if __name__ == '__main__':
if __name__ == "__main__":
this_dir = os.path.abspath(os.path.dirname(__file__))
vendor_dir = os.path.join(this_dir, 'src', 'geoarrow', 'geoarrow')
vendor_source_dir = os.path.join(this_dir, '..', 'src', 'geoarrow')
vendor_dir = os.path.join(this_dir, "src", "geoarrow", "geoarrow")
vendor_source_dir = os.path.join(this_dir, "..", "src", "geoarrow")

if os.path.exists(vendor_dir):
shutil.rmtree(vendor_dir)

vendor_source_files = glob.glob(os.path.join(vendor_source_dir, '*.c'))
vendor_source_files += glob.glob(os.path.join(vendor_source_dir, '*.h'))
vendor_source_files += glob.glob(os.path.join(vendor_source_dir, 'geoarrow.hpp'))
vendor_source_files = glob.glob(os.path.join(vendor_source_dir, "*.c"))
vendor_source_files += glob.glob(os.path.join(vendor_source_dir, "*.h"))
vendor_source_files += glob.glob(os.path.join(vendor_source_dir, "geoarrow.hpp"))
vendor_source_files += glob.glob(
os.path.join(vendor_source_dir, "double_parse_fast_float.cc")
)
vendor_source_files += glob.glob(os.path.join(vendor_source_dir, "ryu/*.h"))
vendor_source_files += glob.glob(os.path.join(vendor_source_dir, "ryu/*.c"))

os.mkdir(vendor_dir)
os.mkdir(os.path.join(vendor_dir, "ryu"))
for source_file in vendor_source_files:
shutil.copyfile(
source_file,
os.path.join(vendor_dir, os.path.basename(source_file))
)
dst_file = source_file.removeprefix(os.path.join(vendor_source_dir, ""))
shutil.copyfile(source_file, os.path.join(vendor_dir, dst_file))
13 changes: 11 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@
subprocess.run([sys.executable, bootstrap_py])

vendor_dir = os.path.join(this_dir, "src", "geoarrow", "geoarrow")
vendored_files = os.listdir(vendor_dir)
sources = [f"src/geoarrow/geoarrow/{f}" for f in vendored_files if f.endswith(".c")]
sources = [
f"src/geoarrow/geoarrow/{f}"
for f in os.listdir(vendor_dir)
if f.endswith(".c") or f.endswith(".cc")
]

sources += [
f"src/geoarrow/geoarrow/ryu/{f}"
for f in os.listdir(os.path.join(vendor_dir, "ryu"))
if f.endswith(".c")
]


# Workaround because setuptools has no easy way to mix C and C++ sources
Expand Down
Loading
Loading