Mike Gerwitz
94bbc2d725
This is the culmination of a great deal of work over the past few weeks. Indeed, this change has been prototyped a number of different ways and has lived in a stash of mine, in one form or another, for a few weeks. This is not done just yet---I have to finish moving the index out of Asg, and then clean up a little bit more---but this is a significant simplification of the system. It was very difficult to reason about prior approaches, and this finally moves toward doing something that I wasn't sure if I'd be able to do successfully: formalize scope using AirAggregate's stack and encapsulate indexing as something that is _supplemental_ to the graph, rather than an integral component of it. This _does not yet_ index the AirIdent operation on the package itself because the active state is not part of the stack; that is one of the remaining changes I still have stashed. It will be needed shortly for package imports. This rationale will have to appear in docs, which I intend to write soon, but: this means that `Asg` contains _resolved_ data and itself has no concept of scope. The state of the ASG immediately after parsing _can_ be used to derive what the scope _must_ be (and indeed that's what `asg::air::test::scope::derive_scopes_from_asg` does), but once we start performing optimizations, that will no longer be true in all cases. This means that lexical scope is a property of parsing, which, well, seems kind of obvious from its name. But the awkwardness was that, if we consider scope to be purely a parse-time thing---used only to construct the relationships on the graph and then be discarded---then how do we query for information on the graph? We'd have to walk the graph in search of an identifier, which is slow. But when do we need to do such a thing? For tests, it doesn't matter if it's a little bit slow, and the graphs aren't all that large. And for operations like template expansion and optimizations, if they need access to a particular index, then we'll be sure to generate or provide the appropriate one. If we need a central database of identifiers for tooling in the future, we'll create one then. No general-purpose identifier lookup _is_ actually needed. And with that, `Asg::lookup_or_missing` is removed. It has been around since the beginning of the ASG, when the linker was just a prototype, so it's the end of TAMER's early era as I was trying to discover exactly what I wanted the ASG to represent. DEV-13162 |
||
---|---|---|
.. | ||
benches | ||
build-aux | ||
src | ||
tests | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
Makefile.am | ||
README.md | ||
autogen.sh | ||
bootstrap | ||
conf.sh.in | ||
configure.ac | ||
rustfmt.toml |
README.md
TAME in Rust (TAMER)
TAME was written to help tame the complexity of developing comparative insurance rating systems. This project aims to tame the complexity and performance issues of TAME itself. TAMER is therefore more tame than TAME.
TAME was originally written in XSLT. For more information about the
project, see the parent README.md
.
Building
To bootstrap from the source repository, run ./bootstrap
.
To configure the build for your system, run ./configure
. To build, run
make
. To run tests, run make check
.
You may also invoke cargo
directly, which make
will do for you using
options provided to configure
.
Note that the default development build results in terrible runtime performance! See [#Build Flags][] below for instructions on how to generate a release binary.
Build Flags
The environment variable CARGO_BUILD_FLAGS
can be used to provide
additional arguments to cargo build
when invoked via make
. This can be
provided optionally during configure
and can be overridden when invoking
make
. For example:
# release build
$ ./configure && make CARGO_BUILD_FLAGS=--release
$ ./configure CARGO_BUILD_FLAGS=--release && make
# dev build
$ ./configure && make
$ ./configure CARGO_BUILD_FLAGS=--release && make CARGO_BUILD_FLAGS=
Hacking
This section contains advice for those developing TAMER.
Running Tests
Developers should be using test-driven development (TDD). make check
will
run all necessary tests.
Code Format
Rust provides rustfmt
that can automatically format code for you. This
project mandates its use and therefore eliminates personal preference in
code style (for better or worse).
Formatting checks are run during make check
and, on failure, will output
the diff that would be applied if you ran make fmt
(or make fix
); this
will run cargo fmt
for you (and will use the binaries configured via
configure
).
Since developers should be doing test-driven development (TDD) and therefore
should be running make check
frequently, the hope is that frequent
feedback on formatting issues will allow developers to quickly adjust their
habits to avoid triggering formatting errors at all.
If you want to automatically fix formatting errors and then run tests:
$ make fmt check
Benchmarking
Benchmarks serve two purposes: external integration tests (which are subject
to module visibility constraints) and actual benchmarking. To run
benchmarks, invoke make bench
.
Note that link-time optimizations (LTO) are performed on the binary for benchmarking so that its performance reflects release builds that will be used in production.
The configure
script will automatically detect whether the test
feature
is unstable (as it was as of the time of writing) and, if so, will
automatically fall back to invoking nightly (by running cargo +nightly bench
).
If you do not have nightly, run you install it via rustup install nightly
.