Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hydroflow_lang)!: remove singleton referencer persist::<'static>() insertion #1332

Merged
merged 4 commits into from
Jul 22, 2024

Conversation

MingweiSamuel
Copy link
Member

@MingweiSamuel MingweiSamuel commented Jul 3, 2024

Also enables singletons for persist() and ensures that only the 'static lifetime is used

Singletons are supposed to act like cross_join(). I.e. if we have this code:

stream -> filter(|item| ... #y ...) -> ...

It should behave equivalently to

stream -> cj[0];
y -> cj[1];
cj = cross_join() -> filter(|(item, y)| ...) -> ...

This has a very unintuitive replaying behavior, if y receives multiple updates:

  1. y receives an item 10
  2. stream receives an item 20
  3. (10, 20) is emitted
  4. y receives an item 11
  5. (11, 20) is emitted
    In this case the item 20 gets emitted twice.

To emulate this unintuitive behavior, we currently ensure that a persist::<'static>() exists before operator that references the singleton (filter, in this case). (Note that this is equivalent to cross_join::<'static>() and not cross_join::<'tick>())

However singletons also have had a different mechanism that affects this- currently singleton references create a next-stratum constraint, that ensures a singleton referencer must be in a later stratum than the singleton it is referencing.

Note that this actually prevents the example situation above from happening-- the updates to y will be received all at once at the start of the next stratum.

This means that actually, currently singletons are equivalent to something like:

stream -> cj[0];
y -> next_stratum() -> last() -> cj[1];
cj = cross_join() -> filter(|(item, y)| ...) -> ...

last() is a hypothetical operator that only keeps the most recent item output by y. next_stratum() -> last() is equivalent to reduce(|acc, item| *acc = item) (since that comes with a stratum barrier). So technically this is a slightly different behavior than just cross_join, but it is more intuitive.

stream -> cj[0];
y -> reduce(|acc, item| { *acc = item; }) -> cj[1];
cj = cross_join() -> filter(|(item, y)| ...) -> ...

Also fixes #1293

BREAKING CHANGE: removing persist insertion changes the exact way singletons behave

Also enables singletons for `persist()` and ensures that only the
`'static` lifetime is used
@MingweiSamuel MingweiSamuel changed the title fix(hydroflow_lang)!: remove singleton persist insertion fix(hydroflow_lang)!: remove singleton referencer persist::<'static>() insertion Jul 5, 2024
@MingweiSamuel MingweiSamuel marked this pull request as ready for review July 5, 2024 20:46
@MingweiSamuel MingweiSamuel merged commit 755e8a6 into hydro-project:main Jul 22, 2024
13 checks passed
@MingweiSamuel MingweiSamuel deleted the persist-tick branch July 22, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removal of unused unions/tees happens before ensure_singleton_referencers_succeed_persist check
2 participants