Skip to content

Commit

Permalink
chore: add foundationdb to dev-full & document avx support
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Nov 21, 2024
1 parent bdd7ba3 commit d37a085
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 3 deletions.
13 changes: 13 additions & 0 deletions docker/dev-full/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ services:
interval: 2s
timeout: 10s

foundationdb:
# See docs-internal/infrastructure/fdb/AVX.md
image: foundationdb/foundationdb:7.1.60
environment:
- FDB_CLUSTER_FILE_CONTENTS=fdb:fdb@127.0.0.1:4500
entrypoint: ["/usr/bin/tini", "-g", "--", "bash", "-c", "/usr/local/bin/entrypoint.sh"]
volumes:
- ./foundationdb/entrypoint.sh:/usr/local/bin/entrypoint.sh
# - foundationdb-data:/var/lib/foundationdb
networks:
- rivet-network

vector-client:
image: timberio/vector:0.42.0-distroless-static
command: -C /etc/vector
Expand Down Expand Up @@ -183,3 +195,4 @@ volumes:
clickhouse-data:
seaweedfs-data:
vector-data:
foundationdb-data:
28 changes: 28 additions & 0 deletions docker/dev-full/foundationdb/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
function configure_database() {
if ! fdbcli -C /var/fdb/fdb.cluster --exec status --timeout 1 ; then
echo "Configuring database"
until fdbcli -C /var/fdb/fdb.cluster --exec 'configure new single memory; status' --timeout 10 ; do
sleep 2
done
echo "Done configuring database"
fi

echo "Database ready for connection"
}


#
# Start the init function in the background and proceed to the main entry
# point. The function will hang until Foundationdb is up, then configure
# the database and exit silently.
#

configure_database &
IP=$(hostname -i|rev|cut -d' ' -f1|rev)
echo "docker:docker@$IP:4500" > /var/fdb/run/fdb.ci.cluster

# fix for apple sillicon/qemu
# https://github.com/apple/foundationdb/issues/4111#issuecomment-1284040423
sed -i '$ s/$/ --knob_disable_posix_kernel_aio=1/' /var/fdb/scripts/fdb.bash
exec /var/fdb/scripts/fdb.bash "$@"
11 changes: 11 additions & 0 deletions docker/dev-full/foundationdb/entrypoint.sh.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# https://apple.github.io/foundationdb/administration.html#administration-running-foundationdb
# Configure redundancy and storage engine
echo "=== Configuring Storage ==="
# fdbcli --exec "configure new single ssd"

# Start server
echo "=== Starting Server ==="
/var/fdb/scripts/fdb.bash

23 changes: 23 additions & 0 deletions docs-internal/infrastructure/fdb/AVX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# AVX

AVX (Advanced Vector Extensions) is a SIMD instruction on Intel CPUs to make
FoundationDB run parallel data processing tasks faster.

## Even & odd versions

Even versions of FoundationDB are compiled without AVX. Odd versions are compiled with it.

For example, [7.1.61](https://github.com/apple/foundationdb/releases/tag/7.1.61) is the AVX version of [7.1.60](https://github.com/apple/foundationdb/releases/tag/7.1.60).

Make sure to pay attention to if you're using a versino of FDB with AVX.

## When to use AVX

Use AVX on production Linux servers.

## When not to use AVX

Don't use AVX for Docker images, since QEMU can't emulate AVX and will crash ([source](https://github.com/apple/foundationdb/issues/4111#issuecomment-1284040423)). Tihs will prevent ARM users from being able to run FoundationDB.

This might be easy to fix if we build a Docker image built on the prebuilt AMD & ARM binaries on GitHub.

4 changes: 3 additions & 1 deletion packages/infra/client/isolate-v8-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ COPY . .

# Installs shared libs
RUN apt-get update && apt-get install -y libclang-dev protobuf-compiler
RUN curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.1.60/libfdb_c.x86_64.so"

# The FDB version should match `cluster::workflows::server::install::install_scripts::components::fdb::FDB_VERSION`
RUN curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.1.61/libfdb_c.x86_64.so"

RUN \
--mount=type=cache,target=/root/.cargo/git \
Expand Down
3 changes: 2 additions & 1 deletion packages/infra/client/manager/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ pub async fn start_fdb() {
.arg("test-fdb")
.arg("-e")
.arg("FDB_CLUSTER_FILE_CONTENTS=fdb:fdb@127.0.0.1:4500")
.arg("foundationdb/foundationdb:7.1.19")
// See docs-internal/infrastructure/fdb/AVX.md
.arg("foundationdb/foundationdb:7.1.60")
.status()
.await
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub const FDB_VERSION: &str = "7.1.60";
// See docs-internal/infrastructure/fdb/AVX.md
pub const FDB_VERSION: &str = "7.1.61";

pub fn install(initialize_immediately: bool) -> String {
let mut script = include_str!("../files/fdb_install.sh")
Expand Down

0 comments on commit d37a085

Please sign in to comment.