Commit graph

50 commits

Author SHA1 Message Date
Lukas Wirth
211bc158df
Do manual trait casting (#922)
* Do manual trait upcasting instead of downcasting

* Remove another dynamic `zalsa` call

* Rename UpCaster back to DownCaster

* Address reviews
2025-07-31 15:56:13 +00:00
Ibraheem Ahmed
bb0831a640
Outline all tracing events (#942)
Some checks failed
Test / Test (push) Has been cancelled
Book / Book (push) Has been cancelled
Release-plz / Release-plz release (push) Has been cancelled
Release-plz / Release-plz PR (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Shuttle (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
* outline all tracing events

* outline log events
2025-07-22 18:45:02 +00:00
Ibraheem Ahmed
0666e2018b
add option to track heap memory usage of memos (#925)
Some checks failed
Book / Book (push) Has been cancelled
Release-plz / Release-plz release (push) Has been cancelled
Release-plz / Release-plz PR (push) Has been cancelled
Test / Test (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Shuttle (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
2025-06-25 20:26:49 +00:00
Micha Reiser
2b5188778e
fix: multithreaded nested fixpoint iteration (#882)
Some checks are pending
Test / Test (push) Waiting to run
Test / Miri (push) Waiting to run
Test / Shuttle (push) Waiting to run
Test / Benchmarks (push) Waiting to run
Book / Book (push) Waiting to run
Book / Deploy (push) Blocked by required conditions
Release-plz / Release-plz release (push) Waiting to run
Release-plz / Release-plz PR (push) Waiting to run
* Set `validate_final` in `execute` after removing the last cycle head

* Add runaway query repro

* Add tracing

* Fix part 1

* Fix `cycle_head_kinds` to always return provisional for memos that aren't verified final (They should be validated by `validate_same_iteration` or wait for the cycle head

* Fix cycle error

* Documentation

* Fix await for queries depending on initial value

* correctly initialize queued

* Cleanup

* Short circuit if entire query runs on single thread

* Move parallel code into its own method

* Rename method, add self_key to queued

* Revert self-key changes

* Move check *after* `deep_verify_memo`

* Add a test for a cycle with changing cycle heads

* Short circuit more often

* Consider iteration in `validate_provisional`

* Only yield if all heads result in a cycle. Retry if even just one inner cycle made progress (in which case there's a probably a new memo)

* Fix hangs

* Cargo fmt

* clippy

* Fix hang if cycle initial panics

* Rename `cycle_head_kind` enable `cycle_a_t1_b_t2_fallback` shuttle test

* Cleanup

* Docs
2025-06-01 08:45:37 +00:00
Micha Reiser
80fb79e910
Set validate_final in execute after removing the last cycle head (#890)
Some checks are pending
Book / Book (push) Waiting to run
Book / Deploy (push) Blocked by required conditions
Release-plz / Release-plz release (push) Waiting to run
Release-plz / Release-plz PR (push) Waiting to run
Test / Test (push) Waiting to run
Test / Miri (push) Waiting to run
Test / Shuttle (push) Waiting to run
Test / Benchmarks (push) Waiting to run
2025-05-31 13:06:39 +00:00
Ibraheem Ahmed
0c39c08360
Lazily allocate extra memo state (#888)
* lazily allocate extra memo state

* lazily allocate accumulators

* simplify `QueryRevisionsExtra`
2025-05-30 13:28:40 +00:00
Ibraheem Ahmed
0414d89327
Replace loom with shuttle (#876)
* replace loom with shuttle

* inline `empty_cycle_heads`

* ignore failing shuttle test
2025-05-23 15:28:51 +00:00
Lukas Wirth
cfa88e9a4d
Move salsa event system into Zalsa (#849)
* Move salsa event system into `Zalsa`

* Encode `None` into ShallowUpdate

This shrinks the return value from 16 to 8 bytes
2025-05-07 11:45:49 +00:00
Ibraheem Ahmed
54020469a3
Add loom support (#842)
* add support for loom tests

* add just script and fix comment
2025-05-06 15:36:38 +00:00
Micha Reiser
b2b82bccdb
fix: change detection for fixpoint queries (#836)
* bug: Fix missing cycle inputs

* Pass provisional as old memo to `execute_query` during fixpoint

* Remove `provisional` from remove stale output

* Revert debug code

* Update test

* Some documentation

* Clean up tests

* Fix for direct enclosing query

* Format

* More comment fiddling

* Revert copy only outputs change

* Revert `fixpoint_initial` start revision change (worth its own PR)

* Align fixpoint handling with Derived

* Preserve cycle heads when returning fixpoint initial

* Always return changed for `Fixpoint::Initial`

* Keep returning unchanged in some cases
2025-05-06 08:11:31 +00:00
Lukas Wirth
5b5e982994
refactor: Clean up function::execute (#833)
it's gotten a bit tough to reason about imo due to the different execution modes we have now
2025-04-30 08:42:14 +00:00
Micha Reiser
b27e3927e9
fix: Access to tracked-struct that was freed during fixpoint (#817)
* Add test for untracked read on tracked struct created in previous cycle

* Initial fix

* Restrict seeding to memos from the same revision

* Reduce changes

* seed_outputs

* Cleanup test

* Add assertion

* Try

* Try merging outputs after query executed

* Assert logs from first execution

* Enable trace level logging

* Use `FxIndexSet` in `diff_outputs`

* Log more events

* Cleanup

* Append outputs only once
2025-04-28 14:24:33 +00:00
Lukas Wirth
d18dc7705f
fix: Fix incorrect values_equal signature (#825) 2025-04-28 12:42:23 +00:00
Chayim Refael Friedman
05b4faddb5
Add a third cycle mode, equivalent to old Salsa cycle behavior (#801)
That is, directly set a value for all queries that have fallbacks, and ignore all other queries in the cycle.

Unlike old Salsa, we still need all cycle heads to be marked, and we still execute the queries to completion, but we throw their result.
2025-04-22 10:35:43 +00:00
Carl Meyer
87bf6b6c2d
add WillIterateCycle event (#790)
* add WillIterateCycle event

* add iteration_count and fell_back to event
2025-04-10 13:13:17 +00:00
Carl Meyer
296a8c78da
allow reuse of cached provisional memos within the same cycle iteration (#786)
* test for caching provisional values

* add iteration-count to cycle heads

* CycleHeads insert/extend checks iteration count match

* update iteration count in cycle heads

* all tests passing

* remove debug prints

* just walk active query stack once

* switch to tracking active cycle iterations on ZalsaLocal

* Revert "switch to tracking active cycle iterations on ZalsaLocal"

This reverts commit 4ea3d850b53a449dda7af7ceb4cc565d3a64001c.

* Revert "just walk active query stack once"

This reverts commit 2d7948612be3f411c7787829ff2db74e3a575f0c.

* make ActiveQuery::iteration_count private with accessor

* iterate active query stack in reverse

* use tracing::trace! in hot path

* try a cold annotation on validate_same_iteration

* Revert "try a cold annotation on validate_same_iteration"

This reverts commit 49ceb84bb7.
2025-04-03 15:10:50 +00:00
Lukas Wirth
a89e3d2357
chore: Normalize imports style (#779)
* Default impl some ingredient functions

* chore: Normalize imports style

Effectively reformatted everything with
```toml
imports_granularity = "Module"
group_imports = "StdExternalCrate"
reorder_imports = true
```
2025-03-28 05:11:40 +00:00
Lukas Wirth
db61adc0f1
refactor: Remove some unnecessary panicking paths in cycle execution (#765) 2025-03-17 17:54:42 +00:00
Ibraheem Ahmed
a86db59e99
Enable Garbage Collection for Interned Values (#602)
* remove table-wide dependencies

* add plumbing to reuse interned slots

* record durabilities on interned values

* appease clippy

* remove immortal interned value logic

* pass correct revision when tracking interned reads

* force new revision when resetting interned values

* avoid unnecessary calls to `Database::zalsa`

* add log events for value internment

* Only log event kind because thread id can differ between runs/computers

* cargo fmt

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2025-03-17 09:23:14 +00:00
Carl Meyer
095d8b2b81
rewrite cycle handling to support fixed-point iteration (#603) 2025-03-10 22:25:47 +00:00
Lukas Wirth
ceb9b083b3
perf: Some small perf things (#744)
* Some perf things

* Remove unused `QueryOrigin::BaseInput`
2025-03-05 17:23:24 +00:00
Ibraheem Ahmed
2a751d559b replace arc-swap with manual AtomicPtr 2025-02-26 09:04:51 -05:00
Chayim Refael Friedman
6134aaf2b5 Introduce Salsa enums
They are of the form:
```
enum Enum {
    Input(Input),
    Interned(Interned),
    ...
}
```
2025-02-25 09:36:36 +01:00
Lukas Wirth
5eb99ccbab Remove some ZalsaDatabase::zalsa calls
Instead pass around `&Zalsa` to callers more to reduce dynamic dispatch, in most of these cases the functions are only called once so the compiler should have enough knowledge to make the extra argument passing virtually free
2025-02-21 08:16:44 +01:00
Robert Balicki
661f6e10ab fix grammar issue in comment 2025-01-27 00:21:10 -05:00
Lukas Wirth
266f620140 Simplify Event construction 2025-01-05 13:00:20 +01:00
Niko Matsakis
acc34396c6
Merge branch 'master' into dhruv/recreate-panic 2024-09-22 07:37:00 -04:00
Micha Reiser
7e8720a2ad
Clippy 2024-09-21 16:36:35 +02:00
Niko Matsakis
2caa5ccf87 return lifetime-extended memo, not value
Change the core operation to be `refresh_memo`.
This is a nice refactoring on its own but it
will also support the refactoring of how
we manage accumulator values.
2024-09-21 06:40:05 -04:00
Micha Reiser
2d55e83845
Remove deleted entries from tracked_struct_ids 2024-09-13 15:19:40 -04:00
Micha Reiser
8175c77cc5
Reduce cloning of sets in ActiveQuery and QueryRevisions 2024-08-22 09:23:21 +02:00
Niko Matsakis
6401563755 store memoized fn results attached to the salsa struct 2024-08-20 10:09:49 -04:00
Niko Matsakis
188f759555 use table for tracked structs and their fields
This also retools a tiny bit how deletion works.
We will reuse ids faster than before, actually.
2024-08-20 10:09:49 -04:00
Niko Matsakis
4d2ccffddc return to the database-wrapping-storage setup 2024-08-04 02:18:54 -04:00
Niko Matsakis
502716d368 pacify the merciless cargo fmt 2024-07-28 21:33:05 +00:00
Niko Matsakis
ab112b7126 rename local_state to zalsa_local 2024-07-28 13:12:58 +00:00
Niko Matsakis
daaa78056a switch to new database design
Under this design, *all* databases are a
`DatabaseImpl<U>`, where the `U` implements
`UserData` (you can use `()` if there is none).

Code would default to `&dyn salsa::Database` but
if you want to give access to the userdata, you
can define a custom database trait
`MyDatabase: salsa::Databse` so long as you

* annotate `MyDatabase` trait definition of
  impls of `MyDatabase` with `#[salsa::db]`
* implement `MyDatabase` for `DatabaseImpl<U>`
  where `U` is your userdata (this could be a
  blanket impl, if you don't know the precise
  userdata type).

The `tests/common/mod.rs` shows the pattern.
2024-07-28 12:47:50 +00:00
Niko Matsakis
64556e9d28 make event generation lazy
Creating events if nobody is listening has
always bugged me.
2024-07-28 12:35:33 +00:00
Niko Matsakis
1842b1dfbb (almost) encansulate Runtime into Zalsa
The distinction is dumb and should go away.
But we still need it for a bit.
2024-07-28 12:35:33 +00:00
Niko Matsakis
596461c213 hide internal methods behind a Zalsa trait
The traits are now quite simple:

* Database is the external trait
* ZalsaDatabase is the internal one, implemented
  by `#[salsa::db]`. It adds two methods,
  `zalsa` and `zalsa_mut`. Those give access
  to our internal methods.

For now I've hidden the methods behind
`&dyn Zalsa`. This is nice and clean but it may
be worth later refactoring to a `struct Zalsa`.
2024-07-28 12:35:33 +00:00
Niko Matsakis
3d2b2d3a65 remove RuntimeId and use ThreadId 2024-07-23 11:53:37 -04:00
Niko Matsakis
59dbfc2826 flatten module hierarchy 2024-07-23 11:52:05 -04:00
David Barsky
86f06d8485 chore: use tracing instead of log 2024-07-22 18:02:40 -04:00
Niko Matsakis
dde7341f97 create macro-rules macros to encapsulate output
This is a new idea for how to manage procedural
macros, which I kind of hate.
2024-07-13 05:45:22 -04:00
Niko Matsakis
73b8134345 WIP checkpoint 2024-07-12 07:51:28 -04:00
Niko Matsakis
15106ff8ea reorganize plumbing 2024-07-12 07:11:31 -04:00
Niko Matsakis
c84bd1b5c2 WIP new approach with upcasts 2024-07-10 08:13:00 -04:00
Niko Matsakis
fe1b06a48a WIP-- checkpoint, dynamic jars 2024-07-08 06:25:32 -04:00
Niko Matsakis
e1920bdda6 require databases and ingredients to be static 2024-07-06 08:15:27 -04:00
Matthijs Brobbel
c7851112a5
Rename salsa-2022 to salsa 2024-06-18 09:40:21 +02:00
Renamed from components/salsa-2022/src/function/execute.rs (Browse further)