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

Race condition fix. Part 2 (Runtime) #670

Merged
merged 46 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b25cc81
optimize(runtime:ir): use uint8 for slot idx
emil14 Jun 1, 2024
87a0dd5
wip: broker
emil14 Jun 5, 2024
0a35cc0
Merge branch 'main' into runtime_raceless_queue
emil14 Jun 8, 2024
d1213d9
feat(runtime): massive rewriting
emil14 Jun 10, 2024
4721050
wip: runtime
emil14 Jun 12, 2024
bf09776
wip
emil14 Jun 12, 2024
d0b014a
wip
emil14 Jun 13, 2024
55f876a
feat(runtime:program): add a few more methods for ports
emil14 Jun 15, 2024
04e74e1
fix(runtime:funcs): new ports API
emil14 Jun 15, 2024
0929b2e
fix(runtime:funcs): stream product and stream to list
emil14 Jun 15, 2024
c79dd71
feat(irgen,adapter,runtime): move to raceless queue-based design in a…
emil14 Jun 17, 2024
ee8841d
Merge branch 'main' into runtime_raceless_queue
emil14 Jun 17, 2024
2d2ea44
fix(runtime): few fixes after moving to q-based design
emil14 Jun 18, 2024
266aaf7
fix(adapter): more fixes
emil14 Jun 18, 2024
7914dbe
fix(runtime): fix match component and formatting for portAddr with id…
emil14 Jun 18, 2024
e60a885
fix(runtime:queue): temporary remove round-robin because it was incor…
emil14 Jun 18, 2024
2851927
wip: add x pkg to test fan-in algorithm
emil14 Jun 22, 2024
2a0f11f
fix(x): fan-in using atomic counter instead of time.now
emil14 Jun 22, 2024
2737954
feat(runtime,adapter): migrate to new fan-in based design with atomic…
emil14 Jun 22, 2024
4507b22
fix(runtime,adapter): couple of fixes, still needs few more
emil14 Jun 23, 2024
023dd77
fix(runtime): hello world works again! probably all fan-out-free prog…
emil14 Jun 23, 2024
378a2c1
wip(x): allocated ^2 elems for buf
emil14 Jun 23, 2024
44894ca
feat(desugarer): implement fan-out
emil14 Jun 23, 2024
f631cb7
wip(runtime,compiler): multiple fixes after adding fanOut sugar
emil14 Jun 23, 2024
200d7f3
refactor(runtime): minor refactorings
emil14 Jun 24, 2024
ab58de5
fix(compiler:desugarer): remove duplicate receivers that lead to unne…
emil14 Jun 24, 2024
5b295fc
fix(adapter): remove useless fan-out usage for buf setting (we don't …
emil14 Jun 24, 2024
a2b0910
refactor(runtime:msg): add a few TODO comments
emil14 Jun 24, 2024
e1f046e
fix(desugarer:network:fan_out): replace existing receivers with one s…
emil14 Jun 24, 2024
adf27c4
wip(irgen): fixing bugs
emil14 Jun 27, 2024
ad1c8f4
fix(runtime): use combination of uint8+bool to avoid pointer incompat…
emil14 Jun 28, 2024
06fa505
tmp(runtime): remove fmt print for debugging (event listening)
emil14 Jun 28, 2024
d9af4ae
refactor(compiler): remove useless wd arg
emil14 Jun 28, 2024
f285764
feat,refactor: pass debug flag everywhere
emil14 Jun 28, 2024
f42a61f
feat(runtime): add debug interceptor (printer)
emil14 Jun 30, 2024
817cbac
fix: compile err
emil14 Jun 30, 2024
38a3094
fix(runtime:funcs:if): return instead of continue when ctx closed
emil14 Jun 30, 2024
084554e
fix(desugarer): virtual fan out nodes counter for names
emil14 Jun 30, 2024
78ac1c9
feat/fix(runtime:funcs,e2e): if sends bool instead of nil and by that…
emil14 Jun 30, 2024
2fba8d2
fix(runtime:funcs:printf): add missing check if ctx is closed while r…
emil14 Jun 30, 2024
25ba51b
feat(runtime:funcs:int_casemod): simplify and optimize
emil14 Jun 30, 2024
51a2e0f
refactor(examples:fizzbuzz): refactor with map and for (out of order …
emil14 Jun 30, 2024
5ae6833
cian
emil14 Jun 30, 2024
2b5778c
tmp(e2e): return for_with_range with race
emil14 Jul 1, 2024
3466e9e
refactor(e2e:for_with_range_and_if): remove comments with broken version
emil14 Jul 1, 2024
70c2039
fix(linting): also remove unused tmp code
emil14 Jul 1, 2024
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
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"mode": "auto",
"program": "${workspaceFolder}/cmd/neva",
"cwd": "${workspaceFolder}",
"args": ["run", "examples/swork"]
"args": ["run", "-debug", "e2e/99_bottles_verbose/main"]
},
{
"name": "LSP",
Expand Down
8 changes: 4 additions & 4 deletions cmd/lsp/server/get_file_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ func (s *Server) GetFileView(glspCtx *glsp.Context, req GetFileViewRequest) (Get
func getExtraForFile(file src.File, scope src.Scope) (map[string]map[string]src.Interface, error) {
extra := map[string]map[string]src.Interface{}
for entityName, entity := range file.Entities {
if entity.Kind != src.FlowEntity {
if entity.Kind != src.ComponentEntity {
continue
}

nodesIfaces := map[string]src.Interface{}
for nodeName, node := range entity.Flow.Nodes {
for nodeName, node := range entity.Component.Nodes {
nodeEntity, _, err := scope.Entity(node.EntityRef)
if err != nil {
return nil, err
}

var iface src.Interface
if nodeEntity.Kind == src.FlowEntity {
iface = nodeEntity.Flow.Interface
if nodeEntity.Kind == src.ComponentEntity {
iface = nodeEntity.Component.Interface
} else if nodeEntity.Kind == src.InterfaceEntity {
iface = nodeEntity.Interface
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/99_bottles_verbose/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ flow PrintFirstLine(n int) (n int) {
match:else -> printf:args[0]
$firstLine1 -> printf:tpl

[println:sig, printf:args[0]] -> lock:sig
[println:sig, printf:sig] -> lock:sig

lock:data -> :n
}
Expand All @@ -69,6 +69,6 @@ flow PrintSecondLine(n int) (n int) {
match:else -> printf:args[0]
$secondLine1 -> printf:tpl

[println:sig, printf:args[0]] -> lock:sig
[println:sig, printf:sig] -> lock:sig
lock:data -> :n
}
4 changes: 2 additions & 2 deletions e2e/99_bottles_with_chain/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ flow PrintFirstLine(n int) (n int) {
($firstLine1 -> printf:tpl)
]

[println:sig, printf:args[0]] -> lock:sig
[println:sig, printf:sig] -> lock:sig
lock:data -> :n
}

Expand All @@ -60,6 +60,6 @@ flow PrintSecondLine(n int) (n int) {
($secondLine1 -> printf:tpl)
]

[println:sig, printf:args[0]] -> lock:sig
[println:sig, printf:sig] -> lock:sig
lock:data -> :n
}
2 changes: 1 addition & 1 deletion e2e/cli_new/neva.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
neva: 0.23.0
neva: 0.25.0
6 changes: 3 additions & 3 deletions e2e/compare_ints_lt_equal/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
flow Main(start) (stop) {
nodes { Println, Lt<int>}
nodes { Println, Lt<int> }
:start -> [
(20 -> lt:compared),
(20 -> lt:actual)
]
lt:res -> println -> :stop
]
lt:res -> println -> :stop
}
11 changes: 5 additions & 6 deletions e2e/compare_strings/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
flow Main(start) (stop) {
nodes { Println, Gt<string>,If}
nodes { Println, Gt<string>, If }
:start -> [
('A' -> gt:compared),
('Z' -> gt:actual)
]
gt:res -> if

if:then -> ('Actual is greater' -> println -> :stop)
if:else -> ('Actual is lower' -> println -> :stop)
]
gt:res -> if
if:then -> ('Actual is greater' -> println -> :stop)
if:else -> ('Actual is lower' -> println -> :stop)
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flow Main(start) (stop) {
:start -> :stop
}
}
File renamed without changes.
3 changes: 1 addition & 2 deletions e2e/for_with_range_and_if/main/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ flow Main(start) (stop) {
flow Printer(data bool) (sig any) {
nodes { If, Println }
:data -> if
if:then -> ('true' -> println)
if:else -> ('false' -> println)
[if:then, if:else] -> println
println -> :sig
}
4 changes: 2 additions & 2 deletions e2e/logic_gate_and/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
flow Main(start) (stop) {
nodes { Println, And }
:start -> [
(true -> and:A),
(true -> and:B)
(true -> and:a),
(true -> and:b)
]
and -> println -> :stop
}
4 changes: 2 additions & 2 deletions e2e/logic_gate_or/main/main.neva
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
flow Main(start) (stop) {
nodes { Println, Or }
:start -> [
(false -> or:A),
(false -> or:B)
(false -> or:a),
(false -> or:b)
]
or -> println -> :stop
}
22 changes: 22 additions & 0 deletions e2e/simple_fan_out/e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package test

import (
"os/exec"
"testing"

"github.com/stretchr/testify/require"
)

func Test(t *testing.T) {
cmd := exec.Command("neva", "run", "main")

out, err := cmd.CombinedOutput()
require.NoError(t, err)
require.Equal(
t,
"<empty>\n<empty>\n",
string(out),
)

require.Equal(t, 0, cmd.ProcessState.ExitCode())
}
7 changes: 7 additions & 0 deletions e2e/simple_fan_out/main/main.neva
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { time }

flow Main(start) (stop) {
nodes { p1 Println, p2 Println }
:start -> [p1, p2]
p1 -> (p2 -> :stop)
}
1 change: 1 addition & 0 deletions e2e/simple_fan_out/neva.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
neva: 0.10.0
5 changes: 3 additions & 2 deletions examples/99_bottles/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ flow PrintFirstLine(n int) (n int) {
($firstLine1 -> printf:tpl)
]

[println, printf:args[0]] -> lock:sig
[println:sig, printf:sig] -> lock:sig
lock -> :n
}

Expand All @@ -55,6 +55,7 @@ flow PrintSecondLine(n int) (n int) {
($secondLine1 -> printf:tpl)
]

[println, printf:args[0]] -> lock:sig
[println:sig, printf:sig] -> lock:sig

lock:data -> :n
}
2 changes: 1 addition & 1 deletion examples/add_numbers/main.neva
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flow Main(start) (stop) {
nodes {
add ReducePort<int> { Add<int> }
Println
add ReducePort<int> { Add<int> }
}
:start -> [
(1 -> add[0]),
Expand Down
32 changes: 11 additions & 21 deletions examples/fizzbuzz/main.neva
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
flow Main(start) (stop) {
nodes { Range, PrintLine, Match }

:start -> [
(1 -> range:from),
(101 -> range:to)
]
range.data -> printLine -> match:data
100 -> match:case[0] -> :stop
nodes { Range, Map<int, string>{FizzBuzz}, For{Println} }
:start -> [(1 -> range:from), (101 -> range:to)]
range -> map -> for -> :stop
}

flow PrintLine(data int) (data int) {
nodes { mod CaseMod, Println, Lock<int> }

:data -> [mod:data, lock:data]

15 -> mod:case[0] -> ('FizzBuzz' -> println)
3 -> mod:case[1] -> ('Fizz' -> println)
5 -> mod:case[2] -> ('Buzz' -> println)
mod:else -> println

println -> lock:sig
lock:data -> :data
}
flow FizzBuzz(data int) (res any) {
nodes { CaseMod }
:data -> caseMod:data
15 -> caseMod:case[0] -> ('FizzBuzz' -> :res)
3 -> caseMod:case[1] -> ('Fizz' -> :res)
5 -> caseMod:case[2] -> ('Buzz' -> :res)
caseMod:else -> :res
}
2 changes: 1 addition & 1 deletion examples/get_args/main.neva
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { os, lists }

flow Main(start) (stop) {
nodes { os.Args, lists.For{Println}}
:start -> (args -> for -> :stop)
:start -> args -> for -> :stop
}
2 changes: 1 addition & 1 deletion examples/hello_world/main.neva
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flow Main(start) (stop) {
nodes { Println }
:start -> ('Hello, World!' -> println -> :stop)
}
}
10 changes: 6 additions & 4 deletions examples/stream_product/main.neva
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
flow Main(start) (stop) {
nodes {
r1 Range,
r2 Range,
Product<int, int>,
For<ProductRes<int, int>>{Println<ProductRes<int, int>>}
r1 Range
r2 Range
Product<int, int>
For<ProductResult<int, int>> {
Println<ProductResult<int, int>>
}
}
:start -> [
(0 -> [r1:from, r2:from]),
Expand Down
28 changes: 7 additions & 21 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ func NewApp(
if err != nil {
return err
}
intr := interpreter.New(bldr, goc, debug)
if err := intr.Interpret(
context.Background(),
workdir,
dirFromArg,
); err != nil {
intr := interpreter.New(bldr, goc)
if err := intr.Interpret(context.Background(), dirFromArg, debug); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -148,25 +144,15 @@ func NewApp(
}
switch target {
case "go":
return goc.Compile(
workdir, dirFromArg, workdir,
)
return goc.Compile(dirFromArg, workdir, debug)
case "wasm":
return wasmc.Compile(
workdir, dirFromArg, workdir,
)
return wasmc.Compile(dirFromArg, workdir, debug)
case "json":
return jsonc.Compile(
workdir, dirFromArg, workdir,
)
return jsonc.Compile(dirFromArg, workdir, debug)
case "dot":
return dotc.Compile(
workdir, dirFromArg, workdir,
)
return dotc.Compile(dirFromArg, workdir, debug)
default:
return nativec.Compile(
workdir, dirFromArg, workdir,
)
return nativec.Compile(dirFromArg, workdir, debug)
}
},
},
Expand Down
8 changes: 4 additions & 4 deletions internal/compiler/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ func (a Analyzer) analyzeEntity(entity src.Entity, scope src.Scope) (src.Entity,
}.Wrap(err)
}
resolvedEntity.Interface = resolvedInterface
case src.FlowEntity:
analyzedFlow, err := a.analyzeFlow(entity.Flow, scope)
case src.ComponentEntity:
analyzedComponent, err := a.analyzeComponent(entity.Component, scope)
if err != nil {
return src.Entity{}, compiler.Error{
Location: &scope.Location,
Meta: &entity.Flow.Meta,
Meta: &entity.Component.Meta,
}.Wrap(err)
}
resolvedEntity.Flow = analyzedFlow
resolvedEntity.Component = analyzedComponent
default:
return src.Entity{}, &compiler.Error{
Err: fmt.Errorf("%w: %v", ErrUnknownEntityKind, entity.Kind),
Expand Down
Loading
Loading