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

Scheduler spins when new tick triggeres Irrelevant stateful operator in stratum 0 (bug code) #961

Closed
wants to merge 2 commits into from

Conversation

MingweiSamuel
Copy link
Member

@MingweiSamuel MingweiSamuel commented Nov 16, 2023

%%{init:{'theme':'base','themeVariables':{'clusterBkg':'#ddd','clusterBorder':'#888'}}}%%
flowchart TD
classDef pullClass fill:#8af,stroke:#000,text-align:left,white-space:pre
classDef pushClass fill:#ff8,stroke:#000,text-align:left,white-space:pre
classDef otherClass fill:#fdc,stroke:#000,text-align:left,white-space:pre
linkStyle default stroke:#aaa
1v1[\"(1v1) <code>source_iter([1])</code>"/]:::pullClass
2v1[\"(2v1) <code>union()</code>"/]:::pullClass
3v1[\"(3v1) <code>persist()</code>"/]:::pullClass
4v1[\"(4v1) <code>fold(|| 0, |accum, x| *accum += x)</code>"/]:::pullClass
5v1[\"(5v1) <code>defer_tick_lazy()</code>"/]:::pullClass
6v1[\"(6v1) <code>filter(|_| false)</code>"/]:::pullClass
7v1[/"(7v1) <code>tee()</code>"\]:::pushClass
8v1[/"(8v1) <code>null()</code>"\]:::pushClass
9v1["(9v1) <code>handoff</code>"]:::otherClass
10v1["(10v1) <code>handoff</code>"]:::otherClass
11v1["(11v1) <code>handoff</code>"]:::otherClass
1v1-->2v1
6v1-->7v1
5v1-->6v1
4v1-->9v1
3v1-->10v1
2v1-->3v1
7v1-->8v1
7v1-->11v1
9v1--o5v1; linkStyle 8 stroke:red
10v1--x4v1; linkStyle 9 stroke:red
11v1-->2v1
subgraph sg_1v1 ["sg_1v1 stratum 0"]
    1v1
    2v1
    3v1
    subgraph sg_1v1_var_double ["var <tt>double</tt>"]
        3v1
    end
    subgraph sg_1v1_var_items ["var <tt>items</tt>"]
        2v1
    end
end
subgraph sg_2v1 ["sg_2v1 stratum 1"]
    4v1
    subgraph sg_2v1_var_double ["var <tt>double</tt>"]
        4v1
    end
end
subgraph sg_3v1 ["sg_3v1 stratum 0"]
    5v1
    6v1
    7v1
    8v1
    subgraph sg_3v1_var_double ["var <tt>double</tt>"]
        5v1
        6v1
        7v1
    end
end
Loading

mermaid.live

@MingweiSamuel MingweiSamuel changed the title Scheduler bug Irrelevant stratum 0 stateful operator causes scheduler to spin if new ticks are triggered (bug code) Nov 20, 2023
@MingweiSamuel MingweiSamuel changed the title Irrelevant stratum 0 stateful operator causes scheduler to spin if new ticks are triggered (bug code) Scheduler spins when new tick triggeres Irrelevant stateful operator in stratum 0 (bug code) Nov 20, 2023
@MingweiSamuel
Copy link
Member Author

Could we just re-implement persist and other stateful operators only to emit if they receive input?

@shadaj
Copy link
Member

shadaj commented Dec 6, 2023

Could we just re-implement persist and other stateful operators only to emit if they receive input?

This seems really messy from a semantics standpoint. We expect the output of persist to be monotonic wrt time for a bunch of optimizations we want.

@MingweiSamuel
Copy link
Member Author

Yes it would work in some situations (push based) but not in others (pull based)

@jhellerstein jhellerstein requested review from zzlk and removed request for zzlk January 8, 2024 17:43
@jhellerstein jhellerstein requested review from zzlk and removed request for zzlk January 8, 2024 17:44
@MingweiSamuel
Copy link
Member Author

MingweiSamuel commented Apr 23, 2024

2024-04-23T19:48:05.398693Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: End of tick 182, starting tick 183. can_start_tick=true
2024-04-23T19:48:05.398922Z TRACE run_available:next_stratum{current_tick_only=false}:try_recv_events{events_received_tick=false}: hydroflow::scheduled::graph: Event received. sg_id=0 sg_name="Subgraph GraphSubgraphId(1v1)" is_external=false sg_stratum=0
2024-04-23T19:48:05.399252Z TRACE run_available:next_stratum{current_tick_only=false}:try_recv_events{events_received_tick=false}: hydroflow::scheduled::graph: return=1
2024-04-23T19:48:05.399502Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: `can_start_tick` is `true`, continuing. tick=183
2024-04-23T19:48:05.399699Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=183 stratum=0
2024-04-23T19:48:05.399896Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Work found on stratum. tick=183 stratum=0
2024-04-23T19:48:05.400096Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: return=true
2024-04-23T19:48:05.400321Z TRACE run_available:run_stratum{tick=183 stratum=0}: hydroflow::scheduled::graph: Running subgraph. sg_id=2 sg_name="Subgraph GraphSubgraphId(3v1)"
2024-04-23T19:48:05.400548Z TRACE run_available:run_stratum{tick=183 stratum=0}: hydroflow::scheduled::graph: Running subgraph. sg_id=0 sg_name="Subgraph GraphSubgraphId(1v1)"
2024-04-23T19:48:05.400847Z TRACE run_available:run_stratum{tick=183 stratum=0}: hydroflow::scheduled::graph: Successor subgraph scheduled. sg_id=1 sg_name="Subgraph GraphSubgraphId(2v1)"
2024-04-23T19:48:05.401092Z TRACE run_available:run_stratum{tick=183 stratum=0}: hydroflow::scheduled::graph: return=true
2024-04-23T19:48:05.401323Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Starting `next_stratum` call. events_received_tick=true can_start_tick=false       
2024-04-23T19:48:05.401594Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Starting tick, setting `can_start_tick = false`.
2024-04-23T19:48:05.401877Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=183 stratum=0
2024-04-23T19:48:05.402093Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=183 stratum=1
2024-04-23T19:48:05.402304Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Work found on stratum. tick=183 stratum=1
2024-04-23T19:48:05.402545Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: return=true
2024-04-23T19:48:05.402761Z TRACE run_available:run_stratum{tick=183 stratum=1}: hydroflow::scheduled::graph: Running subgraph. sg_id=1 sg_name="Subgraph GraphSubgraphId(2v1)"
2024-04-23T19:48:05.402999Z TRACE run_available:run_stratum{tick=183 stratum=1}: hydroflow::scheduled::graph: Data sent to next tick, setting  `can_start_tick = true`.
2024-04-23T19:48:05.403209Z TRACE run_available:run_stratum{tick=183 stratum=1}: hydroflow::scheduled::graph: Successor subgraph scheduled. sg_id=2 sg_name="Subgraph GraphSubgraphId(3v1)"
2024-04-23T19:48:05.403463Z TRACE run_available:run_stratum{tick=183 stratum=1}: hydroflow::scheduled::graph: return=true
2024-04-23T19:48:05.403680Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Starting `next_stratum` call. events_received_tick=true can_start_tick=true        
2024-04-23T19:48:05.403891Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=183 stratum=1
2024-04-23T19:48:05.404094Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: End of tick 183, starting tick 184. can_start_tick=true

@MingweiSamuel
Copy link
Member Author

MingweiSamuel commented Apr 23, 2024

    let mut df = hydroflow_syntax! {
        source_iter([1])
            -> next_stratum()
            -> persist()
            -> defer_tick_lazy()
            -> null();
    };
2024-04-23T20:27:56.861787Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: `can_start_tick` is `true`, continuing. tick=385
2024-04-23T20:27:56.861980Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=385 stratum=0
2024-04-23T20:27:56.862185Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Work found on stratum. tick=385 stratum=0
2024-04-23T20:27:56.862387Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: return=true
2024-04-23T20:27:56.862586Z TRACE run_available:run_stratum{tick=385 stratum=0}: hydroflow::scheduled::graph: Running subgraph. sg_id=3 sg_name="Subgraph GraphSubgraphId(4v1)"
2024-04-23T20:27:56.862807Z TRACE run_available:run_stratum{tick=385 stratum=0}: hydroflow::scheduled::graph: return=true
2024-04-23T20:27:56.863015Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Starting `next_stratum` call. events_received_tick=true can_start_tick=false       
2024-04-23T20:27:56.863236Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Starting tick, setting `can_start_tick = false`.
2024-04-23T20:27:56.863414Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=385 stratum=0
2024-04-23T20:27:56.863621Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=385 stratum=1
2024-04-23T20:27:56.863845Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Work found on stratum. tick=385 stratum=1
2024-04-23T20:27:56.864044Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: return=true
2024-04-23T20:27:56.864268Z TRACE run_available:run_stratum{tick=385 stratum=1}: hydroflow::scheduled::graph: Running subgraph. sg_id=2 sg_name="Subgraph GraphSubgraphId(3v1)"
2024-04-23T20:27:56.864509Z TRACE run_available:run_stratum{tick=385 stratum=1}: hydroflow::scheduled::graph: Data sent to next tick, setting  `can_start_tick = true`.
2024-04-23T20:27:56.864725Z TRACE run_available:run_stratum{tick=385 stratum=1}: hydroflow::scheduled::graph: Successor subgraph scheduled. sg_id=3 sg_name="Subgraph GraphSubgraphId(4v1)"
2024-04-23T20:27:56.864971Z TRACE run_available:run_stratum{tick=385 stratum=1}: hydroflow::scheduled::graph: return=true
2024-04-23T20:27:56.865218Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Starting `next_stratum` call. events_received_tick=true can_start_tick=true        
2024-04-23T20:27:56.865450Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: Looking for work on stratum. tick=385 stratum=1
2024-04-23T20:27:56.865665Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: End of tick 385, starting tick 386. can_start_tick=true
2024-04-23T20:27:56.865870Z TRACE run_available:next_stratum{current_tick_only=false}:try_recv_events{events_received_tick=false}: hydroflow::scheduled::graph: Event received. sg_id=2 sg_name="Subgraph GraphSubgraphId(3v1)" is_external=false sg_stratum=1
2024-04-23T20:27:56.866214Z TRACE run_available:next_stratum{current_tick_only=false}:try_recv_events{events_received_tick=false}: hydroflow::scheduled::graph: return=1
2024-04-23T20:27:56.866457Z TRACE run_available:next_stratum{current_tick_only=false}: hydroflow::scheduled::graph: `can_start_tick` is `true`, continuing. tick=386

MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 23, 2024
MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 23, 2024
MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 23, 2024
MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 24, 2024
MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 24, 2024
MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 24, 2024
MingweiSamuel added a commit to MingweiSamuel/hydroflow that referenced this pull request Apr 24, 2024
… (hydro-project#1171)

fixes the added tests failing in the previous commit
MingweiSamuel added a commit that referenced this pull request Apr 25, 2024
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.

2 participants