Skip to content

Commit

Permalink
thread dump service rust (#1270)
Browse files Browse the repository at this point in the history
* thread dumb service rust

* fix bug

* fix routing

* change to elfutils

* install lidw-dev

* fix install

* fix install

* set-up in workflows

* train set-up

* more dockerfile

* switch to using Makefiles for system deps

* more centralization

* retrigger CI

* switch to JSON

* format to Trace

* proper formatting

* use match[

* we need libwd-dev at run time too (dynamic lib)

* tipo

* renamed options

---------

Co-authored-by: Tarek Ziadé <[email protected]>
  • Loading branch information
hermeGarcia and tarekziade authored Sep 6, 2023
1 parent d6cb139 commit 3fcd2a2
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/nucliadb_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ env:
IMAGE_NAME_NODE_SIDECAR: node_sidecar

jobs:
pre-checks-rust:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Check system
run: make -C nucliadb_node/ check-system

pre-checks-python:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -112,6 +121,7 @@ jobs:
clippy-rust:
name: Clippy lint
runs-on: ubuntu-latest
needs: pre-check-rust
steps:
- uses: actions/checkout@v3

Expand All @@ -131,6 +141,7 @@ jobs:
prebuild-tests-rust:
name: Prebuild rust tests
runs-on: ubuntu-latest
needs: pre-check-rust

steps:
- uses: actions/checkout@v3
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/nucliadb_node_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ jobs:

- run: pip install -U twine 'black>=22.3.0,<23' typing_extensions

- name: Check system deps
if: ${{ matrix.os != 'windows' }}
run: make -C nucliadb check-system

- name: build sdist
if: ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux == 'auto' }}
uses: messense/maturin-action@v1
Expand All @@ -91,7 +95,10 @@ jobs:

- name: build wheels
uses: messense/maturin-action@v1
env:
RUSTFLAGS: --cfg tokio_unstable
with:
before-script-linux: scripts/install-system-deps.sh
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
container: ${{ matrix.container }}
Expand Down
87 changes: 85 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Dockerfile.node
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ ARG CARGO_FEATURES=release-feature-set
ARG CARGO_PROFILE=release
ENV RUSTFLAGS="--cfg prometheus_metrics --cfg tokio_unstable"

# Install system dependencies
COPY scripts/install-system-deps.sh /tmp/
RUN /tmp/install-system-deps.sh && rm /tmp/install-system-deps.sh && rm -rf /var/lib/apt/lists/*

COPY --from=planner /nucliadb/recipe.json recipe.json

# Build dependencies (this is the cached docker layer)
Expand All @@ -54,7 +58,6 @@ COPY nucliadb_texts /nucliadb/nucliadb_texts
COPY nucliadb_vectors /nucliadb/nucliadb_vectors
COPY vectors_benchmark /nucliadb/vectors_benchmark

# Build application (only run when sources are modified)
RUN echo "Building workspace with feature(s) '$CARGO_FEATURES' and profile '$CARGO_PROFILE'" \
&& cargo build \
--locked \
Expand All @@ -78,6 +81,7 @@ RUN apt-get -y update \
&& apt-get -y install ca-certificates curl \
libssl1.1 \
lmdb-utils \
libdw-dev \
&& rm -rf /var/lib/apt/lists/*

COPY --from=eu.gcr.io/stashify-218417/basenode:latest /bin/grpc_health_probe /bin/grpc_health_probe
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.node_local
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ LABEL org.opencontainers.image.vendor="Nuclia Inc."

WORKDIR /nucliadb

# Install system dependencies
COPY scripts/install-system-deps.sh /tmp/
RUN /tmp/install-system-deps.sh && rm /tmp/install-system-deps.sh

RUN apt-get -y update \
&& apt-get -y install ca-certificates \
cmake \
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.rust
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ RUN set -eux; \
cargo --version; \
rustc --version;

# Install system dependencies
COPY scripts/install-system-deps.sh /tmp/
RUN /tmp/install-system-deps.sh && rm /tmp/install-system-deps.sh

RUN apt-get update -y && apt-get install --yes --no-install-recommends patchelf cmake && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN pip install maturin
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.withbinding
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ RUN set -eux; \
cargo --version; \
rustc --version;

# Install system dependencies
COPY scripts/install-system-deps.sh /tmp/
RUN /tmp/install-system-deps.sh && rm /tmp/install-system-deps.sh

RUN apt-get update -y && apt-get install --yes --no-install-recommends patchelf cmake && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN pip install maturin
Expand Down
6 changes: 5 additions & 1 deletion nucliadb/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: install-dev
install-dev:
install-dev: check-system
pip install --upgrade pip wheel
cd .. && pip install \
-r test-requirements.txt \
Expand All @@ -9,6 +9,10 @@ install-dev:
-r nucliadb/requirements-test.txt
pip install -e .

.PHONY: check-system
check-system:
../scripts/install-system-deps.sh

freeze-requirements:
# create venv only for freezing requirements
python -m venv .freeze-venv
Expand Down
11 changes: 7 additions & 4 deletions nucliadb_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ rand = "0.8.4"
# nucliadb dependencies
nucliadb_telemetry = { path = "../nucliadb_telemetry" }
nucliadb_core = { path = "../nucliadb_core" }
nucliadb_texts= { path = "../nucliadb_texts" }
nucliadb_paragraphs= { path = "../nucliadb_paragraphs" }
nucliadb_vectors= { path = "../nucliadb_vectors" }
nucliadb_relations= { path = "../nucliadb_relations" }
nucliadb_texts = { path = "../nucliadb_texts" }
nucliadb_paragraphs = { path = "../nucliadb_paragraphs" }
nucliadb_vectors = { path = "../nucliadb_vectors" }
nucliadb_relations = { path = "../nucliadb_relations" }

# sentry sdk
sentry = "0.26.0"
Expand All @@ -86,6 +86,9 @@ tracing-log = { version = "0.1.3", features = ["env_logger"] }
opentelemetry-zipkin = "0.15.0"
sentry-tracing = "0.27.0"

[target.'cfg(all(target_arch = "x86_64", target_os = "linux", not(target_env = "musl")))'.dependencies]
rstack-self = { version = "0.3.0", features = ["dw"], default-features = false }

# indra
# indradb-lib = { version = "1", features = ["rocksdb-datastore"] }

Expand Down
7 changes: 6 additions & 1 deletion nucliadb_node/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: install-dev
install-dev:
install-dev: check-system
pip install --upgrade pip wheel
cd .. && pip install \
-r test-requirements.txt \
Expand All @@ -8,6 +8,11 @@ install-dev:
-r nucliadb_node/requirements.txt
pip install -e .

.PHONY: check-system
check-system:
../scripts/install-system-deps.sh


.PHONY: format
format:
cd .. && isort --profile black nucliadb_node
Expand Down
4 changes: 2 additions & 2 deletions nucliadb_node/src/bin/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use nucliadb_node::grpc::middleware::{
GrpcDebugLogsLayer, GrpcInstrumentorLayer, GrpcTasksMetricsLayer,
};
use nucliadb_node::grpc::reader::NodeReaderGRPCDriver;
use nucliadb_node::http_server::{run_http_metrics_server, MetricsServerOptions};
use nucliadb_node::http_server::{run_http_server, ServerOptions};
use nucliadb_node::lifecycle;
use nucliadb_node::settings::providers::env::EnvSettingsProvider;
use nucliadb_node::settings::providers::SettingsProvider;
Expand Down Expand Up @@ -64,7 +64,7 @@ async fn main() -> NodeResult<()> {
grpc_driver,
settings.reader_listen_address(),
));
let metrics_task = tokio::spawn(run_http_metrics_server(MetricsServerOptions {
let metrics_task = tokio::spawn(run_http_server(ServerOptions {
default_http_port: 3031,
}));

Expand Down
4 changes: 2 additions & 2 deletions nucliadb_node/src/bin/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use nucliadb_node::grpc::middleware::{
GrpcDebugLogsLayer, GrpcInstrumentorLayer, GrpcTasksMetricsLayer,
};
use nucliadb_node::grpc::writer::{NodeWriterEvent, NodeWriterGRPCDriver};
use nucliadb_node::http_server::{run_http_metrics_server, MetricsServerOptions};
use nucliadb_node::http_server::{run_http_server, ServerOptions};
use nucliadb_node::node_metadata::NodeMetadata;
use nucliadb_node::settings::providers::env::EnvSettingsProvider;
use nucliadb_node::settings::providers::SettingsProvider;
Expand Down Expand Up @@ -90,7 +90,7 @@ async fn main() -> NodeResult<()> {
None => tokio::spawn(task),
};
}
let metrics_task = tokio::spawn(run_http_metrics_server(MetricsServerOptions {
let metrics_task = tokio::spawn(run_http_server(ServerOptions {
default_http_port: 3032,
}));

Expand Down
11 changes: 6 additions & 5 deletions nucliadb_node/src/http_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
//! HTTP serving utilities

mod metrics_service;
mod traces_service;

use std::net::SocketAddr;

Expand All @@ -29,17 +30,17 @@ use axum::Router;

use crate::env::metrics_http_port;

pub struct MetricsServerOptions {
pub struct ServerOptions {
pub default_http_port: u16,
}

pub async fn run_http_metrics_server(options: MetricsServerOptions) {
pub async fn run_http_server(options: ServerOptions) {
// Add routes to services
let addr = SocketAddr::from(([0, 0, 0, 0], metrics_http_port(options.default_http_port)));
let metrics = Router::new().route("/metrics", get(metrics_service::metrics_service));
let router = Router::new().route("/metrics", get(metrics_service::metrics_service));
let router = router.route("/__dump", get(traces_service::thread_dump_service));
axum_server::bind(addr)
// Services will be added here
.serve(metrics.into_make_service())
.serve(router.into_make_service())
.await
.expect("Error starting the HTTP server");
}
Loading

2 comments on commit 3fcd2a2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 3fcd2a2 Previous: a40981d Ratio
nucliadb/tests/benchmarks/test_search.py::test_search_returns_labels 88.33781098173809 iter/sec (stddev: 0.0004386548882646358) 60.779932309336715 iter/sec (stddev: 0.0019119907918232523) 0.69
nucliadb/tests/benchmarks/test_search.py::test_search_relations 210.5874109386256 iter/sec (stddev: 0.000024998798360636732) 182.57436721258293 iter/sec (stddev: 0.0002220745559283828) 0.87

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 3fcd2a2 Previous: 10c9980 Ratio
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error 8527.119112007811 iter/sec (stddev: 0.000002377807796845594) 8662.717161511408 iter/sec (stddev: 3.746653110190535e-7) 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.