Repository navigation
Diamond 0.26.0
Added
-
A documentation site.
tools/docsite/build.d6(written in d6) turnsdocs/into the site
served at rolld6.codes/docs: a new beginner-friendly guide indocs/guide/for people who
already know another language, followed by the existing reference pages, with a sidebar,
an on-this-page panel and d6 syntax highlighting. Guide examples have a Run button that runs
them in the browser with the homepage's WebAssembly build, and every# =>claim in the guide
is checked bymake test-docs.make test-docsitebuilds the site and checks every link. -
Plain
d6 build. With no source file,d6 buildbuilds the project's entry file in
the current directory (main.d6, asfacet newgenerates, elseapp.d6or a legacyapp.di) and, unless-osays otherwise, names the binary after the
directory:cd greeter && d6 buildproduces./greeter.d6 build tool.d6still produces
tool.
Changed
-
Fewer regex allocations. Matches use call-local temporary capture storage
for small patterns, and boolean matches skip unused result storage. -
Faster regular expressions. The native regex library is now optimized in
every build, reducing the work and instruction-cache pressure of matching. -
Faster interpreter dispatch. Hot instructions reuse their operand bounds
check to prepare the next opcode, removing a separate end-of-code check. -
Int division rounds down.
/on twoInts now floors (rounds toward negative infinity),
like Ruby and Python and like%already did, instead of truncating toward zero:-7 / 2is
-4(was-3) and7 / -2is-4.(a / b) * b + a % b == anow holds for every sign mix,
arbitrary-precisionInts included. Results with both operands the same sign, or an exact
quotient, are unchanged. -
A leaner interpreter loop. With GCC on x86-64, the release build compiles the interpreter's
dispatch function on its own with flags that free one more CPU register for it, and arithmetic
on an Int constant no longer stalls on reading back the previous instruction's result. Across the
benchmark suite, programs run about 3.5% fewer cycles on average. Calls and loops over
collections gain the most: recursivefiband raising and rescuing exceptions each run about 8%
fewer cycles, and block iteration (each,times,reduce) about 9% fewer. A bare integer
counting loop runs about 7% more. With the JIT off, a call to a plain function also skips a
forwarding layer and two no-op frees: recursivefibruns another 8% fewer instructions, and
closures 5% fewer cycles. Method calls andnewskip the same layer: allocating objects and
calling their methods runs 5% fewer cycles. The interpreter now checks for pending signals and
for a supervisor or thread stop on backward jumps and calls instead of before every
instruction; resource limits and opcode counting still see every instruction. That cuts the
counting loop's cost by 14% (more than winning back the 7% above), a sieve by 19%, Float-heavy
mandelbrotby 14% andfibby 12%; across the suite, about 4% fewer cycles on average. -
Profile-guided release builds. With GCC,
make release(and so the .deb and .rpm packages)
now builds an instrumented binary, runs a few small training programs fromtools/pgo/, and
rebuilds using the profile, which adds well under a minute. Hot code is packed together and cold
code moved out of the way, so the processor's instruction cache stops thrashing: object-heavy code
runs about 14% faster, text processing 15%, tree building 13% and JSON 10%, and the benchmark suite
about 6.6% faster on average; tight integer loops are 1-2% slower.make release PGO=0builds
without it. clang builds are unchanged. -
Faster setters and Float arithmetic. A setter whose whole body stores its argument
(attr_accessor'sx=, or a one-fieldinitialize) is answered by writing the field,
without a call, the way getters already were; and Float-with-Float+ - * /no longer
leaves the interpreter's arithmetic instruction. An n-body simulation runs about 19% fewer
instructions and a Mandelbrot loop about 37% fewer. Both shortcuts also settle class-typed
fields (-> Node | Nil), so a binary-tree walk runs about 21% fewer. A warm call site
answers such a getter or setter before the method-call machinery is entered at all,
another 19% off the n-body simulation and 5-6% off object-heavy loops. -
Faster Array indexing and
Array.new. Reading or writing an Array element at an
in-bounds Int index is answered in the interpreter's own instruction, andArray * Int
(whichArray.new(n, fill)compiles to) fills the result natively instead of pushing one
element at a time: a sieve of Eratosthenes to a million runs about 63% fewer instructions. -
Native
each,each_with_index,reduceandtimes. Likemapandselectbefore
them, Array'seach,each_with_indexandreduceand Int'stimescall their block
from a loop in C instead of the prelude's d6 loop, about 45% fewer instructions per block
call.break,next,return, raises and errors behave as before. -
Native
Hash#fetch. A found key, or a missing key with a fallback, is answered with one
native lookup instead of the prelude'sinclude_key?plus[]: counting into a Hash with
counts[k] = counts.fetch(k, 0) + 1runs about 49% fewer instructions. A missing key with
no fallback raises the sameIndexErroras before. -
sub/gsubwith a String pattern skip the Regexp. When both the pattern and the
replacement are Strings and the replacement has no\escapes, the replace is a plain
substring search instead of compiling a Regexp on every call: a small-string workload
mixinggsubwithupcase,include?andsliceruns about 41% fewer instructions.
Interpolating an Int ("#{n}",to_s,join) no longer goes throughprintf: another
10% off that workload and 16% off a string-building one. Raising an exception builds its
backtrace entries the same way, about 15% off a loop that raises in one call of five.