tamer: tameld: Place constants into static section in executable
This is something that changed when the TAMER POC was initially created, as I was learning Rust. I don't recall the original reason why this was moved, but it could have been moved back long ago. In our systems, constants can hold tables (as matrices) with tens or hundreds of thousands of rows, and there are a number of them in certain projects. As an example, the YAML-based test cases for one of our systems went from ~2m30s to ~45s after this change was made. Much of the cost savings comes from saving GC.main
parent
53360548da
commit
90c6b51fd5
|
@ -18,6 +18,10 @@ NEXT
|
|||
====
|
||||
Compiler
|
||||
--------
|
||||
- Place constants into static section in linked executable.
|
||||
- This was the case in the old linker before the `tameld`
|
||||
proof-of-concept. The benefits are significant when large constants are
|
||||
used (e.g. for large tables of data).
|
||||
- Do not report value list optimization error on duplicate conjunctive
|
||||
predicates.
|
||||
- This doesn't emit code any differently, it merely permits the situation,
|
||||
|
|
|
@ -310,6 +310,7 @@ where
|
|||
IdentKind::RetMapHead
|
||||
| IdentKind::RetMap
|
||||
| IdentKind::RetMapTail => deps.retmap.push_body(ident),
|
||||
IdentKind::Const(_, _) => deps.consts.push_body(ident),
|
||||
_ => deps.rater.push_body(ident),
|
||||
},
|
||||
None => {
|
||||
|
@ -387,7 +388,8 @@ mod test {
|
|||
use super::super::graph::AsgError;
|
||||
use super::*;
|
||||
use crate::ir::asg::{
|
||||
Dim, IdentObject, TransitionError, TransitionResult, UnresolvedError,
|
||||
DataType, Dim, IdentObject, TransitionError, TransitionResult,
|
||||
UnresolvedError,
|
||||
};
|
||||
use crate::ir::legacyir::SymDtype;
|
||||
use crate::sym::SymbolIndex;
|
||||
|
@ -854,9 +856,10 @@ mod test {
|
|||
}
|
||||
|
||||
macro_rules! assert_section_sym {
|
||||
( $iter:expr, $s:ident ) => {{
|
||||
( $iterable:expr, $s:ident ) => {{
|
||||
let mut pos = 0;
|
||||
for obj in $iter {
|
||||
assert_eq!($iterable.len(), $s.len());
|
||||
for obj in $iterable.iter() {
|
||||
let sym = obj.name().expect("missing object");
|
||||
assert_eq!($s.get(pos), Some(sym));
|
||||
|
||||
|
@ -866,7 +869,7 @@ mod test {
|
|||
}
|
||||
|
||||
macro_rules! add_syms {
|
||||
($sut:ident, $base:expr, {$($dest:ident <- $name:ident: $kind:path,)*}) => {
|
||||
($sut:ident, $base:expr, {$($dest:ident <- $name:ident: $kind:expr,)*}) => {
|
||||
let mut i = 1;
|
||||
|
||||
$(
|
||||
|
@ -890,6 +893,7 @@ mod test {
|
|||
let mut worksheet = vec![];
|
||||
let mut map = vec![];
|
||||
let mut retmap = vec![];
|
||||
let mut consts = vec![];
|
||||
|
||||
let base = symbol_dummy!(1, "sym1");
|
||||
let base_node = sut
|
||||
|
@ -899,6 +903,7 @@ mod test {
|
|||
add_syms!(sut, &base, {
|
||||
meta <- meta1: IdentKind::Meta,
|
||||
worksheet <- work1: IdentKind::Worksheet,
|
||||
consts <- const1: IdentKind::Const(Dim::from_u8(0), DataType::Float),
|
||||
map <- map1: IdentKind::MapHead,
|
||||
map <- map2: IdentKind::Map,
|
||||
map <- map3: IdentKind::MapTail,
|
||||
|
@ -913,16 +918,18 @@ mod test {
|
|||
worksheet <- work2: IdentKind::Worksheet,
|
||||
map <- map6: IdentKind::MapTail,
|
||||
retmap <- retmap6: IdentKind::RetMapHead,
|
||||
consts <- const2: IdentKind::Const(Dim::from_u8(2), DataType::Float),
|
||||
});
|
||||
|
||||
map.push(base);
|
||||
|
||||
let sections = sut.sort(&vec![base_node])?;
|
||||
|
||||
assert_section_sym!(sections.meta.iter(), meta);
|
||||
assert_section_sym!(sections.worksheet.iter(), worksheet);
|
||||
assert_section_sym!(sections.map.iter(), map);
|
||||
assert_section_sym!(sections.retmap.iter(), retmap);
|
||||
assert_section_sym!(sections.meta, meta);
|
||||
assert_section_sym!(sections.worksheet, worksheet);
|
||||
assert_section_sym!(sections.map, map);
|
||||
assert_section_sym!(sections.retmap, retmap);
|
||||
assert_section_sym!(sections.consts, consts);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ pub struct Sections<'a, T> {
|
|||
pub params: Section<'a, T>,
|
||||
pub types: Section<'a, T>,
|
||||
pub funcs: Section<'a, T>,
|
||||
pub consts: Section<'a, T>,
|
||||
pub rater: Section<'a, T>,
|
||||
}
|
||||
|
||||
|
@ -143,6 +144,7 @@ impl<'a, T> Sections<'a, T> {
|
|||
params: Section::new(),
|
||||
types: Section::new(),
|
||||
funcs: Section::new(),
|
||||
consts: Section::new(),
|
||||
rater: Section::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,8 @@ impl<W: Write> XmleWriter<W> {
|
|||
.write_section(sections.worksheet.iter())?
|
||||
.write_section(sections.params.iter())?
|
||||
.write_section(sections.types.iter())?
|
||||
.write_section(sections.funcs.iter())
|
||||
.write_section(sections.funcs.iter())?
|
||||
.write_section(sections.consts.iter())
|
||||
})?
|
||||
.write_element(b"l:exec", |writer| {
|
||||
writer.write_section(sections.rater.iter())
|
||||
|
|
Loading…
Reference in New Issue