tigerbeetle-node 0.11.12 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +212 -196
- package/dist/bin/aarch64-linux-gnu/client.node +0 -0
- package/dist/bin/aarch64-linux-musl/client.node +0 -0
- package/dist/bin/aarch64-macos/client.node +0 -0
- package/dist/bin/x86_64-linux-gnu/client.node +0 -0
- package/dist/bin/x86_64-linux-musl/client.node +0 -0
- package/dist/bin/x86_64-macos/client.node +0 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package-lock.json +66 -0
- package/package.json +8 -17
- package/src/index.ts +56 -1
- package/src/node.zig +10 -9
- package/dist/.client.node.sha256 +0 -1
- package/scripts/build_lib.sh +0 -61
- package/scripts/download_node_headers.sh +0 -32
- package/src/tigerbeetle/scripts/benchmark.bat +0 -48
- package/src/tigerbeetle/scripts/benchmark.sh +0 -66
- package/src/tigerbeetle/scripts/confirm_image.sh +0 -44
- package/src/tigerbeetle/scripts/fuzz_loop.sh +0 -15
- package/src/tigerbeetle/scripts/fuzz_unique_errors.sh +0 -7
- package/src/tigerbeetle/scripts/install.bat +0 -7
- package/src/tigerbeetle/scripts/install.sh +0 -21
- package/src/tigerbeetle/scripts/install_zig.bat +0 -113
- package/src/tigerbeetle/scripts/install_zig.sh +0 -90
- package/src/tigerbeetle/scripts/lint.zig +0 -199
- package/src/tigerbeetle/scripts/pre-commit.sh +0 -9
- package/src/tigerbeetle/scripts/scripts/benchmark.bat +0 -48
- package/src/tigerbeetle/scripts/scripts/benchmark.sh +0 -66
- package/src/tigerbeetle/scripts/scripts/confirm_image.sh +0 -44
- package/src/tigerbeetle/scripts/scripts/fuzz_loop.sh +0 -15
- package/src/tigerbeetle/scripts/scripts/fuzz_unique_errors.sh +0 -7
- package/src/tigerbeetle/scripts/scripts/install.bat +0 -7
- package/src/tigerbeetle/scripts/scripts/install.sh +0 -21
- package/src/tigerbeetle/scripts/scripts/install_zig.bat +0 -113
- package/src/tigerbeetle/scripts/scripts/install_zig.sh +0 -90
- package/src/tigerbeetle/scripts/scripts/lint.zig +0 -199
- package/src/tigerbeetle/scripts/scripts/pre-commit.sh +0 -9
- package/src/tigerbeetle/scripts/scripts/shellcheck.sh +0 -5
- package/src/tigerbeetle/scripts/scripts/tests_on_alpine.sh +0 -10
- package/src/tigerbeetle/scripts/scripts/tests_on_ubuntu.sh +0 -14
- package/src/tigerbeetle/scripts/scripts/upgrade_ubuntu_kernel.sh +0 -48
- package/src/tigerbeetle/scripts/scripts/validate_docs.sh +0 -23
- package/src/tigerbeetle/scripts/scripts/vr_state_enumerate +0 -46
- package/src/tigerbeetle/scripts/shellcheck.sh +0 -5
- package/src/tigerbeetle/scripts/tests_on_alpine.sh +0 -10
- package/src/tigerbeetle/scripts/tests_on_ubuntu.sh +0 -14
- package/src/tigerbeetle/scripts/upgrade_ubuntu_kernel.sh +0 -48
- package/src/tigerbeetle/scripts/validate_docs.sh +0 -23
- package/src/tigerbeetle/scripts/vr_state_enumerate +0 -46
- package/src/tigerbeetle/src/benchmark.zig +0 -314
- package/src/tigerbeetle/src/config.zig +0 -234
- package/src/tigerbeetle/src/constants.zig +0 -436
- package/src/tigerbeetle/src/ewah.zig +0 -286
- package/src/tigerbeetle/src/ewah_benchmark.zig +0 -120
- package/src/tigerbeetle/src/ewah_fuzz.zig +0 -130
- package/src/tigerbeetle/src/fifo.zig +0 -120
- package/src/tigerbeetle/src/io/benchmark.zig +0 -213
- package/src/tigerbeetle/src/io/darwin.zig +0 -814
- package/src/tigerbeetle/src/io/linux.zig +0 -1062
- package/src/tigerbeetle/src/io/test.zig +0 -643
- package/src/tigerbeetle/src/io/windows.zig +0 -1183
- package/src/tigerbeetle/src/io.zig +0 -34
- package/src/tigerbeetle/src/iops.zig +0 -107
- package/src/tigerbeetle/src/lsm/README.md +0 -308
- package/src/tigerbeetle/src/lsm/binary_search.zig +0 -341
- package/src/tigerbeetle/src/lsm/bloom_filter.zig +0 -125
- package/src/tigerbeetle/src/lsm/compaction.zig +0 -603
- package/src/tigerbeetle/src/lsm/composite_key.zig +0 -77
- package/src/tigerbeetle/src/lsm/direction.zig +0 -11
- package/src/tigerbeetle/src/lsm/eytzinger.zig +0 -587
- package/src/tigerbeetle/src/lsm/eytzinger_benchmark.zig +0 -330
- package/src/tigerbeetle/src/lsm/forest.zig +0 -204
- package/src/tigerbeetle/src/lsm/forest_fuzz.zig +0 -401
- package/src/tigerbeetle/src/lsm/grid.zig +0 -573
- package/src/tigerbeetle/src/lsm/groove.zig +0 -972
- package/src/tigerbeetle/src/lsm/k_way_merge.zig +0 -474
- package/src/tigerbeetle/src/lsm/level_iterator.zig +0 -332
- package/src/tigerbeetle/src/lsm/manifest.zig +0 -617
- package/src/tigerbeetle/src/lsm/manifest_level.zig +0 -877
- package/src/tigerbeetle/src/lsm/manifest_log.zig +0 -789
- package/src/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -691
- package/src/tigerbeetle/src/lsm/merge_iterator.zig +0 -106
- package/src/tigerbeetle/src/lsm/node_pool.zig +0 -235
- package/src/tigerbeetle/src/lsm/posted_groove.zig +0 -378
- package/src/tigerbeetle/src/lsm/segmented_array.zig +0 -1328
- package/src/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -148
- package/src/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -9
- package/src/tigerbeetle/src/lsm/set_associative_cache.zig +0 -850
- package/src/tigerbeetle/src/lsm/table.zig +0 -1031
- package/src/tigerbeetle/src/lsm/table_immutable.zig +0 -203
- package/src/tigerbeetle/src/lsm/table_iterator.zig +0 -340
- package/src/tigerbeetle/src/lsm/table_mutable.zig +0 -220
- package/src/tigerbeetle/src/lsm/test.zig +0 -438
- package/src/tigerbeetle/src/lsm/tree.zig +0 -1193
- package/src/tigerbeetle/src/lsm/tree_fuzz.zig +0 -474
- package/src/tigerbeetle/src/message_bus.zig +0 -1012
- package/src/tigerbeetle/src/message_pool.zig +0 -156
- package/src/tigerbeetle/src/ring_buffer.zig +0 -399
- package/src/tigerbeetle/src/simulator.zig +0 -569
- package/src/tigerbeetle/src/state_machine/auditor.zig +0 -577
- package/src/tigerbeetle/src/state_machine/workload.zig +0 -883
- package/src/tigerbeetle/src/state_machine.zig +0 -1881
- package/src/tigerbeetle/src/static_allocator.zig +0 -65
- package/src/tigerbeetle/src/stdx.zig +0 -162
- package/src/tigerbeetle/src/storage.zig +0 -393
- package/src/tigerbeetle/src/testing/cluster/message_bus.zig +0 -82
- package/src/tigerbeetle/src/testing/cluster/network.zig +0 -237
- package/src/tigerbeetle/src/testing/cluster/state_checker.zig +0 -169
- package/src/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -202
- package/src/tigerbeetle/src/testing/cluster.zig +0 -443
- package/src/tigerbeetle/src/testing/fuzz.zig +0 -140
- package/src/tigerbeetle/src/testing/hash_log.zig +0 -66
- package/src/tigerbeetle/src/testing/id.zig +0 -99
- package/src/tigerbeetle/src/testing/packet_simulator.zig +0 -364
- package/src/tigerbeetle/src/testing/priority_queue.zig +0 -645
- package/src/tigerbeetle/src/testing/reply_sequence.zig +0 -139
- package/src/tigerbeetle/src/testing/state_machine.zig +0 -249
- package/src/tigerbeetle/src/testing/storage.zig +0 -757
- package/src/tigerbeetle/src/testing/table.zig +0 -247
- package/src/tigerbeetle/src/testing/time.zig +0 -84
- package/src/tigerbeetle/src/tigerbeetle.zig +0 -227
- package/src/tigerbeetle/src/time.zig +0 -112
- package/src/tigerbeetle/src/tracer.zig +0 -529
- package/src/tigerbeetle/src/unit_tests.zig +0 -42
- package/src/tigerbeetle/src/vopr.zig +0 -495
- package/src/tigerbeetle/src/vsr/README.md +0 -209
- package/src/tigerbeetle/src/vsr/client.zig +0 -544
- package/src/tigerbeetle/src/vsr/clock.zig +0 -853
- package/src/tigerbeetle/src/vsr/journal.zig +0 -2413
- package/src/tigerbeetle/src/vsr/journal_format_fuzz.zig +0 -111
- package/src/tigerbeetle/src/vsr/marzullo.zig +0 -309
- package/src/tigerbeetle/src/vsr/replica.zig +0 -6381
- package/src/tigerbeetle/src/vsr/replica_format.zig +0 -219
- package/src/tigerbeetle/src/vsr/superblock.zig +0 -1631
- package/src/tigerbeetle/src/vsr/superblock_client_table.zig +0 -256
- package/src/tigerbeetle/src/vsr/superblock_free_set.zig +0 -929
- package/src/tigerbeetle/src/vsr/superblock_free_set_fuzz.zig +0 -334
- package/src/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -390
- package/src/tigerbeetle/src/vsr/superblock_manifest.zig +0 -615
- package/src/tigerbeetle/src/vsr/superblock_quorums.zig +0 -394
- package/src/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -314
- package/src/tigerbeetle/src/vsr.zig +0 -1352
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
|
|
3
|
-
set ZIG_RELEASE_DEFAULT=0.9.1
|
|
4
|
-
|
|
5
|
-
:: Determine the Zig build:
|
|
6
|
-
if "%~1"=="" (
|
|
7
|
-
set ZIG_RELEASE=%ZIG_RELEASE_DEFAULT%
|
|
8
|
-
) else if "%~1"=="latest" (
|
|
9
|
-
set ZIG_RELEASE=builds
|
|
10
|
-
) else (
|
|
11
|
-
set ZIG_RELEASE=%~1
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
:: Checks format of release version.
|
|
15
|
-
echo.%ZIG_RELEASE% | findstr /b /r /c:"builds" /c:"^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*">nul || (echo.Unexpected release format. && exit 1)
|
|
16
|
-
|
|
17
|
-
set ZIG_OS=windows
|
|
18
|
-
set ZIG_ARCH=x86_64
|
|
19
|
-
|
|
20
|
-
set ZIG_TARGET=zig-%ZIG_OS%-%ZIG_ARCH%
|
|
21
|
-
|
|
22
|
-
:: Determine the build, split the JSON line on whitespace and extract the 2nd field:
|
|
23
|
-
for /f "tokens=2" %%a in ('curl --silent https://ziglang.org/download/index.json ^| findstr %ZIG_TARGET% ^| findstr %ZIG_RELEASE%' ) do (
|
|
24
|
-
set ZIG_URL=%%a
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
:: Then remove quotes and commas:
|
|
28
|
-
for /f %%b in ("%ZIG_URL:,=%") do (
|
|
29
|
-
set ZIG_URL=%%~b
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
:: Checks the ZIG_URL variable follows the expected format.
|
|
33
|
-
echo.%ZIG_URL% | findstr /b /r /c:"https://ziglang.org/builds/" /c:"https://ziglang.org/download/%ZIG_RELEASE%">nul || (echo.Unexpected release URL format. && exit 1)
|
|
34
|
-
|
|
35
|
-
if "%ZIG_RELEASE%"=="builds" (
|
|
36
|
-
echo Installing Zig latest build...
|
|
37
|
-
) else (
|
|
38
|
-
echo Installing Zig %ZIG_RELEASE% release build...
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
:: Using variable modifiers to determine the directory and filename from the URL:
|
|
42
|
-
:: %%~ni Expands %%i to a file name only and %%~xi Expands %%i to a file name extension only.
|
|
43
|
-
for /f %%i in ("%ZIG_URL%") do (
|
|
44
|
-
set ZIG_DIRECTORY=%%~ni
|
|
45
|
-
set ZIG_TARBALL=%%~nxi
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
:: Checks the ZIG_DIRECTORY variable follows the expected format.
|
|
49
|
-
echo.%ZIG_DIRECTORY% | findstr /b /r /c:"zig-win64-" /c:"zig-windows-x86_64-">nul || (echo.Unexpected zip directory name format. && exit 1)
|
|
50
|
-
|
|
51
|
-
:: Making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
|
|
52
|
-
if exist %ZIG_TARBALL% (
|
|
53
|
-
del /q %ZIG_TARBALL%
|
|
54
|
-
if exist %ZIG_TARBALL% (
|
|
55
|
-
echo Failed to delete %ZIG_TARBALL%.
|
|
56
|
-
exit 1
|
|
57
|
-
)
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
echo Downloading %ZIG_URL%...
|
|
61
|
-
curl --silent --progress-bar --output %ZIG_TARBALL% %ZIG_URL%
|
|
62
|
-
if not exist %ZIG_TARBALL% (
|
|
63
|
-
echo Failed to download Zig zip file.
|
|
64
|
-
exit 1
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
:: Replace any existing Zig installation so that we can install or upgrade:
|
|
68
|
-
echo Removing any existing 'zig' and %ZIG_DIRECTORY% folders before extracting.
|
|
69
|
-
if exist zig\ (
|
|
70
|
-
rd /s /q zig\
|
|
71
|
-
:: Ensure the directory has been deleted.
|
|
72
|
-
if exist zig\ (
|
|
73
|
-
echo The ‘zig’ directory could not be deleted.
|
|
74
|
-
exit 1
|
|
75
|
-
)
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
if exist %ZIG_DIRECTORY%\ (
|
|
79
|
-
rd /s /q %ZIG_DIRECTORY%
|
|
80
|
-
:: Ensure the directory has been deleted.
|
|
81
|
-
if exist %ZIG_DIRECTORY% (
|
|
82
|
-
echo The %ZIG_DIRECTORY% directory could not be deleted.
|
|
83
|
-
exit 1
|
|
84
|
-
)
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
:: Extract and then remove the downloaded tarball:
|
|
88
|
-
echo Extracting %ZIG_TARBALL%...
|
|
89
|
-
|
|
90
|
-
:: Hiding Powershell's progress bar during the extraction
|
|
91
|
-
SET PS_DISABLE_PROGRESS="$ProgressPreference=[System.Management.Automation.ActionPreference]::SilentlyContinue"
|
|
92
|
-
powershell -Command "%PS_DISABLE_PROGRESS%;Expand-Archive %ZIG_TARBALL% -DestinationPath ."
|
|
93
|
-
|
|
94
|
-
if not exist %ZIG_TARBALL% (
|
|
95
|
-
echo Failed to extract zip file.
|
|
96
|
-
exit 1
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
echo Installing %ZIG_DIRECTORY% to 'zig' in current working directory...
|
|
100
|
-
ren %ZIG_DIRECTORY% zig
|
|
101
|
-
if exist %ZIG_DIRECTORY% (
|
|
102
|
-
echo Failed to rename %ZIG_DIRECTORY% to zig.
|
|
103
|
-
exit 1
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
:: Removes the zip file
|
|
107
|
-
del /q %ZIG_TARBALL%
|
|
108
|
-
if exist %ZIG_TARBALL% (
|
|
109
|
-
echo Failed to delete %ZIG_TARBALL% file.
|
|
110
|
-
exit 1
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
echo "Congratulations, you have successfully installed Zig version %ZIG_RELEASE%. Enjoy!"
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -eu
|
|
3
|
-
|
|
4
|
-
ZIG_RELEASE_DEFAULT="0.9.1"
|
|
5
|
-
# Default to the release build, or allow the latest dev build, or an explicit release version:
|
|
6
|
-
ZIG_RELEASE=${1:-$ZIG_RELEASE_DEFAULT}
|
|
7
|
-
if [ "$ZIG_RELEASE" = "latest" ]; then
|
|
8
|
-
ZIG_RELEASE="builds"
|
|
9
|
-
fi
|
|
10
|
-
|
|
11
|
-
# Validate the release version explicitly:
|
|
12
|
-
if echo "$ZIG_RELEASE" | grep -q '^builds$'; then
|
|
13
|
-
echo "Installing Zig latest build..."
|
|
14
|
-
elif echo "$ZIG_RELEASE" | grep -q '^[0-9]\+.[0-9]\+.[0-9]\+$'; then
|
|
15
|
-
echo "Installing Zig $ZIG_RELEASE release build..."
|
|
16
|
-
else
|
|
17
|
-
echo "Release version invalid"
|
|
18
|
-
exit 1
|
|
19
|
-
fi
|
|
20
|
-
|
|
21
|
-
# Determine the architecture:
|
|
22
|
-
if [ "$(uname -m)" = 'arm64' ] || [ "$(uname -m)" = 'aarch64' ]; then
|
|
23
|
-
ZIG_ARCH="aarch64"
|
|
24
|
-
else
|
|
25
|
-
ZIG_ARCH="x86_64"
|
|
26
|
-
fi
|
|
27
|
-
|
|
28
|
-
# Determine the operating system:
|
|
29
|
-
if [ "$(uname)" = "Linux" ]; then
|
|
30
|
-
ZIG_OS="linux"
|
|
31
|
-
else
|
|
32
|
-
ZIG_OS="macos"
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
ZIG_TARGET="zig-$ZIG_OS-$ZIG_ARCH"
|
|
36
|
-
|
|
37
|
-
# Determine the build, split the JSON line on whitespace and extract the 2nd field, then remove quotes and commas:
|
|
38
|
-
if command -v wget; then
|
|
39
|
-
# -4 forces `wget` to connect to ipv4 addresses, as ipv6 fails to resolve on certain distros.
|
|
40
|
-
# Only A records (for ipv4) are used in DNS:
|
|
41
|
-
ipv4="-4"
|
|
42
|
-
# But Alpine doesn't support this argument
|
|
43
|
-
if [ -f /etc/alpine-release ]; then
|
|
44
|
-
ipv4=""
|
|
45
|
-
fi
|
|
46
|
-
ZIG_URL=$(wget $ipv4 --quiet -O - https://ziglang.org/download/index.json | grep -F "$ZIG_TARGET" | grep -F "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g')
|
|
47
|
-
else
|
|
48
|
-
ZIG_URL=$(curl --silent https://ziglang.org/download/index.json | grep -F "$ZIG_TARGET" | grep -F "$ZIG_RELEASE" | awk '{print $2}' | sed 's/[",]//g')
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
# Ensure that the release is actually hosted on the ziglang.org website:
|
|
52
|
-
if [ -z "$ZIG_URL" ]; then
|
|
53
|
-
echo "Release not found on ziglang.org"
|
|
54
|
-
exit 1
|
|
55
|
-
fi
|
|
56
|
-
|
|
57
|
-
# Work out the filename from the URL, as well as the directory without the ".tar.xz" file extension:
|
|
58
|
-
ZIG_TARBALL=$(basename "$ZIG_URL")
|
|
59
|
-
ZIG_DIRECTORY=$(basename "$ZIG_TARBALL" .tar.xz)
|
|
60
|
-
|
|
61
|
-
# Download, making sure we download to the same output document, without wget adding "-1" etc. if the file was previously partially downloaded:
|
|
62
|
-
echo "Downloading $ZIG_URL..."
|
|
63
|
-
if command -v wget; then
|
|
64
|
-
# -4 forces `wget` to connect to ipv4 addresses, as ipv6 fails to resolve on certain distros.
|
|
65
|
-
# Only A records (for ipv4) are used in DNS:
|
|
66
|
-
ipv4="-4"
|
|
67
|
-
# But Alpine doesn't support this argument
|
|
68
|
-
if [ -f /etc/alpine-release ]; then
|
|
69
|
-
ipv4=""
|
|
70
|
-
fi
|
|
71
|
-
wget $ipv4 --quiet --output-document="$ZIG_TARBALL" "$ZIG_URL"
|
|
72
|
-
else
|
|
73
|
-
curl --silent --output "$ZIG_TARBALL" "$ZIG_URL"
|
|
74
|
-
fi
|
|
75
|
-
|
|
76
|
-
# Extract and then remove the downloaded tarball:
|
|
77
|
-
echo "Extracting $ZIG_TARBALL..."
|
|
78
|
-
tar -xf "$ZIG_TARBALL"
|
|
79
|
-
rm "$ZIG_TARBALL"
|
|
80
|
-
|
|
81
|
-
# Replace any existing Zig installation so that we can install or upgrade:
|
|
82
|
-
echo "Installing $ZIG_DIRECTORY to 'zig' in current working directory..."
|
|
83
|
-
rm -rf zig
|
|
84
|
-
mv "$ZIG_DIRECTORY" zig
|
|
85
|
-
|
|
86
|
-
# It's up to the user to add this to their path if they want to:
|
|
87
|
-
ZIG_BIN="$(pwd)/zig/zig"
|
|
88
|
-
|
|
89
|
-
ZIG_VERSION=$($ZIG_BIN version)
|
|
90
|
-
echo "Congratulations, you have successfully installed Zig $ZIG_VERSION to $ZIG_BIN. Enjoy!"
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const fs = std.fs;
|
|
3
|
-
const math = std.math;
|
|
4
|
-
const mem = std.mem;
|
|
5
|
-
|
|
6
|
-
const whitelist = std.ComptimeStringMap([]const u32, .{
|
|
7
|
-
.{ "src/cli.zig", &.{ 35, 39 } },
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
fn whitelisted(path: []const u8, line: u32) bool {
|
|
11
|
-
const lines = whitelist.get(path) orelse return false;
|
|
12
|
-
return mem.indexOfScalar(u32, lines, line) != null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Stats = struct {
|
|
16
|
-
path: []const u8,
|
|
17
|
-
assert_count: u32,
|
|
18
|
-
function_count: u32,
|
|
19
|
-
ratio: f64,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var file_stats = std.ArrayListUnmanaged(Stats){};
|
|
23
|
-
var seen = std.AutoArrayHashMapUnmanaged(fs.File.INode, void){};
|
|
24
|
-
|
|
25
|
-
var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
|
26
|
-
const gpa = general_purpose_allocator.allocator();
|
|
27
|
-
|
|
28
|
-
pub fn main() !void {
|
|
29
|
-
const argv = std.os.argv;
|
|
30
|
-
for (argv[1..]) |raw_path| {
|
|
31
|
-
const path = mem.span(raw_path);
|
|
32
|
-
lint_file(path, fs.cwd(), path) catch |err| switch (err) {
|
|
33
|
-
error.IsDir, error.AccessDenied => try lint_dir(path, fs.cwd(), path),
|
|
34
|
-
else => return err,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var max_path_len: usize = "total:".len;
|
|
39
|
-
var total_assert_count: usize = 0;
|
|
40
|
-
var total_function_count: usize = 0;
|
|
41
|
-
for (file_stats.items) |stats| {
|
|
42
|
-
max_path_len = math.max(max_path_len, stats.path.len);
|
|
43
|
-
total_assert_count += stats.assert_count;
|
|
44
|
-
total_function_count += stats.function_count;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
std.sort.sort(Stats, file_stats.items, {}, struct {
|
|
48
|
-
fn less_than(_: void, a: Stats, b: Stats) bool {
|
|
49
|
-
return a.ratio > b.ratio;
|
|
50
|
-
}
|
|
51
|
-
}.less_than);
|
|
52
|
-
|
|
53
|
-
var buffered_writer = std.io.bufferedWriter(std.io.getStdOut().writer());
|
|
54
|
-
const stdout = buffered_writer.writer();
|
|
55
|
-
|
|
56
|
-
try stdout.writeAll("\npath");
|
|
57
|
-
try stdout.writeByteNTimes(' ', max_path_len - "path".len);
|
|
58
|
-
try stdout.writeAll(" asserts functions ratio\n");
|
|
59
|
-
|
|
60
|
-
for (file_stats.items) |stats| {
|
|
61
|
-
try stdout.writeAll(stats.path);
|
|
62
|
-
try stdout.writeByteNTimes(' ', max_path_len - stats.path.len);
|
|
63
|
-
try stdout.print(" {d: >7} {d: >9} {d: >5.2}\n", .{
|
|
64
|
-
stats.assert_count,
|
|
65
|
-
stats.function_count,
|
|
66
|
-
stats.ratio,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
try stdout.writeByteNTimes(' ', max_path_len - "total:".len);
|
|
71
|
-
try stdout.print("total: {d: >7} {d: >9} {d: >5.2}\n", .{
|
|
72
|
-
total_assert_count,
|
|
73
|
-
total_function_count,
|
|
74
|
-
@intToFloat(f64, total_assert_count) / @intToFloat(f64, total_function_count),
|
|
75
|
-
});
|
|
76
|
-
try buffered_writer.flush();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const LintError = error{
|
|
80
|
-
OutOfMemory,
|
|
81
|
-
ParseError,
|
|
82
|
-
NotUtf8,
|
|
83
|
-
} || fs.File.OpenError || fs.File.ReadError || fs.File.WriteError;
|
|
84
|
-
|
|
85
|
-
fn lint_dir(file_path: []const u8, parent_dir: fs.Dir, parent_sub_path: []const u8) LintError!void {
|
|
86
|
-
var dir = try parent_dir.openDir(parent_sub_path, .{ .iterate = true });
|
|
87
|
-
defer dir.close();
|
|
88
|
-
|
|
89
|
-
const stat = try dir.stat();
|
|
90
|
-
if (try seen.fetchPut(gpa, stat.inode, {})) |_| return;
|
|
91
|
-
|
|
92
|
-
var dir_it = dir.iterate();
|
|
93
|
-
while (try dir_it.next()) |entry| {
|
|
94
|
-
const is_dir = entry.kind == .Directory;
|
|
95
|
-
|
|
96
|
-
if (is_dir and std.mem.eql(u8, entry.name, "zig-cache")) continue;
|
|
97
|
-
|
|
98
|
-
if (is_dir or mem.endsWith(u8, entry.name, ".zig")) {
|
|
99
|
-
const full_path = try fs.path.join(gpa, &[_][]const u8{ file_path, entry.name });
|
|
100
|
-
defer gpa.free(full_path);
|
|
101
|
-
|
|
102
|
-
if (is_dir) {
|
|
103
|
-
try lint_dir(full_path, dir, entry.name);
|
|
104
|
-
} else {
|
|
105
|
-
try lint_file(full_path, dir, entry.name);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
fn lint_file(file_path: []const u8, dir: fs.Dir, sub_path: []const u8) LintError!void {
|
|
112
|
-
const source_file = try dir.openFile(sub_path, .{});
|
|
113
|
-
defer source_file.close();
|
|
114
|
-
|
|
115
|
-
const stat = try source_file.stat();
|
|
116
|
-
|
|
117
|
-
if (stat.kind == .Directory) return error.IsDir;
|
|
118
|
-
|
|
119
|
-
// Add to set after no longer possible to get error.IsDir.
|
|
120
|
-
if (try seen.fetchPut(gpa, stat.inode, {})) |_| return;
|
|
121
|
-
|
|
122
|
-
const source = try source_file.readToEndAllocOptions(
|
|
123
|
-
gpa,
|
|
124
|
-
math.maxInt(usize),
|
|
125
|
-
null,
|
|
126
|
-
@alignOf(u8),
|
|
127
|
-
0,
|
|
128
|
-
);
|
|
129
|
-
try check_line_length(source, file_path);
|
|
130
|
-
|
|
131
|
-
var tree = try std.zig.parse(gpa, source);
|
|
132
|
-
defer tree.deinit(gpa);
|
|
133
|
-
|
|
134
|
-
if (tree.errors.len != 0) return error.ParseError;
|
|
135
|
-
|
|
136
|
-
const node_tags = tree.nodes.items(.tag);
|
|
137
|
-
const main_tokens = tree.nodes.items(.main_token);
|
|
138
|
-
const node_datas = tree.nodes.items(.data);
|
|
139
|
-
|
|
140
|
-
var function_count: u32 = 0;
|
|
141
|
-
var assert_count: u32 = 0;
|
|
142
|
-
for (node_tags) |tag, node| {
|
|
143
|
-
switch (tag) {
|
|
144
|
-
.fn_decl => {
|
|
145
|
-
function_count += 1;
|
|
146
|
-
const body = node_datas[node].rhs;
|
|
147
|
-
const body_start = tree.tokenLocation(0, tree.firstToken(body));
|
|
148
|
-
const body_end = tree.tokenLocation(0, tree.lastToken(body));
|
|
149
|
-
// Add 1 as the count returned by tokenLocation() is
|
|
150
|
-
// 0-indexed while most editors start at 1.
|
|
151
|
-
const line = @intCast(u32, body_start.line + 1);
|
|
152
|
-
const body_lines = body_end.line - body_start.line;
|
|
153
|
-
if (body_lines > 70 and !whitelisted(file_path, line)) {
|
|
154
|
-
const stderr = std.io.getStdErr().writer();
|
|
155
|
-
try stderr.print("{s}:{d} function body exceeds 70 lines ({d} lines)\n", .{
|
|
156
|
-
file_path,
|
|
157
|
-
line,
|
|
158
|
-
body_lines,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
.call_one, .call_one_comma => {
|
|
164
|
-
const lhs = node_datas[node].lhs;
|
|
165
|
-
if (node_tags[lhs] == .identifier and
|
|
166
|
-
mem.eql(u8, "assert", tree.tokenSlice(main_tokens[lhs])))
|
|
167
|
-
{
|
|
168
|
-
assert_count += 1;
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
.unreachable_literal => assert_count += 1,
|
|
173
|
-
|
|
174
|
-
else => {},
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
try file_stats.append(gpa, .{
|
|
179
|
-
.path = try gpa.dupe(u8, file_path),
|
|
180
|
-
.assert_count = assert_count,
|
|
181
|
-
.function_count = function_count,
|
|
182
|
-
.ratio = @intToFloat(f64, assert_count) / @intToFloat(f64, function_count),
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
fn check_line_length(source: []const u8, path: []const u8) !void {
|
|
187
|
-
var i: usize = 0;
|
|
188
|
-
var line: u32 = 1;
|
|
189
|
-
while (mem.indexOfScalar(u8, source[i..], '\n')) |newline| : (line += 1) {
|
|
190
|
-
const line_length = std.unicode.utf8CountCodepoints(
|
|
191
|
-
source[i..][0..newline],
|
|
192
|
-
) catch return error.NotUtf8;
|
|
193
|
-
if (line_length > 100 and !whitelisted(path, line)) {
|
|
194
|
-
const stderr = std.io.getStdErr().writer();
|
|
195
|
-
try stderr.print("{s}:{d} line exceeds 100 columns\n", .{ path, line });
|
|
196
|
-
}
|
|
197
|
-
i += newline + 1;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal enabledelayedexpansion
|
|
3
|
-
|
|
4
|
-
REM Install Zig if it does not already exist:
|
|
5
|
-
if not exist "zig" (
|
|
6
|
-
call .\scripts\install_zig.bat
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
if "%~1" equ ":main" (
|
|
10
|
-
shift /1
|
|
11
|
-
goto main
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
cmd /d /c "%~f0" :main %*
|
|
15
|
-
set ZIG_RESULT=%ERRORLEVEL%
|
|
16
|
-
taskkill /F /IM tigerbeetle.exe >nul
|
|
17
|
-
|
|
18
|
-
if !ZIG_RESULT! equ 0 (
|
|
19
|
-
del /f benchmark.log
|
|
20
|
-
) else (
|
|
21
|
-
echo.
|
|
22
|
-
echo Error running benchmark, here are more details
|
|
23
|
-
type benchmark.log
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
echo.
|
|
27
|
-
exit /b
|
|
28
|
-
|
|
29
|
-
:main
|
|
30
|
-
zig\zig.exe build install -Drelease-safe
|
|
31
|
-
|
|
32
|
-
for /l %%i in (0, 1, 0) do (
|
|
33
|
-
echo Initializing replica %%i
|
|
34
|
-
set ZIG_FILE=.\0_%%i.tigerbeetle.benchmark
|
|
35
|
-
if exist "!ZIG_FILE!" DEL /F "!ZIG_FILE!"
|
|
36
|
-
.\tigerbeetle.exe format --cluster=0 --replica=%%i !ZIG_FILE! > benchmark.log 2>&1
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
for /l %%i in (0, 1, 0) do (
|
|
40
|
-
echo Starting replica %%i
|
|
41
|
-
set ZIG_FILE=.\0_%%i.tigerbeetle.benchmark
|
|
42
|
-
start /B "tigerbeetle_%%i" .\tigerbeetle.exe start --addresses=3001 !ZIG_FILE! > benchmark.log 2>&1
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
echo.
|
|
46
|
-
echo Benchmarking...
|
|
47
|
-
zig\zig.exe build benchmark -Drelease-safe
|
|
48
|
-
exit /b %errorlevel%
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -eEuo pipefail
|
|
3
|
-
|
|
4
|
-
# Number of replicas to benchmark
|
|
5
|
-
REPLICAS=${REPLICAS:-0}
|
|
6
|
-
|
|
7
|
-
# Install Zig if it does not already exist:
|
|
8
|
-
if [ ! -d "zig" ]; then
|
|
9
|
-
scripts/install_zig.sh
|
|
10
|
-
fi
|
|
11
|
-
|
|
12
|
-
COLOR_RED='\033[1;31m'
|
|
13
|
-
COLOR_END='\033[0m'
|
|
14
|
-
|
|
15
|
-
zig/zig build install -Drelease-safe
|
|
16
|
-
|
|
17
|
-
function onerror {
|
|
18
|
-
if [ "$?" == "0" ]; then
|
|
19
|
-
rm benchmark.log
|
|
20
|
-
else
|
|
21
|
-
echo -e "${COLOR_RED}"
|
|
22
|
-
echo "Error running benchmark, here are more details (from benchmark.log):"
|
|
23
|
-
echo -e "${COLOR_END}"
|
|
24
|
-
cat benchmark.log
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
for I in $REPLICAS
|
|
28
|
-
do
|
|
29
|
-
echo "Stopping replica $I..."
|
|
30
|
-
done
|
|
31
|
-
kill %1
|
|
32
|
-
}
|
|
33
|
-
trap onerror EXIT
|
|
34
|
-
|
|
35
|
-
for I in $REPLICAS
|
|
36
|
-
do
|
|
37
|
-
echo "Formatting replica $I..."
|
|
38
|
-
|
|
39
|
-
# Be careful to use a benchmark-specific filename so that we don't erase a real data file:
|
|
40
|
-
FILE="./0_${I}.tigerbeetle.benchmark"
|
|
41
|
-
if [ -f "$FILE" ]; then
|
|
42
|
-
rm "$FILE"
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
./tigerbeetle format --cluster=0 --replica="$I" "$FILE" > benchmark.log 2>&1
|
|
46
|
-
done
|
|
47
|
-
|
|
48
|
-
for I in $REPLICAS
|
|
49
|
-
do
|
|
50
|
-
echo "Starting replica $I..."
|
|
51
|
-
FILE="./0_${I}.tigerbeetle.benchmark"
|
|
52
|
-
./tigerbeetle start --addresses=3001 "$FILE" >> benchmark.log 2>&1 &
|
|
53
|
-
done
|
|
54
|
-
|
|
55
|
-
echo ""
|
|
56
|
-
echo "Benchmarking..."
|
|
57
|
-
zig/zig build benchmark -Drelease-safe
|
|
58
|
-
echo ""
|
|
59
|
-
|
|
60
|
-
for I in $REPLICAS
|
|
61
|
-
do
|
|
62
|
-
FILE="./0_${I}.tigerbeetle.benchmark"
|
|
63
|
-
if [ -f "$FILE" ]; then
|
|
64
|
-
rm "$FILE"
|
|
65
|
-
fi
|
|
66
|
-
done
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
set -e
|
|
4
|
-
|
|
5
|
-
if [[ -z "$1" ]]; then
|
|
6
|
-
echo "Expected a first argument with a Docker image name or id"
|
|
7
|
-
exit 2
|
|
8
|
-
fi
|
|
9
|
-
|
|
10
|
-
if [[ "$2" != "--want-production" ]] && [[ "$2" != "--want-debug" ]]; then
|
|
11
|
-
echo "Expected a second argument: --want-production or --want-debug".
|
|
12
|
-
exit 2
|
|
13
|
-
fi
|
|
14
|
-
|
|
15
|
-
check="
|
|
16
|
-
set -eu
|
|
17
|
-
|
|
18
|
-
apt-get update -y
|
|
19
|
-
apt-get install -y binutils
|
|
20
|
-
|
|
21
|
-
is_production=false
|
|
22
|
-
# This getSymbolFromDwarf symbol only appears to be in the debug
|
|
23
|
-
# build, not the release build. So that's the test!
|
|
24
|
-
if ! [[ \$(nm -an /opt/beta-beetle/tigerbeetle | grep getSymbolFromDwarf) ]]; then
|
|
25
|
-
is_production=true
|
|
26
|
-
fi
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
if [[ "$2" == '--want-production' ]]; then
|
|
30
|
-
cmd+="
|
|
31
|
-
if [[ \$is_production == false ]]; then
|
|
32
|
-
echo 'Does not seem to be a production build'
|
|
33
|
-
exit 1
|
|
34
|
-
fi"
|
|
35
|
-
else
|
|
36
|
-
cmd+="
|
|
37
|
-
if [[ \$is_production == true ]]; then
|
|
38
|
-
echo 'Does not seem to be a debug build'
|
|
39
|
-
exit 1
|
|
40
|
-
fi"
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
# We accept a passed-in arg
|
|
44
|
-
docker run --entrypoint bash "$1" -c "$check"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -eu
|
|
3
|
-
|
|
4
|
-
# Repeatedly runs some zig build command with different seeds and stores the output in the current directory.
|
|
5
|
-
# Eg `fuzz_repeatedly.sh fuzz_lsm_forest` will run `zig build fuzz_lsm_forest -- seed $SEED > fuzz_lsm_forest_fuzz_${SEED}`
|
|
6
|
-
# Use ./fuzz_unique_errors.sh to analyze the results.
|
|
7
|
-
|
|
8
|
-
FUZZ_COMMAND=$1
|
|
9
|
-
|
|
10
|
-
while true; do
|
|
11
|
-
SEED=$(od -A n -t u8 -N 8 /dev/urandom | xargs)
|
|
12
|
-
(zig build "$FUZZ_COMMAND" -Drelease-safe=true -- --seed "$SEED") || \
|
|
13
|
-
(zig build "$FUZZ_COMMAND" -- --seed "$SEED" 2> "fuzz_${FUZZ_COMMAND}_${SEED}") || \
|
|
14
|
-
true
|
|
15
|
-
done
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
set -eu
|
|
3
|
-
|
|
4
|
-
# After running ./fuzz_loop.sh use this script to produce a list of unique crashes.
|
|
5
|
-
# As a heuristic, we look for the first line of the stacktrace that occurs inside tigerbeetle code.
|
|
6
|
-
|
|
7
|
-
grep -m 1 'tigerbeetle/src' fuzz_* | sort -u -t':' -k2,2
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env sh
|
|
2
|
-
|
|
3
|
-
if [ -z "$DEBUG" ]; then
|
|
4
|
-
debug="$DEBUG"
|
|
5
|
-
fi
|
|
6
|
-
|
|
7
|
-
debug="$DEBUG"
|
|
8
|
-
if [ "$1" = "--debug" ]; then
|
|
9
|
-
debug="true"
|
|
10
|
-
fi
|
|
11
|
-
|
|
12
|
-
set -eu
|
|
13
|
-
|
|
14
|
-
scripts/install_zig.sh
|
|
15
|
-
if [ "$debug" = "true" ]; then
|
|
16
|
-
echo "Building Tigerbeetle debug..."
|
|
17
|
-
zig/zig build install -Dcpu=baseline
|
|
18
|
-
else
|
|
19
|
-
echo "Building TigerBeetle..."
|
|
20
|
-
zig/zig build install -Dcpu=baseline -Drelease-safe
|
|
21
|
-
fi
|