Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
460c0d5
fix(store): a replaced splayed table keeps one copy of itself (#713)
singaraiona Oct 5, 2026
b3c8222
Merge pull request #714 from RayforceDB/feat/splay-retention-713
singaraiona Oct 5, 2026
6537eb3
fix(query): exclude null symbols from not-in (#739)
singaraiona Oct 8, 2026
00f5ea8
Merge pull request #742 from RayforceDB/fix/739-sym-not-in-nulls
singaraiona Oct 8, 2026
21e0d0c
perf(index): store hash slot table and group offsets as 32-bit
ser-vasilich Oct 6, 2026
506bc68
fix(heap): count off-heap allocations toward the spill watermark (#712)
ser-vasilich Oct 6, 2026
8e9b7d7
perf(index): store hash index row ids as 32-bit
ser-vasilich Oct 6, 2026
46c0608
fix(arena): grow chunks so a large arena can spill (#712)
ser-vasilich Oct 6, 2026
b00e1fe
fix(index): keep the wide arrays when narrowing is interrupted
ser-vasilich Oct 6, 2026
2883f55
fix(heap): hand memory back between statements when it is short
ser-vasilich Oct 7, 2026
13bcf74
perf(index): build hash indexes partition by partition within the mem…
ser-vasilich Oct 7, 2026
32f338c
fix(heap): relieve only when it brings the footprint back under the w…
ser-vasilich Oct 8, 2026
433c85c
Merge pull request #745 from RayforceDB/perf/hash-index-build
singaraiona Oct 8, 2026
e767c04
Merge pull request #746 from RayforceDB/fix/heap-watermark-712
singaraiona Oct 8, 2026
06a7b56
perf(scan): read ahead the columns a pass reads on cold storage (#747)
ser-vasilich Oct 8, 2026
9c76c90
fix(store): a reader keeps up with a table that is being rewritten (#…
ser-vasilich Oct 8, 2026
d02757c
perf(parquet): import column by column when memory is short, through …
ser-vasilich Oct 8, 2026
0fe8318
perf(query): isolate sparse group-count worker slices (#741)
singaraiona Oct 8, 2026
57f5cfe
fix(query): compare ordered symbols by lexical value (#743)
singaraiona Oct 8, 2026
24c14e8
perf(query): compose safe nested selects before planning (#754)
singaraiona Oct 8, 2026
f91f52f
fix(query): align membership, concat, and grouped fallback semantics …
singaraiona Oct 10, 2026
676c2f0
fix(query): sort and take a no-output grouping on a computed key (#772)
ser-vasilich Oct 11, 2026
869ded1
perf(import): bound parquet symbol import and splayed hash-index I/O …
ser-vasilich Oct 11, 2026
86bc380
fix(eval): closure scoping, eval windows and key purity (#777)
ser-vasilich Oct 11, 2026
d17dfbc
fix(heap): relieve memory on evidence of a spill, discard parked spil…
ser-vasilich Oct 11, 2026
16f9401
perf(store): reuse unchanged partitions across parted mounts (#761)
singaraiona Oct 11, 2026
92e37db
fix(store): release unused partition domains before splayed I/O (#782)
singaraiona Oct 11, 2026
1789a4d
fix(test): read pf_sink so clang accepts test_pool.c (#775)
vbmithr Oct 12, 2026
5c4dde9
fix(query): a multi-key select with a distinct count beside an expres…
singaraiona Oct 12, 2026
c5f2765
fix(query): release the filter result in the count-distinct rewrite (…
ihrfv Oct 12, 2026
43b9941
fix: empty-left in answers B8; balance sys-mapped on map and unmap (#…
ser-vasilich Oct 12, 2026
b5a813a
fix: string membership in and out of queries; null equality across ty…
ser-vasilich Oct 12, 2026
a9f0ab2
fix(test): drop a late _POSIX_C_SOURCE define in test_link.c (#774)
vbmithr Oct 13, 2026
6e13d19
fix(app): validate CLI integers and cap worker count (#793)
belowzeroff Oct 13, 2026
060c273
fix(log): reject arguments to snapshot and sync (#795)
belowzeroff Oct 13, 2026
902c851
fix(datalog): finalize owned programs and guard serialization (#797)
belowzeroff Oct 13, 2026
7911350
fix(system): reject arguments to read-only introspection calls (#798)
belowzeroff Oct 13, 2026
6a77363
test(app): cover CLI argument errors (#799)
belowzeroff Oct 13, 2026
6f07156
build: scope section GC flags to static library (#804)
belowzeroff Oct 13, 2026
de67240
fix(pool): run tasks past the ring in further rounds of the same grai…
ser-vasilich Oct 13, 2026
4a0250c
fix(sort,window,group): unsigned key spans, numeric F64 composite ord…
ser-vasilich Oct 13, 2026
bb43a73
docs(readme): document embedding as a static library (#783)
phillc73 Oct 13, 2026
2f4605b
fix(group,query): parted STR/LIST group merge; composite keys at full…
ser-vasilich Oct 13, 2026
a9c5bdc
fix(group): parted avg/var over nulls, binary-agg second operand, key…
ser-vasilich Oct 14, 2026
f569750
fix(eval): print an uncaught raise's value, rendered lazily and bound…
vbmithr Oct 14, 2026
835f15f
fix(lang): implement multi-branch if in both evaluators (#812)
vbmithr Oct 14, 2026
7524357
docs: name resolution in queries; take cycles (#817)
vbmithr Oct 14, 2026
7ff58fd
fix(domain): abort cancelled batch interns before commit (#825)
belowzeroff Oct 14, 2026
ad90f6a
fix(query): sort, take, format and serialize parted tables in place (…
ser-vasilich Oct 14, 2026
6006083
fix(domain): free the superseded generation at reopen instead of reti…
ihrfv Oct 14, 2026
13606f2
feat(lang): indexed times, (times [i n] body...) (#827)
vbmithr Oct 14, 2026
9720da0
fix(collection): at keeps a typed vector's type for any integer index…
vbmithr Oct 14, 2026
4a29db4
fix(cmp): comparisons and and/or/not work element-wise on a LIST (#830)
vbmithr Oct 14, 2026
3646332
fix(cmp): dyadic min/max give the operands' promoted type; LIST resul…
vbmithr Oct 14, 2026
0ae4495
fix(dict): release distinct error values on failure (#834)
belowzeroff Oct 16, 2026
233cd34
fix(sys): skip memory flag value in .sys.args (#835)
belowzeroff Oct 16, 2026
be19c86
fix(compile): preserve signed zero in constant pool (#836)
belowzeroff Oct 16, 2026
94a77ee
fix(collection): reverse tables and dictionaries (#837)
belowzeroff Oct 16, 2026
c9d863d
fix(query,group): parted where/take/group fixes; column-free aggregat…
ser-vasilich Oct 16, 2026
74a9f18
fix(alter): amend a dotted target in place when its dict chain is sol…
vbmithr Oct 16, 2026
d91801f
fix(group): sort nullable min groups after aggregation (#843)
belowzeroff Oct 16, 2026
313f191
fix(group): avoid raw-sum ranking for affine top-N (#844)
belowzeroff Oct 16, 2026
a436b3f
perf(sort): reuse already ordered select input (#847)
belowzeroff Oct 16, 2026
2faf4b3
test(heap): measure discarded spill pages against the dirty ones (#857)
ser-vasilich Oct 16, 2026
3e48d55
fix(hof): map, fold and scan box a typed vector one element at a time…
vbmithr Oct 16, 2026
65a8a3e
perf(join): use asof index for null-free symbol keys (#848)
belowzeroff Oct 16, 2026
cc6236b
fix(alter): reject local targets before global writes (#846)
belowzeroff Oct 16, 2026
364cc1b
fix(build): select clang by default and test clang 23 in CI (#845)
belowzeroff Oct 16, 2026
9299821
fix(csv,splay): a cancelled splayed write publishes nothing (#860)
ser-vasilich Oct 16, 2026
2287056
fix(group): affine sum bias counts the non-null rows (#861)
ser-vasilich Oct 16, 2026
93ff47e
fix(store,collection): LIST cells keep inner nulls and GUIDs, table/d…
ser-vasilich Oct 16, 2026
17120ae
fix(query): eval-level grouping over parted tables, by-dict aliases a…
ser-vasilich Oct 17, 2026
eea553d
test: pool read-ahead and pty master-close tests hold on older kernel…
ser-vasilich Oct 17, 2026
0462f4b
perf(env): answer a dotted name's flat global lookup from a slot filt…
vbmithr Oct 17, 2026
ebae11c
fix(format): print a null symbol as ', not null (#872)
vbmithr Oct 17, 2026
9f8e6c3
fix(collection): take rows from a parted table handle (#867)
belowzeroff Oct 17, 2026
03ba8bf
fix(timeit): materialize a lazy result inside the timed span (#868)
belowzeroff Oct 17, 2026
237a982
fix(mem): free nested containers without recursing per level (#874)
ser-vasilich Oct 17, 2026
2129b8a
fix(build): rebuild the build-info objects when the version or date c…
vbmithr Oct 17, 2026
877ab84
fix(atom): keep a DATE or TIME atom within 32 bits, as its vector cel…
vbmithr Oct 17, 2026
72864a8
fix(parse): read a time literal's fraction as a decimal fraction of a…
vbmithr Oct 18, 2026
a1270d0
fix(store): never follow a link when removing what the store cleans u…
belowzeroff Oct 18, 2026
a6c52dc
perf(csr): build adjacency lists by counting sort instead of sorting …
morsel-ray Oct 18, 2026
d673759
fix(numparse): apply a parsed float's sign through its bits, not FP n…
morsel-ray Oct 18, 2026
1b6ba06
docs(sys): document every .sys.mem key (#890)
belowzeroff Oct 18, 2026
7b743a5
fix(query): decline unary numeric DAG ops on types their builtins rej…
belowzeroff Oct 18, 2026
8831906
fix(group): break top-N ties on first source row (#892)
belowzeroff Oct 18, 2026
ca13d6b
fix(group): strlen sum/avg skip the empty string on every route (#888)
ser-vasilich Oct 18, 2026
388265e
fix(query): sorted, taken and parted routes honour a lambda local tha…
ser-vasilich Oct 18, 2026
524de52
test(heap): check the spill discard where a punch cancels no writes (…
belowzeroff Oct 18, 2026
20e04bc
perf(csr): count and scatter edges on the pool when building a CSR (#…
morsel-ray Oct 19, 2026
8159bfc
fix(query): free the count-distinct where-sample chunk list once (#899)
morsel-ray Oct 19, 2026
96e1915
perf(query): keep integer rounding in the select DAG (#896)
belowzeroff Oct 19, 2026
424aa5c
fix(lang): parse F32 and GUID nulls and align F32 casting and printin…
vbmithr Oct 19, 2026
9c3d581
fix(exec): finalize parallel null flags only after workers join (#903)
morsel-ray Oct 19, 2026
9d3c69a
feat(store): add generation-2 compressed columns
singaraiona Oct 19, 2026
744116d
fix(query): preserve WHERE predicate row domains (#908)
morsel-ray Oct 19, 2026
d8cf73c
docs(query): explain filter domain barriers and static ranking (#909)
morsel-ray Oct 19, 2026
c9951bf
perf(group): batch staged SYM strlen accumulation (#910)
morsel-ray Oct 19, 2026
cbeb9ec
perf(query): take split WHERE rows without a full gather (#907)
ihrfv Oct 20, 2026
8560198
fix(cast): return ordinary BOOL and U8 values for null inputs (#913)
vbmithr Oct 20, 2026
8e2ece3
fix(query): decline temporal div and mod in the select DAG (#906)
belowzeroff Oct 20, 2026
67b3c46
test(mem): replace caller-heap fallback peak proxy with scoped oracle…
morsel-ray Oct 20, 2026
d199ae5
feat(lang): add q-style F32 literals (#911)
vbmithr Oct 20, 2026
631ad80
test(opt): exercise subset invariance on copied row subsets (#914)
morsel-ray Oct 20, 2026
555263a
fix(exec): isolate whole-row reader input domains (#916)
ihrfv Oct 20, 2026
0ea94d2
perf(vec): avoid double rounding bulk growth payloads (#925)
morsel-ray Oct 20, 2026
6464599
feat(lang): add nanosecond timespan values (#917)
vbmithr Oct 20, 2026
a58713b
perf(vec): keep sizing off reserved-capacity single appends (#938)
morsel-ray Oct 21, 2026
bda2f21
fix(graph): decline mixed symbol equality operands (#928)
morsel-ray Oct 21, 2026
f35b859
fix(xbar): a null atom gives a typed null (#931)
belowzeroff Oct 22, 2026
d9eead4
fix(expr): a zero divisor gives a null in fused arithmetic (#932)
belowzeroff Oct 22, 2026
5f44d2d
fix(group): keep the F64 type of a whole-number float bias in sum and…
belowzeroff Oct 22, 2026
d7153e7
perf(sort): rank symbols before parallel sortedness checks (#937)
vbmithr Oct 22, 2026
b0b0a1b
perf(query): avoid repeated parted metadata walks (#936)
morsel-ray Oct 22, 2026
5f6e619
fix(sort): use 32-bit TIME in sortedness shortcut (#939)
morsel-ray Oct 22, 2026
f7b23ec
perf(join): retain left columns for identity output mappings (#943)
vbmithr Oct 22, 2026
02804c3
perf(join): skip speculative hashing for minimum chained tables (#942)
morsel-ray Oct 22, 2026
014b98a
fix(cast): reject non-atom results in flat STR casts (#927)
morsel-ray Oct 22, 2026
62d9bff
perf(pool): size the default pool from the CPUs the process may run o…
ser-vasilich Oct 22, 2026
d4899d9
docs(pmap): describe sequential callbacks and kernel parallelism (#949)
morsel-ray Oct 23, 2026
1c86992
fix(strop): handle delimiters longer than split input (#953)
belowzeroff Oct 23, 2026
6eb7a61
perf(env): index global binding writes by symbol (#955)
vbmithr Oct 23, 2026
b30a594
perf: memory bounds on small machines, wide dense grouping, compresse…
ser-vasilich Oct 23, 2026
4529eb3
fix(enlist): restrict float promotion to I64/F64 atoms (#965)
morsel-ray Oct 23, 2026
c121003
fix(collection): return B8 for symbol prior comparisons (#967)
morsel-ray Oct 23, 2026
9956b0f
fix(arith): promote both integer atom subtraction operands (#979)
morsel-ray Oct 23, 2026
4c120ce
fix(query): distinguish dyadic minmax from reductions (#980)
morsel-ray Oct 24, 2026
d9f9ab6
fix(agg): compute TIMESPAN medians through rank kernels (#982)
morsel-ray Oct 24, 2026
580b1b2
chore(release): reconcile master ancestry for v3.0.1
morsel-ray Oct 24, 2026
2be297f
chore(release): reconcile master ancestry for v3.0.1 (#985)
morsel-ray Oct 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
45 changes: 35 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,51 @@ jobs:
include:
- os: ubuntu-latest
target: debug
compiler: gcc
- os: ubuntu-latest
target: release
compiler: gcc
- os: macos-latest
target: debug
compiler: clang
- os: macos-latest
target: release
compiler: clang

steps:
- uses: actions/checkout@v4

- name: Build (${{ matrix.target }})
run: make ${{ matrix.target }}
run: make ${{ matrix.target }} CC=${{ matrix.compiler }}

# Tests build their own debug+ASan objects, so they only make sense after a
# debug build. Running `make test` after `make release` reuses the
# release-compiled src objects (no -DDEBUG), which omits DEBUG-only symbols
# like ray_check_null_invariant and fails to link. The release legs still
# verify the optimized build compiles + links; the debug legs run the tests.
# The embedding archive has its own .lib.o flags: binary-only builds
# do not exercise codec strict-FP overrides in that profile.
- name: Build static library
if: matrix.target == 'release' && matrix.compiler == 'gcc'
run: make -j2 lib CC=${{ matrix.compiler }}

# Debug legs execute the sanitizer suite; release legs verify optimized
# artifacts. Runtime tests under release FP flags use the separate
# `make test-release` profile, not the debug suite below.
- name: Test
if: matrix.target == 'debug'
run: make test
run: make test CC=${{ matrix.compiler }}

# The default Ubuntu compiler is gcc. Exercise the suite with a recent
# upstream Clang as well, so new -Werror diagnostics reach CI before users
# of rolling-release toolchains encounter them.
clang-current:
runs-on: ubuntu-latest
env:
RAY_MARCH: x86-64
steps:
- uses: actions/checkout@v4
- name: Install Clang 23
run: |
wget -qO llvm.sh https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 23
- name: Test with Clang 23
run: make test CC=clang-23

# The suite with every assert() compiled out (-DNDEBUG). Our own builds keep
# asserts on, but CMake Release, distro packagers and `zig cc` define NDEBUG;
Expand Down Expand Up @@ -148,15 +172,16 @@ jobs:
# skipped required check can be treated as passed, silently opening the gate.
# static-analysis is intentionally NOT in `needs` — it is advisory only.
ci-success:
needs: [build-and-test, ndebug, fuzz-smoke, tsan]
needs: [build-and-test, clang-current, ndebug, fuzz-smoke, tsan]
if: always()
runs-on: ubuntu-latest
steps:
- name: Verify all required jobs passed
run: |
bt='${{ needs.build-and-test.result }}'
cl='${{ needs.clang-current.result }}'
nd='${{ needs.ndebug.result }}'
fz='${{ needs.fuzz-smoke.result }}'
ts='${{ needs.tsan.result }}'
echo "build-and-test: $bt ndebug: $nd fuzz-smoke: $fz tsan: $ts"
[ "$bt" = "success" ] && [ "$nd" = "success" ] && [ "$fz" = "success" ] && [ "$ts" = "success" ] || exit 1
echo "build-and-test: $bt clang-current: $cl ndebug: $nd fuzz-smoke: $fz tsan: $ts"
[ "$bt" = "success" ] && [ "$cl" = "success" ] && [ "$nd" = "success" ] && [ "$fz" = "success" ] && [ "$ts" = "success" ] || exit 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ compile_commands.json
# Extra build flavours (see Makefile)
rayforce.tsan
rayforce.test.tsan
rayforce.test.rel

# Fuzzing: grown corpus and crash artifacts stay local; only fuzz/seeds/ is committed
fuzz/corpus/
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ See [RELEASE.md](RELEASE.md) for how releases are cut.
## Local build notes

- Zero external dependencies; C17 toolchain only.
- `make` compiles with `clang` when `CC` is not set, so a machine without clang
fails at the first compile. `make CC=gcc` (or `CC=gcc` in the environment)
builds with gcc. The fuzz, TSan, coverage and `compdb` targets use clang
regardless of `CC`.
- Debug builds enable AddressSanitizer + UndefinedBehaviorSanitizer; warnings are
errors (`-Werror -Wall -Wextra`). A warning will fail CI, so fix them locally.
- The version reported by a local build is derived from git tags (`0.0.0` on an
Expand Down Expand Up @@ -96,6 +100,12 @@ The debug binaries load the ASan runtime DLL from `clang64\bin`, so keep it on
Beyond the ASan/UBSan test run, the repo carries a stability toolset. These
gate CI (fuzz smoke + TSan on every PR) and run deeper overnight.

Each PR is built with these compilers (`.github/workflows/ci.yml`): gcc for
the Ubuntu debug and release legs, clang for the macOS debug and release
legs, upstream Clang 23 from apt.llvm.org for the Ubuntu `clang-current` test
leg, and the Ubuntu runner's `clang` for the NDEBUG, fuzz-smoke and TSan
legs.

- **Fuzzing** (Linux + clang): coverage-guided targets under `fuzz/` cover the
parser, numeric scanners, the binary wire/journal decoder, and the sandboxed
evaluator, CSV, and journal-replay paths. `make fuzz-smoke` is the PR gate;
Expand Down
111 changes: 84 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
CC ?= clang
# GNU make predefines CC=cc, so ?= cannot select clang as the default.
# Keep command-line and environment overrides intact.
ifeq ($(origin CC),default)
CC = clang
endif
# Some targets need clang specifically regardless of $(CC): the fuzzing
# runtime (-fsanitize=fuzzer) and -MJ compilation-database fragments are
# clang-only. Same precedent as `make coverage`, which pins CC=clang.
Expand All @@ -25,12 +29,14 @@ VERSION_MAJOR := $(word 1,$(subst ., ,$(RAY_VERSION)))
VERSION_MINOR := $(word 2,$(subst ., ,$(RAY_VERSION)))
VERSION_PATCH := $(word 3,$(subst ., ,$(RAY_VERSION)))
GIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# The objects that embed GIT_HASH depend on a stamp rewritten only when the
# hash changes, so an incremental build after a new commit rebuilds them
# instead of keeping the previous hash (see GIT_HASH_OBJS below).
GIT_HASH_STAMP := build/.git-hash
$(shell mkdir -p build && { [ "$$(cat $(GIT_HASH_STAMP) 2>/dev/null)" = "$(GIT_HASH)" ] || echo "$(GIT_HASH)" > $(GIT_HASH_STAMP); })
BUILD_DATE := $(shell date -u +%Y-%m-%d)
# The objects that embed the build information (commit, version, build date)
# depend on a stamp rewritten only when one of them changes, so an incremental
# build after a new commit, a RAY_VERSION override or a new day rebuilds them
# instead of keeping the previous values (see BUILD_INFO_OBJS below).
BUILD_INFO := $(GIT_HASH) $(RAY_VERSION) $(BUILD_DATE)
BUILD_INFO_STAMP := build/.build-info
$(shell mkdir -p build && { [ "$$(cat $(BUILD_INFO_STAMP) 2>/dev/null)" = "$(BUILD_INFO)" ] || echo "$(BUILD_INFO)" > $(BUILD_INFO_STAMP); })

WARNS = -Wall -Wextra -Werror -Wstrict-prototypes -Wno-unused-parameter
DEFS = -DRAYFORCE_GIT_COMMIT=\"$(GIT_HASH)\" -DRAYFORCE_BUILD_DATE=\"$(BUILD_DATE)\" \
Expand Down Expand Up @@ -58,6 +64,10 @@ DEBUG_CFLAGS = -fPIC $(WARNS) -std=$(STD) -g -O0 -march=$(RAY_MARCH) -DDEBUG \
RELEASE_CFLAGS = -fPIC $(WARNS) -std=$(STD) -O3 -march=$(RAY_MARCH) \
-funroll-loops -fomit-frame-pointer -fno-math-errno -falign-functions=64 \
-fassociative-math -ffp-contract=fast -fno-signed-zeros -fno-trapping-math
# -ffunction-sections/-fdata-sections: isolate code/data so static-library
# clients can discard unused sections with linker GC. Keep this library-only:
# the server keeps nearly all code live and gains little from these flags.
LIB_CFLAGS = $(RELEASE_CFLAGS) -ffunction-sections -fdata-sections
# -falign-functions=64: start every function on a cache line. The default
# 16-byte alignment makes hot leaf functions' cost depend on where unrelated
# edits elsewhere in the same translation unit happen to push them —
Expand Down Expand Up @@ -152,6 +162,15 @@ HARDENED_CFLAGS = -fPIC $(WARNS) -std=$(STD) -O3 -march=$(RAY_MARCH) -g \
# the whole suite that way.
NDEBUG_CFLAGS = $(DEBUG_CFLAGS) -DNDEBUG

# Strict IEEE arithmetic for the ALP / ALP_RD codec (compressed-columns P5):
# its decode is a fixed expression (spec "ALP") and must give the same bits
# in every build profile, so reassociation, contraction and signed-zero
# folding are switched off for these objects only. Applied LAST on each
# pattern rule's command line, so it overrides the profile's fast-math flags.
STRICT_FP_CFLAGS := -fno-fast-math -fno-unsafe-math-optimizations -fno-associative-math \
-fno-reciprocal-math -fsigned-zeros -ffp-contract=off
FP_STRICT_src/store/enc_alp := $(STRICT_FP_CFLAGS)

CFLAGS = $(DEBUG_CFLAGS)
LDFLAGS = $(DEBUG_LDFLAGS)

Expand All @@ -166,6 +185,7 @@ TEST_OBJ = $(TEST_SRC:.c=.o)

# Per-flavour object lists (see the flavour CFLAGS block above).
REL_LIB_OBJ = $(LIB_SRC:.c=.rel.o)
LIB_LIB_OBJ = $(LIB_SRC:.c=.lib.o)
REL_MAIN_OBJ = $(MAIN_SRC:.c=.rel.o)
FUZZ_LIB_OBJ = $(LIB_SRC:.c=.fuzz.o)
TSAN_LIB_OBJ = $(LIB_SRC:.c=.tsan.o)
Expand All @@ -176,48 +196,63 @@ HARD_MAIN_OBJ = $(MAIN_SRC:.c=.hard.o)
NDEBUG_LIB_OBJ = $(LIB_SRC:.c=.ndebug.o)
NDEBUG_MAIN_OBJ = $(MAIN_SRC:.c=.ndebug.o)
NDEBUG_TEST_OBJ = $(TEST_SRC:.c=.ndebug.o)
RELT_LIB_OBJ = $(LIB_SRC:.c=.reltest.o)
RELT_TEST_OBJ = $(TEST_SRC:.c=.reltest.o)

# Auto-generated header dependencies (one .d per .o, see DEPFLAGS).
# The fragments are -included at the very END of this file — including
# them here would let a .d's first rule (e.g. `foo.o: ...`) become the
# default goal, so bare `make` would build one object instead of `debug`.
DEPS = $(LIB_OBJ:.o=.d) $(MAIN_OBJ:.o=.d) $(TEST_OBJ:.o=.d) \
$(REL_LIB_OBJ:.o=.d) $(REL_MAIN_OBJ:.o=.d) \
$(REL_LIB_OBJ:.o=.d) $(REL_MAIN_OBJ:.o=.d) $(LIB_LIB_OBJ:.o=.d) \
$(FUZZ_LIB_OBJ:.o=.d) \
$(TSAN_LIB_OBJ:.o=.d) $(TSAN_MAIN_OBJ:.o=.d) $(TSAN_TEST_OBJ:.o=.d) \
$(HARD_LIB_OBJ:.o=.d) $(HARD_MAIN_OBJ:.o=.d) \
$(NDEBUG_LIB_OBJ:.o=.d) $(NDEBUG_MAIN_OBJ:.o=.d) $(NDEBUG_TEST_OBJ:.o=.d)
$(NDEBUG_LIB_OBJ:.o=.d) $(NDEBUG_MAIN_OBJ:.o=.d) $(NDEBUG_TEST_OBJ:.o=.d) \
$(RELT_LIB_OBJ:.o=.d) $(RELT_TEST_OBJ:.o=.d)

# Default target (pinned so an -included .d fragment can't steal it).
.DEFAULT_GOAL := default
default: debug

%.o: %.c
$(CC) -c $(CFLAGS) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<
$(CC) -c $(CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

%.rel.o: %.c
$(CC) -c $(RELEASE_CFLAGS) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<
$(CC) -c $(RELEASE_CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

%.lib.o: %.c
$(CC) -c $(LIB_CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

%.fuzz.o: %.c
$(CLANG) -c $(FUZZ_CFLAGS) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<
$(CLANG) -c $(FUZZ_CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

# TSan objects build with clang: gcc's -Werror=tsan rejects standalone
# atomic_thread_fence (src/core/platform.h), which clang instruments fine.
%.tsan.o: %.c
$(CLANG) -c $(TSAN_CFLAGS) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<
$(CLANG) -c $(TSAN_CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

%.hard.o: %.c
$(CC) -c $(HARDENED_CFLAGS) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<
$(CC) -c $(HARDENED_CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

%.ndebug.o: %.c
$(CC) -c $(NDEBUG_CFLAGS) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

# Sources that embed GIT_HASH (ray_git_commit, the REPL and crash banners,
# and the test that compares ray_git_commit against it), in every object
# flavour.
GIT_HASH_SRCS := src/core/types src/app/repl src/core/crash test/test_types
GIT_HASH_OBJS := $(foreach v,.o .rel.o .fuzz.o .tsan.o .hard.o .ndebug.o,$(addsuffix $(v),$(GIT_HASH_SRCS)))
$(GIT_HASH_OBJS): $(GIT_HASH_STAMP)
$(CC) -c $(NDEBUG_CFLAGS) $(FP_STRICT_$*) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

# The C suite in the RELEASE FP profile (`make test-release`). Its own object
# flavour: the release flags plus -DDEBUG, because the suite calls test
# seams compiled only under DEBUG (platform.h, ipc.h, lang/internal.h);
# -DDEBUG changes no FP flag. The codec object gets the strict group as
# in every flavour; test sources are compiled with strict FP too, so their
# literals (e.g. -0.0) mean what they say. No sanitizers.
%.reltest.o: %.c
$(CC) -c $(RELEASE_CFLAGS) -DDEBUG $(FP_STRICT_$*) $(if $(filter test/%,$<),$(STRICT_FP_CFLAGS) -Itest) $(DEPFLAGS) $(DEFS) $(INCLUDES) -o $@ $<

# Sources that embed the build information (ray_git_commit and the version
# accessors, the REPL and crash banners, .sys.build, and the test that compares
# ray_git_commit against GIT_HASH), in every object flavour.
BUILD_INFO_SRCS := src/core/types src/app/repl src/core/crash src/ops/system test/test_types
BUILD_INFO_OBJS := $(foreach v,.o .rel.o .lib.o .fuzz.o .tsan.o .hard.o .ndebug.o .reltest.o,$(addsuffix $(v),$(BUILD_INFO_SRCS)))
$(BUILD_INFO_OBJS): $(BUILD_INFO_STAMP)

# Main binary for debug/test (some tests spawn ./$(TARGET) as a server).
$(TARGET): $(LIB_OBJ) $(MAIN_OBJ)
Expand All @@ -234,8 +269,9 @@ release: $(REL_LIB_OBJ) $(REL_MAIN_OBJ)
$(CC) $(RELEASE_CFLAGS) -o $(TARGET) $(REL_LIB_OBJ) $(REL_MAIN_OBJ) $(LIBS) $(RELEASE_LDFLAGS)

# Static library
lib: $(REL_LIB_OBJ)
$(AR) rc lib$(TARGET).a $(REL_LIB_OBJ)
lib: $(LIB_LIB_OBJ)
rm -f lib$(TARGET).a
$(AR) rc lib$(TARGET).a $(LIB_LIB_OBJ)

# Release tarball: build the optimized binary and package it as
# dist/rayforce-<version>-<os>-<arch>.tar.gz plus a SHA-256 checksum.
Expand Down Expand Up @@ -279,6 +315,26 @@ test-ndebug: $(NDEBUG_LIB_OBJ) $(NDEBUG_MAIN_OBJ) $(NDEBUG_TEST_OBJ)
$(CC) $(NDEBUG_CFLAGS) -o $(TARGET).test $(NDEBUG_LIB_OBJ) $(NDEBUG_TEST_OBJ) $(LIBS) $(DEBUG_LDFLAGS) -Itest
RAYFORCE_CORES=$(TEST_CORES) ./$(TARGET).test $(TEST_ARGS)

# The suite over the .reltest.o flavour (see its pattern rule). Does not
# relink ./$(TARGET): tests that spawn it get whatever build is on disk.
test-release: $(RELT_LIB_OBJ) $(RELT_TEST_OBJ)
$(CC) $(RELEASE_CFLAGS) -o $(TARGET).test.rel $(RELT_LIB_OBJ) $(RELT_TEST_OBJ) $(LIBS) $(RELEASE_LDFLAGS)
RAYFORCE_CORES=$(TEST_CORES) ./$(TARGET).test.rel $(TEST_ARGS)

# Multi-GiB generation-2 STR pool limits (spec "Large data"). Needs ~10 GiB
# of RAM and ~5 GiB of free space under /tmp.
test-large: CFLAGS = $(DEBUG_CFLAGS)
test-large: LDFLAGS = $(DEBUG_LDFLAGS)
test-large: $(LIB_OBJ) $(MAIN_OBJ) $(TEST_OBJ)
$(CC) $(CFLAGS) -o $(TARGET).test $(LIB_OBJ) $(TEST_OBJ) $(LIBS) $(LDFLAGS) -Itest
RAYFORCE_CORES=$(TEST_CORES) ./$(TARGET).test -f large/

# Generation-2 wire structs compile to the same layout on wasm32 (no libc
# needed: test/wasm/stub supplies the three string.h declarations).
check-wasm32-layout:
clang --target=wasm32 -ffreestanding -fsyntax-only -std=c17 -Wall -Werror \
-Itest/wasm/stub -Isrc -Iinclude test/wasm/layout_check.c

# ─── ThreadSanitizer ────────────────────────────────────────────────
# Data-race detection for the lock-free pool/heap paths, which the
# default ASan build cannot see (ASan and TSan are mutually exclusive,
Expand Down Expand Up @@ -464,12 +520,13 @@ cppcheck:
.PHONY: tidy cppcheck

clean:
-rm -f $(LIB_OBJ) $(MAIN_OBJ) $(TEST_OBJ) $(REL_LIB_OBJ) $(REL_MAIN_OBJ)
-rm -f $(LIB_OBJ) $(MAIN_OBJ) $(TEST_OBJ) $(REL_LIB_OBJ) $(REL_MAIN_OBJ) $(LIB_LIB_OBJ)
-rm -f $(FUZZ_LIB_OBJ) $(TSAN_LIB_OBJ) $(TSAN_MAIN_OBJ) $(TSAN_TEST_OBJ) \
$(HARD_LIB_OBJ) $(HARD_MAIN_OBJ) \
$(NDEBUG_LIB_OBJ) $(NDEBUG_MAIN_OBJ) $(NDEBUG_TEST_OBJ)
$(NDEBUG_LIB_OBJ) $(NDEBUG_MAIN_OBJ) $(NDEBUG_TEST_OBJ) \
$(RELT_LIB_OBJ) $(RELT_TEST_OBJ)
-rm -f $(DEPS)
-rm -f $(TARGET) $(TARGET).test lib$(TARGET).a
-rm -f $(TARGET) $(TARGET).test $(TARGET).test.rel lib$(TARGET).a
-rm -f $(TARGET).tsan $(TARGET).test.tsan
-rm -rf build build_release build_fuzz build_compdb dist
# Test-generated fixtures (see test/rfl/system/*.rfl) — should not linger after a run.
Expand All @@ -478,7 +535,7 @@ clean:
-rm -f cov-*.profraw default.profraw coverage.profdata
-rm -rf coverage_html

.PHONY: default debug release lib dist test test-ndebug coverage compdb tsan tsan-test hardened fuzz-smoke tidy cppcheck clean
.PHONY: check-wasm32-layout default debug release lib dist test test-ndebug test-release test-large coverage compdb tsan tsan-test hardened fuzz-smoke tidy cppcheck clean

# Header dependencies last: .d fragments only add prerequisites to the
# object targets above, and being last they can't hijack the default goal.
Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ make test # run full test suite
./rayforce # start the Rayfall REPL
```

`make` compiles with `clang` when `CC` is not set; `make CC=gcc` (or `CC=gcc`
in the environment) builds with gcc.

## Rayfall REPL

Rayforce ships with **Rayfall** — a Lisp-like query language with a rich set
Expand Down Expand Up @@ -140,6 +143,45 @@ int main(void) {
}
```

## Embedding

`make lib` builds the engine as a static library, `librayforce.a`, with no
dependencies beyond libc, libm and pthreads. The build compiles library
objects with `-ffunction-sections -fdata-sections` (the Makefile's
`LIB_CFLAGS` flavour, applied automatically to the `.lib.o` objects that go
into the archive), so no extra flags are needed at this step.

To discard everything your code never reaches, pass `-Wl,--gc-sections` to
the linker on the final link, and `-s` to strip the result. A DAG-route
client, meaning one that builds and executes query plans through the
`ray_graph_*`, `ray_scan` and `ray_execute` C API and never calls
`ray_eval_str` or loads `.rfl` files, never touches the Rayfall parser,
compiler, REPL or IPC server, and section GC drops that whole surface
(mixing the two routes pulls the parser back in):

```sh
make clean && make lib
cc -O2 -Iinclude -Isrc examples/analytics.c librayforce.a \
-lm -lpthread -Wl,--gc-sections -s -o analytics
```

The command above is the Linux one. On macOS, use `-Wl,-dead_strip` in
place of `-Wl,--gc-sections` (the Makefile's platform block does the same
for its own release links). On MinGW, link the winsock libraries as well:
`-lws2_32 -lmswsock -lkernel32 -ladvapi32`, with the same section-GC flag
the toolchain accepts.

A checkout at the current commit links `analytics.c` to a 3.47 MB
stripped binary, from a 10.22 MB archive; sizes move with the tree, so
this is just one measurement, not a bound.

Memory follows consumed-argument conventions documented per function in
the headers: arguments marked `consumes` are released by the call, and
returns marked `borrowed` stay owned by the container. On error paths the
library releases the references it holds. Values are COW, managed with
`ray_retain`/`ray_release`; error objects are owned and freed with
`ray_error_free`.

## How It Works

**Build** — Construct a lazy DAG: scans, filters, joins, aggregations, window
Expand Down
Loading
Loading