aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 15:45:32 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 15:45:32 +0200
commitfc9b20ba1dbf8ab3547ece455f35be095f2885e0 (patch)
treea96b43ca47c2e7852d22616ff3b649d719382c53
parenttests(basic): Extend to cover repeated sync (diff)
downloadatuin-fc9b20ba1dbf8ab3547ece455f35be095f2885e0.zip
perf: Add basic profiling framework
-rw-r--r--.gitignore5
-rw-r--r--Cargo.toml11
-rwxr-xr-xscripts/profile_history.sh31
3 files changed, 47 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 985e2a88..07c26314 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,8 @@ ui/backend/gen
sqlite-server.db*
.atuin/permissions.*.toml
+
+# Performance testing
+/perf.data
+/perf.data.old
+/flamegraph.svg
diff --git a/Cargo.toml b/Cargo.toml
index 78d8dd44..c5b55e91 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,6 +8,7 @@ members = [
resolver = "2"
exclude = ["crates/atuin-nucleo/matcher/fuzz"]
+
[workspace.package]
version = "18.16.1"
authors = ["Ellie Huxtable <ellie@atuin.sh>"]
@@ -21,6 +22,16 @@ readme = "README.md"
atuin-nucleo = { path = "crates/atuin-nucleo", version = "0.6.0" }
atuin-nucleo-matcher = { path = "crates/atuin-nucleo/matcher", version = "0.3.1" }
+[profile.profiling]
+inherits = "release"
+debug = true
+
+[profile.release]
+lto = true
+codegen-units = 1
+panic = "abort"
+split-debuginfo = "off"
+
[workspace.lints.rust]
# rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html
warnings = "warn"
diff --git a/scripts/profile_history.sh b/scripts/profile_history.sh
new file mode 100755
index 00000000..94f5c7ed
--- /dev/null
+++ b/scripts/profile_history.sh
@@ -0,0 +1,31 @@
+#! /usr/bin/env sh
+
+profile() {
+ cargo flamegraph --bin atuin --profile profiling -- "$@" 2>/dev/null
+}
+
+# SPDX-SnippetBegin
+# SPDX-SnippetCopyrightText: 2023 mentalisttraceur (https://github.com/mentalisttraceur)
+# Source: https://github.com/atuinsh/atuin/issues/1188#issuecomment-1698354107
+run_and_record_in_turtle() {
+ id="$(atuin history start --author "benchmark-script" --intent "to-profile atuin itself" -- "$@")"
+
+ "$@"
+ status="$?"
+
+ profile history end --exit "$status" "$id"
+
+ return $status
+}
+# SPDX-SnippetEnd
+
+if [ "$#" -eq 0 ]; then
+ echo "Not enough args"
+ exit 2
+fi
+
+cargo build --profile profiling
+
+run_and_record_in_turtle "$@"
+
+# vim: ft=sh