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

Avoid slow CI tests on MACOS_X using build flag #13276

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,10 @@ endif()
if(CMAKE_SYSTEM_NAME MATCHES "Cygwin")
add_definitions(-fno-builtin-memcmp -DCYGWIN)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(OS_MACOSX ON)
add_definitions(-DOS_MACOSX)
elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
set(OS_MACOSX ON)
add_definitions(-DOS_MACOSX -DIOS_CROSS_COMPILE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DOS_LINUX)
Expand Down Expand Up @@ -574,7 +576,7 @@ if(HAVE_AUXV_GETAUXVAL)
endif()

check_cxx_symbol_exists(F_FULLFSYNC "fcntl.h" HAVE_FULLFSYNC)
if(HAVE_FULLFSYNC)
if(HAVE_FULLFSYNC AND (NOT OS_MACOSX OR NOT MACOS_IGNORE_FULLFSYNC))
add_definitions(-DHAVE_FULLFSYNC)
endif()

Expand Down
7 changes: 5 additions & 2 deletions build_tools/build_detect_platform
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,18 @@ EOF
fi

# check for F_FULLFSYNC
$CXX $PLATFORM_CXXFALGS -x c++ - -o test.o 2>/dev/null <<EOF
$CXX $PLATFORM_CXXFLAGS -x c++ - -o test.o 2>/dev/null <<EOF
#include <fcntl.h>
int main() {
fcntl(0, F_FULLFSYNC);
return 0;
}
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_FULLFSYNC"
if [ ! "$MACOS_IGNORE_FULLFSYNC" ] || [ ! "$PLATFORM" = OS_MACOSX ]; then
echo "Full fsync"
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_FULLFSYNC"
fi
fi

rm -f test.o test_dl.o
Expand Down
2 changes: 1 addition & 1 deletion env/io_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ IOStatus PosixMmapFile::Fsync(const IOOptions& /*opts*/,
IODebugContext* /*dbg*/) {
#ifdef HAVE_FULLFSYNC
if (::fcntl(fd_, F_FULLFSYNC) < 0) {
return IOError("While fcntl(F_FULLSYNC) on mmaped file", filename_, errno);
return IOError("While fcntl(F_FULLSYNC) on mmapped file", filename_, errno);
}
#else // HAVE_FULLFSYNC
if (fsync(fd_) < 0) {
Expand Down
43 changes: 43 additions & 0 deletions java/src/test/java/org/rocksdb/OpenFSyncPerformanceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.rocksdb;

import java.util.ArrayList;
import org.junit.Test;

/**
* This test is intended to be run on MacOS
* It is used to compare/validate versions of RocksDB built using
* `make clean jclean; make -j12 rocksdbjava`
* versus versions built using
* `make clean jclean; MACOS_IGNORE_FULLFSYNC=1 make -j12 rocksdbjava`
* The latter run this test about 10x faster on MacOS.
* @link <a href="https://github.com/facebook/rocksdb/issues/13147">...</a>
* `MACOS_IGNORE_FULLFSYNC` can be used to build fast test-only versions of RocksDB for efficient CI
* usage
*/
public class OpenFSyncPerformanceTest {
@Test
public void testOpen() throws RocksDBException {
int count = 100;
ArrayList<Long> deltas = new ArrayList<>(count);
long sum = 0;
for (int i = 0; i < count; i++) {
long start = System.currentTimeMillis();
try (RocksDB db = RocksDB.open("test-open-" + i)) {
long delta = System.currentTimeMillis() - start;
// System.out.println("RocksDB.open() cost:" + (delta));
sum += delta;
deltas.add(delta);
} finally {
RocksDB.destroyDB("test-open-" + i, new Options());
}
}
long mean = sum / count;
long variance = 0;
for (long d : deltas) {
variance += (d - mean) * (d - mean);
}
double sd = Math.sqrt((double) (variance / count));
System.out.println(
"RocksDB.open() mean cost:" + (sum / count) + ", SD: " + sd + ", count: " + count);
}
}
Loading