~bigbes/tarantool

tarantool-protobuf

ref: d6570ec6e105e3986ee544a06804e44649afc356 tarantool-protobuf/Makefile -rw-r--r-- 3.3 KiB
d6570ec6 — Eugene Blikh docs: PLAN.md lazy perf numbers after SoA refactor 3 months ago
                                                                                
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
100
101
102
103
104
105
106
PLUGIN := protoc-gen-tarantool
GEN_DIR := examples/expected
PROTO_DIR := examples/proto
CONFORMANCE_PROTO_DIR := test/conformance/proto

LUATEST := .rocks/bin/luatest
LUA_PATH_PARTS := \
	./runtime/?/init.lua \
	./runtime/?.lua \
	./$(GEN_DIR)/?.lua \
	./$(GEN_DIR)/?/init.lua \
	./?.lua \
	./?/init.lua \
	./test/?.lua

# semicolon-joined; trailing ;; lets the standard package.path defaults apply
empty :=
space := $(empty) $(empty)
LUA_PATH_JOINED := $(subst $(space),;,$(strip $(LUA_PATH_PARTS)));;

.PHONY: all build gen gen-full gen-runtime goldens test test-suite \
        bench bench-baseline bench-compare jit-trace clean

all: build gen test

build:
	go build -o $(PLUGIN) ./cmd/protoc-gen-tarantool

gen: gen-full gen-runtime gen-conformance

gen-full: build
	mkdir -p $(GEN_DIR)
	protoc \
		--plugin=./$(PLUGIN) \
		--tarantool_out=$(GEN_DIR) \
		--tarantool_opt=mode=full,prefix=full \
		-I $(PROTO_DIR) -I options \
		$(PROTO_DIR)/*.proto

gen-runtime: build
	mkdir -p $(GEN_DIR)
	protoc \
		--plugin=./$(PLUGIN) \
		--tarantool_out=$(GEN_DIR) \
		--tarantool_opt=mode=runtime,prefix=runtime \
		-I $(PROTO_DIR) -I options \
		$(PROTO_DIR)/*.proto

# Conformance + Google test_messages_proto3 are needed by cmd/conformance-runner.lua
# and the conformance self-test. Only the `full` mode is required by the runner.
gen-conformance: build
	mkdir -p $(GEN_DIR)
	protoc \
		--plugin=./$(PLUGIN) \
		--tarantool_out=$(GEN_DIR) \
		--tarantool_opt=mode=full,prefix=full \
		-I $(CONFORMANCE_PROTO_DIR) -I options \
		$(CONFORMANCE_PROTO_DIR)/*.proto
	protoc \
		--plugin=./$(PLUGIN) \
		--tarantool_out=$(GEN_DIR) \
		--tarantool_opt=mode=runtime,prefix=runtime \
		-I $(CONFORMANCE_PROTO_DIR) -I options \
		$(CONFORMANCE_PROTO_DIR)/*.proto

# Regenerate the interop golden corpus from .txtpb sources using mainline
# protoc. Run only when fixtures change; the generated .bin files are committed.
goldens:
	@for f in test/interop/fixtures/*.txtpb; do \
		type=$$(awk '/^# type:/ {print $$3; exit}' $$f); \
		out=$${f%.txtpb}.bin; \
		echo "  protoc --encode=$$type < $$f > $$out"; \
		protoc --encode=$$type -I $(PROTO_DIR) -I options $(PROTO_DIR)/hello.proto < $$f > $$out || exit $$?; \
	done

test: gen
	LUA_PATH="$(LUA_PATH_JOINED)" $(LUATEST) -v test/

# Microbenchmark: throughput + allocation per op across 5 payload sizes,
# both codegen modes. Throughput numbers print to stderr (informational —
# they vary with CPU load); the JSON document on stdout is the full record.
bench: gen
	tarantool bench/bench.lua --print

# Overwrite bench/baseline.json with current alloc-per-op numbers. Run on
# a quiet machine; allocs are deterministic to ~10 bytes so the file is
# hardware-independent.
bench-baseline: gen
	tarantool bench/bench.lua --baseline

# Fail with exit 1 if any alloc-per-op grows by >5% vs the committed
# baseline. Wire into CI to gate PRs.
bench-compare: gen
	tarantool bench/bench.lua --compare

# Trace-stability gate: assert every hot encode/decode path JIT-compiles
# without fatal aborts (NYI bytecode, blacklisting, persistent type
# instability) in our own source files. Runs as a standalone tarantool
# script — luatest's framework on macOS arm64 exhausts JIT mcode pages
# before tests run, masking the real abort reasons.
jit-trace: gen
	tarantool bench/jit_trace.lua

clean:
	rm -f $(PLUGIN)
	rm -rf $(GEN_DIR)