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

Make docker image more portable #1233

Merged
merged 2 commits into from
Jan 28, 2023
Merged
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ option(USE_LUAJIT "use luaJIT instead of lua" OFF)
option(ENABLE_OPENSSL "enable openssl to support tls connection" OFF)
option(ENABLE_IPO "enable interprocedural optimization" ON)
option(ENABLE_UNWIND "enable libunwind in glog" ON)
option(PORTABLE "build a portable binary (disable arch-specific optimizations)" OFF)

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN apt install -y git gcc g++ make cmake autoconf automake libtool python3 libs
WORKDIR /kvrocks

COPY . .
RUN ./x.py build -DENABLE_OPENSSL=ON
RUN ./x.py build -DENABLE_OPENSSL=ON -DPORTABLE=ON
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why portable is ON if the binary is built inside Ubuntu and is launching inside Ubuntu?
I guess arch-specific optimizations could be applied in this case because we are fully aware of the target platform (Ubuntu). Correct me if I'm wrong.

Copy link
Member Author

@PragmaTwice PragmaTwice Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, if the build machine (Travis CI here) has avx512 instructions, the built binary will use these instructions to perform vectorize optimization if -march=native is ON. But maybe user's device does not support avx512.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest adding an ARG and defaulting to ON.

Our image can always use the default but if users are certain for the platform they can build their own with PORTABLE=OFF.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. since other build arguments can also have this problem like ENABLE_SSL, DISABLE_JEMALLOC, so I add $MORE_BUILD_ARGS instead of $PORTABLE for more general purpose.


FROM ubuntu:focal

Expand Down
1 change: 1 addition & 0 deletions cmake/rocksdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ FetchContent_MakeAvailableWithArgs(rocksdb
USE_RTTI=ON
ROCKSDB_BUILD_SHARED=OFF
WITH_JEMALLOC=${COMPILE_WITH_JEMALLOC}
PORTABLE=${PORTABLE}
)

add_library(rocksdb_with_headers INTERFACE)
Expand Down