crete-dev icon indicating copy to clipboard operation
crete-dev copied to clipboard

NodeDriver threads' contention over member node_ causes starvation

Open moralismercatus opened this issue 7 years ago • 1 comments

The dispatch-communication thread and the run-node thread compete for node_, as a shared resource. Either one of these can starve the other, if one repeatedly acquires node_ consecutively.

This is especially apparent when e.g., vm-node instances > 1. Because the run-node thread processes all VM instances before relinquishing node_, the issue is exacerbated given run-node's tendency to win the race for node_.

I implemented a fix on my fork: https://github.com/moralismercatus/crete-dev/commit/e2774ace4b3b4f0ce7db9f92756f458c5b410f6a#diff-b5094f7d4fdca6fbd261c78e8b3d8c50

The idea is that when a transmission from dispatch is received, a flag is set. The run-node thread always checks if there's a pending transmission before acquiring node_. If true, then run-node thread waits until the transmission is complete before acquiring node_.

I don't consider it a perfect solution because a transmission could theoretically take considerable time to complete, and run-node is waiting idle during that period, but it works for my purposes, and is certainly an improvement over the current.

moralismercatus avatar Apr 10 '17 19:04 moralismercatus

It looks good to me. As this merge will be simple, I decide to merge it later (after recent changes from my branch are merged).

likebreath avatar Sep 26 '17 22:09 likebreath