Skip to content
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
11 changes: 10 additions & 1 deletion cpp/pixels-retina/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if(ENABLE_JEMALLOC)
URL https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2
CONFIGURE_COMMAND <SOURCE_DIR>/configure
--prefix=${JEMALLOC_INSTALL_DIR}
--with-jemalloc-prefix=je_
--enable-prof
--enable-stats
--enable-shared
Expand All @@ -51,7 +52,6 @@ if(ENABLE_JEMALLOC)
add_dependencies(jemalloc_lib jemalloc_ext)

add_definitions(-DENABLE_JEMALLOC)
add_definitions(-DJEMALLOC_MANGLE)
endif()

# Disable gtest installation
Expand Down Expand Up @@ -93,10 +93,19 @@ add_library(pixels-retina SHARED ${SOURCES})
set_target_properties(pixels-retina PROPERTIES
OUTPUT_NAME "pixels-retina"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
# Set the rpath to the current directory, so that the jemalloc library can be found at runtime
INSTALL_RPATH "$ORIGIN"
BUILD_RPATH "$ORIGIN"
)

target_link_libraries(pixels-retina PRIVATE ${JNI_LIBRARIES})

# Disable rpath
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
set_target_properties(pixels-retina PROPERTIES
INSTALL_RPATH_USE_LINK_PATH FALSE
)

if(ENABLE_JEMALLOC)
target_link_libraries(pixels-retina PRIVATE jemalloc_lib pthread dl)
if(UNIX)
Expand Down
4 changes: 2 additions & 2 deletions cpp/pixels-retina/lib/RGVisibilityJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ JNIEXPORT jlong JNICALL Java_io_pixelsdb_pixels_retina_RGVisibility_getNativeMem

// 1. Try to refresh jemalloc epoch to ensure stats are current.
// Return -2 if this fails, as defined in Java's handleMemoryMetric.
if (mallctl("epoch", NULL, NULL, &epoch, sizeof(uint64_t)) != 0) {
if (je_mallctl("epoch", NULL, NULL, &epoch, sizeof(uint64_t)) != 0) {
return -2;
}

// 2. Try to read the actual allocated bytes.
// Return -3 if this fails, which often implies a config/prefix mismatch.
if (mallctl("stats.allocated", &allocated, &sz, NULL, 0) != 0) {
if (je_mallctl("stats.allocated", &allocated, &sz, NULL, 0) != 0) {
return -3;
}

Expand Down
2 changes: 2 additions & 0 deletions pixels-common/src/main/resources/pixels.properties
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ memspl = [1,8,16,32,64]

# set to true to enable pixels-retina
retina.enable=false
# number of rows in each tile visibility, must be a multiple of 64
retina.tile.visibility.capacity=10240
# number of rows recorded in memTable, must be a multiple of 64
retina.buffer.memTable.size=10240
# the scheme of the storage for retina buffer object storage, e.g., s3, minio
Expand Down
8 changes: 5 additions & 3 deletions pixels-retina/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pixels.retina.capacity>10240</pixels.retina.capacity>
</properties>

<dependencies>
Expand Down Expand Up @@ -163,11 +162,14 @@
<goal>run</goal>
</goals>
<configuration>
<target>
<target xmlns:if="ant:if">
<!-- Load only if pixels.properties exists, and only when the configuration file contains the retina tile visibility capacity setting. -->
<available file="${env.PIXELS_HOME}/etc/pixels.properties" property="pixels.properties.exists"/>
<loadproperties srcFile="${env.PIXELS_HOME}/etc/pixels.properties" if:set="pixels.properties.exists"/>
<exec executable="cmake" failonerror="true" outputproperty="cmake.output" errorproperty="cmake.error">
<arg line="-B ${project.basedir}/../cpp/pixels-retina/build"/>
<arg line="-S ${project.basedir}/../cpp/pixels-retina"/>
<arg line="-DRETINA_CAPACITY=${pixels.retina.capacity}"/>
<arg line="-DRETINA_CAPACITY=${retina.tile.visibility.capacity}" if:set="retina.tile.visibility.capacity"/>
</exec>
<exec executable="make" dir="${project.basedir}/../cpp/pixels-retina/build" failonerror="true" outputproperty="make.output" errorproperty="make.error">
<arg value="install"/>
Expand Down