Skip to content

Commit

Permalink
Merge branch 'main' into dnut/fix/shred-network/keepup
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut authored Jan 16, 2025
2 parents 1813ed5 + bfcd3bd commit 103f298
Show file tree
Hide file tree
Showing 17 changed files with 506 additions and 335 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ jobs:
- name: run
run: ./zig-out/bin/fuzz allocators 19 10000

ledger_fuzz:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: setup zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- name: build
run: zig build -Doptimize=ReleaseSafe -Dno-run fuzz
- name: run
run: ./zig-out/bin/fuzz ledger 19 10000

# benchmarks:
# if: ${{ github.ref != 'refs/heads/main' }}
# strategy:
Expand Down
17 changes: 17 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ There are two main guidelines to keep in mind when naming interfaces and interfa
- As an example, a generic implementation of `std.Random` which is a pseudo-random number generator should be named `prng` (ie this is relevant when making appropriate use of `std.Random.DefaultPrng`).
- As another example, an instance of `std.heap.GeneralPurposeAllocator(config)` should be called `gpa_state`, `std.heap.ArenaAllocator` `arena_state`, and so on.

#### Method Parameters
The first parameter of a method should be named `self`. The type should be the name of the struct.
For example:

```zig
const MyStruct = struct {
state: u8,
fn write(self: *MyStruct, new_state: u8) void {
self.state = new_state;
}
};
```

If the type name is not available (for example in anonymous structs), define `const Self = @This()`
and use that as the type.

### Files as Structs
We prohibit usage of files as instantiable struct types in the codebase.

Expand Down
4 changes: 4 additions & 0 deletions scripts/benchmark_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# doc:
# this script scrapes the results/metrics directory for json files
# and generates a graph for each metric in the json file

import os
import json
import plotly.express as px
Expand Down
13 changes: 10 additions & 3 deletions scripts/collect_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env bash

# crontab -e
# 0 5 * * * bash /home/ubuntu/benchmarks/sig/scripts/collect_benchmarks.sh
# doc:
# this script will pull the latest change of the local repo
# and run the benchmark to collect metrics which are
# saved as results/output.json file. they are then
# moved to results/metrics/output-{commit}-{timestamp}.json
#
# these output files are then compared/visualized using the
# scripts/benchmark_server.py script

# now in the scripts/ dir
cd "$(dirname "$0")"
Expand All @@ -22,7 +28,8 @@ if ls $result_file 1> /dev/null 2>&1; then
echo "Results for commit $git_commit already exist. Skipping benchmark."
else
# Run the benchmark only if the result file doesn't exist
zig build -Doptimize=ReleaseSafe benchmark -- --metrics all
zig build -Doptimize=ReleaseSafe -Dno-run benchmark
./zig-out/bin/benchmark --metrics -e -f all

mv results/output.json "${result_dir}/output-${git_commit}-${timestamp}.json"
echo "Benchmark results saved to ${result_dir}/output-${git_commit}-${timestamp}.json"
Expand Down
13 changes: 13 additions & 0 deletions scripts/cron_jobs/setup_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# doc:
# this script will modify your server's crontab
# to run the collect_benchmarks.sh script at 6am everyday

SCRIPT_DIR=$(dirname "$(readlink -f "$0")")/..

# 6am everyday
(crontab -l; echo "\
0 6 * * * . $HOME/.bashrc; (bash $SCRIPT_DIR/collect_benchmarks.sh) 2>&1 | logger -t sig_bench \
") | crontab

echo "Cron job added. Current crontab:"
crontab -l
Loading

0 comments on commit 103f298

Please sign in to comment.