Avoid redundant expansion stack and closed-child accounting work
This commit is contained in:
1 parent
8903ae6c7a
commit
7164b1915a
2 files changed
+24
-5
No files matched your search
@@ -1113,6 +1113,15 @@ impl Executor {
|
|||||||
if self.expansion_depth >= scan_stack::limit(self.limits.input_depth) {
|
if self.expansion_depth >= scan_stack::limit(self.limits.input_depth) {
|
||||||
return self.fail("native expansion nesting limit exceeded");
|
return self.fail("native expansion nesting limit exceeded");
|
||||||
}
|
}
|
||||||
|
// Literal and frozen tokens cannot recurse. Keep the logical
|
||||||
|
// depth check above and reserve stack growth for command expansion.
|
||||||
|
if input.frozen {
|
||||||
|
return Ok(Some((input, None)));
|
||||||
|
}
|
||||||
|
if let TokenKind::Character(character, category) = input.token.kind {
|
||||||
|
let meaning = Meaning::Character(TokenKind::Character(character, category));
|
||||||
|
return Ok(Some((input, Some(meaning))));
|
||||||
|
}
|
||||||
self.expansion_depth += 1;
|
self.expansion_depth += 1;
|
||||||
let result = scan_stack::enter(|| {
|
let result = scan_stack::enter(|| {
|
||||||
self.expand_with_pending_tokens(input, files, definition_context)
|
self.expand_with_pending_tokens(input, files, definition_context)
|
||||||
|
|||||||
@@ -440,11 +440,12 @@ impl EntryCheckpoint {
|
|||||||
let tail = completed.events.get(old.events.len()..)?;
|
let tail = completed.events.get(old.events.len()..)?;
|
||||||
let retained_history = if completed.accounts_event_history {
|
let retained_history = if completed.accounts_event_history {
|
||||||
measure(timings.as_deref_mut().map(|timings| &mut timings.retained_accounting), || {
|
measure(timings.as_deref_mut().map(|timings| &mut timings.retained_accounting), || {
|
||||||
if current.events.len() == old.events.len()
|
let exact_history = || {
|
||||||
&& current.equivalent_accounting_history_with_source_resize(old, resize)
|
(current.events.len() == old.events.len()
|
||||||
{
|
&& current.equivalent_accounting_history_with_source_resize(old, resize))
|
||||||
return Some(None);
|
.then_some(None)
|
||||||
}
|
};
|
||||||
|
let adjusted_history = || {
|
||||||
// Shipout reports also contribute to later diagnostic
|
// Shipout reports also contribute to later diagnostic
|
||||||
// counters. Only translate the final report here.
|
// counters. Only translate the final report here.
|
||||||
let has_final_report = matches!(tail.last(),
|
let has_final_report = matches!(tail.last(),
|
||||||
@@ -457,6 +458,15 @@ impl EntryCheckpoint {
|
|||||||
}
|
}
|
||||||
let history = current.retained_history_offset(old, resize)?;
|
let history = current.retained_history_offset(old, resize)?;
|
||||||
Some((!history.is_identity()).then_some(history))
|
Some((!history.is_identity()).then_some(history))
|
||||||
|
};
|
||||||
|
if source_id != self.entry {
|
||||||
|
// An exhausted child splice publishes results without
|
||||||
|
// carrying later checkpoints. Try the final report proof
|
||||||
|
// first to avoid recounting the same retained allocations.
|
||||||
|
adjusted_history().or_else(exact_history)
|
||||||
|
} else {
|
||||||
|
exact_history().or_else(adjusted_history)
|
||||||
|
}
|
||||||
})?
|
})?
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in new issue
Block a user