-
Notifications
You must be signed in to change notification settings - Fork 214
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
PLT-380 Replace TChan with bounded queue #502
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm completely inexperienced when it comes to concurrency programming (in Haskell or any other language), but this all sounds very reasonable. And it is simpler, and simple is good 👍
You may use UPD. For blocks with transactions we have |
I second @ak3n. The |
You are right that throughput is important (which reminds me I should implement pipelining as well).
I'll change this PR to use |
9069692
to
d132917
Compare
I have extracted it to a separate personal repo https://git.sr.ht/~ak3n/tbmqueue some time ago where I wanted to play with it and maybe tune but had no time and haven't uploaded to hackage (also it seems I messed up with the LICENSE file). We can start using it which will make me a maintainer and maybe I will extend it. Or we can extract the module to a new package within the plutus-apps repo. Or just copy the module until the dependencies picture will be clearer. |
Do you happen to remember how big was the variation? I am a bit conflicted. I don't even have evicence of lower throughput with an MVar. I will run some tests tomorrow to decide what to do. |
affc1af
to
794c6a7
Compare
I had moved the place where the exception is thrown and forgot to remove the previous code.
84a2d62
to
31194d4
Compare
@ak3n @koslambrou I appreciate your feedback but I have decided to stick with a dead simple MVar. I added a comment explaining the thread off. I am concerned about spending time optimising for the wrong thing. We can revise this later if it becomes a problem. |
No problem, we can add a story for this. I may be wrong, but feels like using something like |
I don't mean to say you are wrong! I saw the issue on JIRA 👍 |
* Remove unreachable code. I had moved the place where the exception is thrown and forgot to remove the previous code. * Replace TChan with MVar * Add comment about MVar choice * Incorporate more feedback
* Remove unreachable code. I had moved the place where the exception is thrown and forgot to remove the previous code. * Replace TChan with MVar * Add comment about MVar choice * Incorporate more feedback
Someone made me notice that I was using an unbounded tchan where I could get away with a mvar. Basically I want to have the two threads (the one running chain-sync and the stream consumer) in lock-step.
In the current version, blocks are pushed in the channel at full speed independently from the speed at which they are consumed, this can cause memory issues if the consumer is slower than the network (which is likely).