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

[Idea]: Should we write Runtime funcs to use one Goroutine per port? #629

Closed Catya3 closed 1 month ago

Catya3 commented 1 month ago

I will add more to the description when I have time.

Short psuedocode example:

for {
  x <- xIn
  y <- yIn
  res <- x+y
}
var x, y int64
var mu Mutex
go func() { for { /*TryLock Mutex */ x = <- xIn } }
go func() { for { /*TryLock Mutex */ y = <- yIn  } }
go func() { for { res <- x+y /*unlock Mutex */  } }
emil14 commented 1 month ago

It depends on logic of specific runtime function

emil14 commented 1 month ago

Also remember that the more locks we have the worse performance is

emil14 commented 1 month ago

I feel like the way to increase performance is actually by reducing amount of goroutines and channels but I have no idea how to do so. Also that's just a feeling, not result of some benchmark

emil14 commented 1 month ago

@Catya3 I will close this one

My answer is "Generally no, but it depends. It might make sense in specific cases. However, better to keep it simple for now"