Retain shared material across edited native page checkpoints
This commit is contained in:
1 parent
c42a1a72aa
commit
9a6c162b46
5 files changed
+251
-17
No files matched your search
@@ -1,4 +1,6 @@
|
||||
use super::*;
|
||||
mod material;
|
||||
use material::MaterialReuse;
|
||||
|
||||
impl InputFrame {
|
||||
fn same_at_shipout(&self, other: &Self) -> bool {
|
||||
@@ -159,15 +161,28 @@ impl EntryCheckpoint {
|
||||
pub fn prepare_suffix_rebase<'a>(
|
||||
&'a self,
|
||||
prior: &'a Self,
|
||||
) -> impl Fn(&Self) -> Option<Self> + 'a {
|
||||
// Keep the old allocation for an unchanged event. Later snapshots
|
||||
// can still refer to it even when the live run rebuilt that event.
|
||||
completed: &Execution,
|
||||
) -> Option<impl Fn(&Self) -> Option<Self> + 'a> {
|
||||
// A restored checkpoint may later be asked to account for its
|
||||
// history, even if the job that furnished the suffix did not.
|
||||
if !completed.accounts_event_history
|
||||
&& !self.executor.equivalent_accounting_history(&prior.executor)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
// Keep the old allocations of unchanged material, including inside
|
||||
// edited events, since later snapshots can still refer to them.
|
||||
let mut prefix = prior.executor.events.clone();
|
||||
let mut current = self.executor.events.iter();
|
||||
let mut material = MaterialReuse::default();
|
||||
for chunk in &mut prefix.prefix {
|
||||
let changes: Vec<_> = chunk.iter().zip(current.by_ref()).enumerate()
|
||||
.filter(|(_, (old, new))| !std::ptr::eq(*old, *new) && old != new)
|
||||
.map(|(index, (_, new))| (index, new.clone()))
|
||||
.map(|(index, (old, new))| {
|
||||
let mut new = new.clone();
|
||||
material.event(old, &mut new);
|
||||
(index, new)
|
||||
})
|
||||
.collect();
|
||||
if !changes.is_empty() {
|
||||
let events = Arc::make_mut(chunk);
|
||||
@@ -176,7 +191,7 @@ impl EntryCheckpoint {
|
||||
}
|
||||
}
|
||||
}
|
||||
move |later| self.rebase_verified_suffix(prior, later, &prefix)
|
||||
Some(move |later: &Self| self.rebase_verified_suffix(prior, later, &prefix))
|
||||
}
|
||||
|
||||
fn rebase_verified_suffix(
|
||||
|
||||
Reference in new issue
Block a user