nevalang / neva

🌊 Dataflow programming language with static types and implicit parallelism. Compiles to native code and Go
https://nevalang.org
MIT License
85 stars 7 forks source link

Tracing (error handling and `Panic` behaviour) #595

Open emil14 opened 1 month ago

emil14 commented 1 month ago
  1. What should we see in a console when we panic? In Go we see a stack-trace of the goroutine that panicked
  2. Do we need something like Go's debug.PrintStack() from runtime/debug? How should it work?
emil14 commented 1 month ago

Option 1

Usage Example

import { runtime }

component Main(start) (stop) {
    nodes { runtime.Trace, Println, Foo }
    net { :start -> foo -> trace -> println -> :stop }
}

component Foo(sig) (sig) {
    nodes { Bar }
    net { :sig -> bar -> :sig }
}

component Bar(sig) (sig) {
    nodes { Baz }
    net { :sig -> baz -> :sig }
}

component Baz(sig) (sig) { :sig -> :sig }

Output

├─ in:start[0]
│  ├─ foo/in:sig[0]
│  │  ├─ foo/bar/in:sig[0]
│  │  │  └─ foo/bar/baz/in:sig[0]
│  │  │  └─ foo/bar/baz/out:sig[0]
│  │  └─ foo/bar/out:sig[0]
   └─ foo/out:sig[0]

Problem 1

It won't work with nested messages like struct, map, list and their combinations.

This is the implementation - when message is send runtime.Connector appends to it's trace current port-address (where it was sent from).

The problem is that to apply that to the trace of any message inside we need to do that recursively.

Now given that how much of a load is on that connector's part we have, it will definitely be a bottle-neck.

Problem 2

We just need to waste more memory on that. Each message will carry a slice of structures that will only get bigger as it moves from one place to another. That is especially the case for looped networks

emil14 commented 4 weeks ago

https://ziglang.org/documentation/0.11.0/#Error-Return-Traces