Skip to content

Commit

Permalink
Merge branch 'main' into go-benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
SanHalacogluImproving committed Nov 10, 2023
2 parents 15b2c44 + 8a0449d commit cccb946
Show file tree
Hide file tree
Showing 91 changed files with 4,400 additions and 1,129 deletions.
14 changes: 10 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", 'eslint-plugin-tsdoc'],
plugins: ["@typescript-eslint", "eslint-plugin-tsdoc", "import"],
root: true,
env: {
browser: true,
node: true,
jest: true,
},
rules: {
'tsdoc/syntax': 'error'
}
"tsdoc/syntax": "error",
"import/no-unresolved": "off",
},
};
46 changes: 46 additions & 0 deletions .github/workflows/java-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Java client benchmarks

on:
workflow_dispatch:
inputs:
name:
required: false
type: string

run-name: ${{ inputs.name == '' && format('{0} @ {1}', github.ref_name, github.sha) || inputs.name }}

jobs:
java-benchmark:
strategy:
matrix:
java:
- 11
- 17
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: ${{ matrix.java }}

- name: Start Redis
run: docker run -p 6379:6379 -p 8001:8001 -d redis/redis-stack

- name: Run benchmarks
working-directory: java
run: ./gradlew :benchmark:run

- name: Upload test reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.java }}
path: |
java/benchmarks/build/reports/**
69 changes: 69 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Java CI

on:
push:
paths:
- babushka-core/**
- submodules/**
- "java/**"
- ".github/workflows/java.yml"
pull_request:
paths:
- babushka-core/**
- submodules/**
- "java/**"
- ".github/workflows/java.yml"

# Run only most latest job on a branch and cancel previous ones
concurrency:
group: ${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build-and-test-java-client:
strategy:
# Run all jobs
fail-fast: false
matrix:
java:
- 11
- 17
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: ${{ matrix.java }}

- name: Install and run protoc (protobuf)
run: |
sudo apt update
sudo apt install -y protobuf-compiler
mkdir -p java/client/src/main/java/org/babushka/javababushka/generated
protoc -Iprotobuf=babushka-core/src/protobuf/ --java_out=java/client/src/main/java/org/babushka/javababushka/generated babushka-core/src/protobuf/*.proto
- name: Build rust part
working-directory: java
run: cargo build

- name: Start Redis
run: docker run -p 6379:6379 -p 8001:8001 -d redis/redis-stack

- name: Build java part
working-directory: java
run: ./gradlew --continue build

- name: Upload test reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.java }}
path: |
java/client/build/reports/**
java/integTest/build/reports/**
20 changes: 19 additions & 1 deletion .github/workflows/lint-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
paths:
- benchmarks/node/**
- node/**
- benchmarks/utilities/*
pull_request:
paths:
- benchmarks/node/**
- node/**
- benchmarks/utilities/*

env:
CARGO_TERM_COLOR: always
Expand All @@ -18,8 +20,24 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- uses: ./.github/workflows/lint-ts
with:
package-folder: ./node
name: lint node

- uses: ./.github/workflows/lint-ts
with:
package-folder: ./benchmarks/node
name: lint benchmark

- uses: ./.github/workflows/lint-ts
with:
package-folder: ./benchmarks/utilities
name: lint benchmark utilities

- name: lint ts
run: |
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier
npm i
npx eslint .
23 changes: 23 additions & 0 deletions .github/workflows/lint-ts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint TypeScript

inputs:
package-folder:
description: "folder that contains the target Cargo.toml file"
required: true
type: string

runs:
using: "composite"

steps:
- uses: actions/checkout@v4

- run: cp .eslintrc.cjs ${{ inputs.package-folder }}
shell: bash

- run: |
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier
npm i
npx eslint . --max-warnings=0
working-directory: ${{ inputs.package-folder }}
shell: bash
7 changes: 6 additions & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
working-directory: ./python
run: |
python -m pip install --upgrade pip
pip install flake8 isort black mypy-protobuf
pip install flake8 isort black mypy-protobuf deadcode
- name: Lint with isort
working-directory: ./python
Expand All @@ -71,6 +71,11 @@ jobs:
run: |
black --target-version py36 --check --diff .
- name: Lint with deadcode
working-directory: .
run: |
deadcode . --ignore-definitions=InfoSection,Level,*protobuf*,*pytest*
- name: Start redis server
working-directory: ./python
run: redis-server &
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
debug/
target/

# Git stuff
.worktrees

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
Expand All @@ -17,6 +20,14 @@ dump.rdb
.env
benchmarks/results

# IDE generaged files
.vs
.vscode
.idea

# MacOS metadata
.DS_Store

# lock files

yarn.lock
Expand Down
2 changes: 1 addition & 1 deletion babushka-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ criterion = { version = "^0.5", features = ["html_reports", "async_tokio"] }
which = "4.4.0"
ctor = "0.2.2"
redis = { path = "../submodules/redis-rs/redis", features = ["tls-rustls-insecure"] }
iai-callgrind = "0.6"
iai-callgrind = "0.7"
tokio = { version = "1", features = ["rt-multi-thread"] }
once_cell = "1.18.0"

Expand Down
51 changes: 43 additions & 8 deletions babushka-core/benches/memory_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use babushka::{
client::Client,
connection_request::{AddressInfo, ConnectionRequest, TlsMode},
};
use iai_callgrind::{black_box, main};
use iai_callgrind::{black_box, library_benchmark, library_benchmark_group, main};
use redis::{cmd, Value};
use tokio::runtime::Builder;

Expand All @@ -28,14 +28,12 @@ where
});
}

// Don't forget the `#[inline(never)]`
#[inline(never)]
#[library_benchmark]
fn just_setup() {
runner(|_| async {});
}

// Don't forget the `#[inline(never)]`
#[inline(never)]
#[library_benchmark]
fn send_message() {
runner(|mut client| async move {
client
Expand All @@ -45,8 +43,7 @@ fn send_message() {
});
}

// Don't forget the `#[inline(never)]`
#[inline(never)]
#[library_benchmark]
fn send_and_receive_messages() {
runner(|mut client| async move {
let mut command = cmd("SET");
Expand Down Expand Up @@ -77,4 +74,42 @@ fn send_and_receive_messages() {
});
}

main!(just_setup, send_message, send_and_receive_messages);
#[library_benchmark]
fn lots_of_messages() {
runner(|mut client| async move {
for _ in 0..1000 {
let mut command = cmd("SET");
command.arg("foo").arg("bar");
client
.req_packed_command(&black_box(command), None)
.await
.unwrap();
let mut command = cmd("SET");
command.arg("baz").arg("foo");
client
.req_packed_command(&black_box(command), None)
.await
.unwrap();
let mut command = cmd("MGET");
command.arg("baz").arg("foo");
let result = client
.req_packed_command(&black_box(command), None)
.await
.unwrap();
assert!(
result
== Value::Bulk(vec![
Value::Data(b"foo".to_vec()),
Value::Data(b"bar".to_vec())
])
)
}
});
}

library_benchmark_group!(
name = cluster;
benchmarks = just_setup, send_message, send_and_receive_messages, lots_of_messages
);

main!(library_benchmark_groups = cluster);
Loading

0 comments on commit cccb946

Please sign in to comment.