Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ pub enum EventKind {
database_key: DatabaseKeyIndex,
},

WillIterateCycle {
/// The database-key for the cycle head. Implements `Debug`.
database_key: DatabaseKeyIndex,
iteration_count: u32,
fell_back: bool,
},

/// Indicates that `unwind_if_cancelled` was called and salsa will check if
/// the current revision has been cancelled.
WillCheckCancellation,
Expand Down
7 changes: 7 additions & 0 deletions src/function/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ where
if iteration_count > MAX_ITERATIONS {
panic!("{database_key_index:?}: execute: too many cycle iterations");
}
db.salsa_event(&|| {
Event::new(EventKind::WillIterateCycle {
database_key: database_key_index,
iteration_count,
fell_back,
})
});
revisions
.cycle_heads
.update_iteration_count(database_key_index, iteration_count);
Expand Down
1 change: 1 addition & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl Database for ExecuteValidateLoggerDatabase {
let event = event();
match event.kind {
salsa::EventKind::WillExecute { .. }
| salsa::EventKind::WillIterateCycle { .. }
| salsa::EventKind::DidValidateMemoizedValue { .. } => {
self.push_log(format!("salsa_event({:?})", event.kind));
}
Expand Down
7 changes: 4 additions & 3 deletions tests/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ fn cycle_unchanged() {
a.assert_value(&db, 59);
b.assert_value(&db, 60);

db.assert_logs_len(4);
db.assert_logs_len(5);

// next revision, we change only A, which is not part of the cycle and the cycle does not
// depend on.
Expand Down Expand Up @@ -917,7 +917,7 @@ fn cycle_unchanged_nested() {
a.assert_value(&db, 59);
b.assert_value(&db, 60);

db.assert_logs_len(10);
db.assert_logs_len(13);

// next revision, we change only A, which is not part of the cycle and the cycle does not
// depend on.
Expand Down Expand Up @@ -984,7 +984,7 @@ fn cycle_unchanged_nested_intertwined() {
e.assert_value(&db, 60);
}

db.assert_logs_len(12 + i);
db.assert_logs_len(15 + i);

// next revision, we change only A, which is not part of the cycle and the cycle does not
// depend on.
Expand Down Expand Up @@ -1031,6 +1031,7 @@ fn repeat_provisional_query() {
"salsa_event(WillExecute { database_key: min_iterate(Id(0)) })",
"salsa_event(WillExecute { database_key: min_panic(Id(1)) })",
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })",
"salsa_event(WillIterateCycle { database_key: min_iterate(Id(0)), iteration_count: 1, fell_back: false })",
"salsa_event(WillExecute { database_key: min_panic(Id(1)) })",
"salsa_event(WillExecute { database_key: min_panic(Id(2)) })",
]"#]]);
Expand Down
1 change: 1 addition & 0 deletions tests/cycle_tracked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ fn main() {
"WillExecute { database_key: cost_to_start(Id(401)) }",
"WillCheckCancellation",
"WillCheckCancellation",
"WillIterateCycle { database_key: cost_to_start(Id(403)), iteration_count: 1, fell_back: false }",
"WillCheckCancellation",
"WillCheckCancellation",
"WillCheckCancellation",
Expand Down