Skip to content

Diamond 0.26.0

Choose a tag to compare

@github-actions github-actions released this 05 Nov 19:31
· 303 commits to main since this release
e42eba0

Added

  • A documentation site. tools/docsite/build.d6 (written in d6) turns docs/ into the site
    served at rolld6.codes/docs: a new beginner-friendly guide in docs/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 by make test-docs. make test-docsite builds the site and checks every link.

  • Plain d6 build. With no source file, d6 build builds the project's entry file in
    the current directory (main.d6, as facet new generates, else app.d6 or a legacy app.di) and, unless -o says otherwise, names the binary after the
    directory: cd greeter && d6 build produces ./greeter. d6 build tool.d6 still 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 two Ints now floors (rounds toward negative infinity),
    like Ruby and Python and like % already did, instead of truncating toward zero: -7 / 2 is
    -4 (was -3) and 7 / -2 is -4. (a / b) * b + a % b == a now holds for every sign mix,
    arbitrary-precision Ints 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: recursive fib and 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: recursive fib runs another 8% fewer instructions, and
    closures 5% fewer cycles. Method calls and new skip 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
    mandelbrot by 14% and fib by 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 from tools/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=0 builds
    without it. clang builds are unchanged.

  • Faster setters and Float arithmetic. A setter whose whole body stores its argument
    (attr_accessor's x=, or a one-field initialize) 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, and Array * Int
    (which Array.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, reduce and times. Like map and select before
    them, Array's each, each_with_index and reduce and Int's times call 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's include_key? plus []: counting into a Hash with
    counts[k] = counts.fetch(k, 0) + 1 runs about 49% fewer instructions. A missing key with
    no fallback raises the same IndexError as before.

  • sub/gsub with 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
    mixing gsub with upcase, include? and slice runs about 41% fewer instructions.
    Interpolating an Int ("#{n}", to_s, join) no longer goes through printf: 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.