-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (76 loc) · 2.62 KB
/
Makefile
File metadata and controls
99 lines (76 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
include makefiles/net.mk
SCCACHE := $(shell which sccache)
CARGO_CMD = RUSTC_WRAPPER=$(SCCACHE) cargo
TARGET_DIR = target/profiling
BINARY = $(TARGET_DIR)/pulsebeam
SIM := sim
.PHONY: all help dev build release profile flamegraph perf deps brew-deps cargo-deps clean
all: build
dev:
$(CARGO_CMD) run -p pulsebeam -- --dev
build:
$(CARGO_CMD) build
release:
$(CARGO_CMD) build --verbose --release -p pulsebeam
profile:
$(CARGO_CMD) build --profile profiling -p pulsebeam
test: test-unit test-loom test-sim
test-unit:
$(CARGO_CMD) test --workspace --exclude pulsebeam-simulator -- --skip loom_
test-sim:
$(CARGO_CMD) test --profile $(SIM) -p pulsebeam-simulator -- --no-capture
test-loom:
LOOM_MAX_PREEMPTIONS=2 $(CARGO_CMD) test --workspace --features loom loom_
lint:
cargo fix --allow-dirty && cargo clippy --fix --allow-dirty
flamegraph: profile
taskset -c 2-5 $(CARGO_CMD) flamegraph --profile profiling -p pulsebeam --bin pulsebeam
perf:
@# Capture PIDs, replace newlines with commas, and trim the trailing comma
$(eval PIDS := $(shell pgrep -x pulsebeam | paste -sd "," -))
@if [ -z "$(PIDS)" ]; then echo "Error: pulsebeam not running"; exit 1; fi; \
sudo sysctl -w kernel.kptr_restrict=0
sudo sysctl -w kernel.perf_event_paranoid=-1
sudo perf record -p $(PIDS) \
--sample-cpu \
-e cycles,cache-misses,LLC-load-misses \
-e sched:sched_switch --switch-events \
--call-graph fp \
-m 16M \
-- sleep 30
sudo hotspot perf.data
stats:
$(eval PIDS := $(shell pgrep -x pulsebeam | paste -sd "," -))
@if [ -z "$(PIDS)" ]; then echo "Error: pulsebeam not running"; exit 1; fi; \
perf stat -e cpu_core/L1-dcache-loads/ \
-e cpu_core/L1-dcache-load-misses/ \
-e cpu_core/L1-dcache-stores/ \
-e cpu_core/L1-dcache-store-misses/ \
-e cpu_core/l2_rqsts.miss/ \
-e cpu_core/LLC-loads/,cpu_core/LLC-load-misses/ \
-e dtlb-load-misses,dtlb-store-misses \
-e instructions,cpu-cycles \
-p $(PIDS) -- sleep 30
deps: deps-brew deps-cargo gh-deps
deps-brew:
brew install git-cliff axodotdev/tap/cargo-dist
deps-cargo:
$(CARGO_CMD) install cargo-release cargo-dist git-cliff
$(CARGO_CMD) install flamegraph cargo-machete
deps-profile:
# used for perf record speed up
$(CARGO_CMD) install addr2line --features=bin
# https://github.com/flamegraph-rs/flamegraph/issues/74
sudo cp /usr/bin/addr2line /usr/bin/addr2line-bak
sudo cp target/release/examples/addr2line /usr/bin/addr2line
deps-gh:
gh extension install yusukebe/gh-markdown-preview
preview-markdown:
gh markdown-preview
clean:
$(CARGO_CMD) clean
rm -f perf.data flamegraph.svg
chore-release:
cargo release -v --execute
unused:
cargo machete