Repository navigation
sysl 0.13.0
The fastest sysl yet: on Are We Fast Yet it takes 1.23 times as long as C++ (1.52 in 0.12.0), the reference-count work the compiler can prove unnecessary is gone from calls through closures, trait objects and locals, and regex search is about twenty-five times faster. A new short string form, held in the value itself, ships in this release but stays off unless you ask for it. Several changes alter what compiles; they are listed first.
Install
brew install sysl-lang/tap/sysl
or download sysl-0.13.0-darwin-arm64.tar.gz below and put its bin/ on your PATH; the compiler finds share/sysl/library beside itself.
Behaviour changes
The short string form is opt-in. A string of 15 bytes or fewer (7 on a 32-bit target) can be held in the string value itself, with no allocation. It is not yet faster on every program (the Json benchmark is slower with it on), so it ships off by default; SYSL_SHORT_STRINGS=1 turns it on for a build. With it off, every string is long, byte for byte as before the form existed. Of its seven behaviour changes, one holds in both forms and six only with SYSL_SHORT_STRINGS=1:
- Both forms: a
stringhanded to anexternparameter marked@keepscarries one count to C, and C hands it back by answering the string. A string C never hands back is held for the rest of the program; a literal needs no count. A string lent to a parameter that is not kept crosses for the call only. - Form on: a string of 15 bytes or fewer is held in its own words. The
stringtype is unchanged; reference/strings.md describes the form. - Form on:
.bytesof a short string is a copy in the frame, copied to the heap once if the view outlives the frame. A write to the variable after taking.bytesnever changes the view, and two.bytesof one short string are two addresses.--explain-escapesnames the copy. - Form on: under
@no_alloc, returning or storing a.bytesthat may be short is refused ("this view of 's.bytes' is returned, and the string may hold its bytes in itself"). A literal, a cut of a literal andstr_vieware never short and pass. With the form off this compiles as before. - Form on: a raw pointer into
s.bytesthat would outlive the frame is refused, as is a pointer a C function answers where it may point into a string argument that is returned or stored. Lend it at the call that reads it, copy the bytes into aBuf[u8]you own, or usec"…". With the form off no org package needs a change. - Form on: an
externtaking a string by value gets a pointer valid for the call, and a C-returned short string is refused at run time. - A compiled library records which form it was built with, and a build in the other form refuses it by name instead of linking it. With the default (off) this only matters for a library built with the flag on.
- Form on: counted-heap and allocation counts are lower (
SYSL_COUNT_ALLOCS,SYSL_COUNT_BYTES), which a test that pins an exact count will see.
Behaviour changes in the type checker and the language:
- A call through a closure or a trait object takes no count where every implementation answers a reference read out of its arguments, in a program's own build (BI8). The program's tables gain one slot after the ordinary ones; libraries, archives and C see unchanged tables. A function whose parameter is passed by address also gets the count-free entry.
- A struct alias constructs and matches as the struct.
type G3 = G[3]makesG3(5)aG[3],type BI = Bx[long]makesBI(5)aBx[long](it was aBx[int]), and a generic alias of a struct is a constructor too (PA(5),PA[int](6)).val g: G[4] = G3(5)andBI(5)where aBx[int]is wanted are now refused as mismatches; both were wrongly accepted. - Untyped integer constant arithmetic is exact, as a literal's is.
const Half = 200; val x: u8 = Half * 2is refused at compile time, andh(Half * 2)picks its overload ash(200 * 2)does. - A comparison chain whose middle operand is an unparenthesised
&,|or^is refused, sinceboolnow has those operators (see Features). - A generic's length and type parameters are symbols in its own declaration.
Box[T]whereBox[U]is declared, and an array length or lane count that differs from the declared one, are refused at the declaration whether or not anything calls it; a closure's result is checked against a declared&Fn. reference/generics.md, vectors.md and arrays.md have the rules. - An
externnaming an AES, SHA-3 or dot-product LLVM instruction takes and returns vectors, as the instruction does. load_relaxedandSeqLock[T]accept aPlainTwith no zero value, and the codec decodes an array of such elements. Avarof a type with no zero value inside a generic instance is reported at the caller's line, naming the instance.Regexgains two private fields, so aRegexcannot be built by a literal outside its module.- A
@no_allocrefusal of an interpolation says "the string a value renders as"; the refusal is the same. - Allocation counts change where a box is laid in the frame. A
&Tnothing keeps past its frame, including a factory's answer kept locally, now lives in the frame; destructors run exactly as before.
Features
boolhas&,|,^,&=,|=and^=, without short-circuit.slot_empty()gives an empty local (var out: T = slot_empty()) for a type with no zero value.Carrying: everyuNhasadd_carryandsub_borrow, lowered to LLVM's overflow intrinsics;bigint's portable loops use them.sysl.cpu:cpu.has("sha3")asks the running processor (sysctl on macOS,getauxvalon Linux and Android, cpuid on x86-64) to guard an@uncheckedfast path. A name that is not an@extensionsname is refused at compile time; a call on a bare-metal target is refused.- Crypto and dot-product intrinsics for AArch64 (AES, SHA-3, dot product) and x86-64 (AES-NI, AVX-VNNI) under
@extensionsand@unchecked. The x86-64 ones are built, not run. @views(self)members taking*selfreadself.bytesin place, with no copy, short or long;Searchuses it (view_in_place), sos.index_of(…)ands.starts_with(…)allocate nothing.sysl testhonours--explain-escapesand--explain-borrows, and--explain-borrowsnow reports locals, calls through trait objects and closures, and functions answered through function values.sysl import-creads a C string macro as ac const … at string, and refuses a wide literal and a non-literalcharpointer by name.- A generic alias of a struct constructs, and an
if constover an enum value parameter accepts the bare variant (see Fixed).
Performance
- Are We Fast Yet, against C++ (30 × 10, Apple M5 Pro): sysl is 1.226 times C++ (95% interval 1.223 to 1.229), from 1.521 on 0.12.0. The geometric mean of each language's time relative to C, fastest first: C 1.000, Zig 1.044, C++ 1.116, Rust 1.209, sysl 1.369. Per benchmark against C++: List 4.37 to 1.09, Permute 2.16 to 1.26, Towers 1.88 to 1.15, Queens 1.96 to 1.68, DeltaBlue 1.47, Havlak 1.29, Json 1.30, Richards 1.81, CD 1.70; sysl is faster on Bounce (0.96) and NBody (0.90). Richards, CD, Queens, DeltaBlue and Json are where sysl is still slowest. The full per-benchmark tables against C++, C, Rust and Zig are on the new Performance page and in the README.
- plb2: sysl is 1.03 times C, with C 1.00, D 1.01, Nim 1.02, Rust 1.04 (over three programs, Rust's bedcov prints a wrong answer) and Swift 1.11. Zig has no cells: upstream's programs do not build on Zig 0.17.1.
- Json, the short-form regression, is gone. With the form off (the default) Json runs at 175 ms against 0.12.1's 173 ms; the opt-in form-on path improved from 214 ms to 183 ms, because
==and substring bounds checks no longer copy the string to the stack. - Less reference counting. A local that only walks storage takes no count; an argument handed to a closure or trait-object call takes none when nothing that call can reach writes through it; a rebound or rewritten parameter, a held argument, an unwrapped pair and a call's live kills are all worked out; a reference read out of a field that is written before it is read again is moved out (no count in either direction); a box laid in the frame has its counts elided, including one handed to a trait object or closure.
--explain-borrowssays which and why. AWFY List went from 49.7 ms to 11.6 ms per iteration. - Growth moves instead of copying. A
Bufthat grows with one holder is onememmoveand a count raise, as in C++. - A failed bounds check is one call to a cold stub, so small functions inline again.
- String interpolation builds in one buffer, with up to 64 bytes of
DisplayandDebugoutput in a frame scratch: one allocation, not one per piece. - Regex search uses a lazy DFA forwards and backwards, falling back to the VM only for captures. regex-redux on a 5,000,000-line fasta goes from 33.7 s on 0.12.1 to 1.36 s (PCRE2 with its JIT: 1.59 s, Rust's regex crate: 1.60 s).
- Emitting a function whose body is one long block is linear instead of quadratic in its length, and inferring which locals need no count no longer slows compilation of large programs.
Fixed
- A box laid in a frame now tears down as a heap box does: releases inside its destructor wait for the destructor, and a frame box let go of inside a running drain is torn down before its frame ends (this used to fault). A value read through a pointer keeps its count across a call that overwrites module storage holding it. A box whose address is read through a cast to another pointer type stays on the heap, which fixes a leak from viewing a
&sync Frozen. - A closure laid in the frame and kept by what a call answers (a factory box, a struct returned by value) was torn down at the end of the statement that made it, so a later call read freed memory. It now lives as long as the answer.
- A struct is constructed and matched through its alias as the reference says, including a generic alias, and
val P(a, b) = …and aP{x}arm match throughtype P = Point. An alias of a generic alias (type PB[T] = PA[T]) is still refused. if const M == Aworks whenMis an enum value parameter and the variant is written bare; onlyM == Mode.Aworked.- The regex library no longer declares a cache that does not fit
usizeon a 16-bit target.
Tests
- Full suite on the release tree (
SYSL_DOCS=1, stage 2): 26901 passed, 0 failed, 3 ignored. --std: 2283 passed, 0 failed.- The stage-3 self check reports identical emit-llvm (3,097,691 lines).
- No consumer suites were run for this release.