[GitHub] nifi issue #3131: NIFI-3229 When a queue contains only Penalized FlowFile's ...
Github user patricker commented on the issue: https://github.com/apache/nifi/pull/3131 @markap14 I built unit tests, but I'm having trouble running them at scale. I temporarily checked back in the original method so I could run side-by-side speed comparisons on the same `Connectable`. But if I exceed about 100k tests my unit tests seem to go out to lunch, even if I increase heap so they don't run out. These are checked in right now to run 1 million iterations, but that has not succeeded for me... This is true of the unmodified method if run by itself also (at least on my poor little computer). ---
[GitHub] nifi issue #3131: NIFI-3229 When a queue contains only Penalized FlowFile's ...
Github user patricker commented on the issue: https://github.com/apache/nifi/pull/3131 @markap14 Sounds reasonable, I'll work on it. ---
[GitHub] nifi issue #3131: NIFI-3229 When a queue contains only Penalized FlowFile's ...
Github user markap14 commented on the issue: https://github.com/apache/nifi/pull/3131 @patricker you're right - it may perform just fine. However, the concern is not that we are holding a lock longer but rather that we are obtaining it twice as often now when there's data queued. The acquisition of the lock itself can be expensive. So all I am suggesting is that we don't want to make such a change without knowing how it's going to affect things. We'd want to gather some performance numbers before and after this changeset is applied. Specifically, I'd want to setup a test suite that calculates things like: How long does it take to check if there are FlowFiles queued 10 million times when there are no FlowFiles queued? How long does it take to check if there are FlowFiles queued 10 million times when there are FlowFiles queued? How do these numbers change when you have 1 thread vs. 2 threads vs. 12 threads vs. 25 threads? I'd want to run these tests 10-20 times in a row to ensure that the numbers are steady, and then get these numbers before and after the changeset is applied. If the worst-case differs by say 5% then it's probably fine. If the worse case differs by say 50% then it probably makes sense to look for a different solution. ---
[GitHub] nifi issue #3131: NIFI-3229 When a queue contains only Penalized FlowFile's ...
Github user patricker commented on the issue: https://github.com/apache/nifi/pull/3131 @markap14 I was worried about the same thing, which is why the `if` statement is structured as it is. First, we do the standard check on `isActiveQueueEmpty`. This happens in the code now as you mentioned, and right now if this passes we create a writelock update the queue and call the processor. All my change does is add one additional check, but only if the queue is not empty. So as far as I can tell, I'm locking one extra time for a queue that is already going to get locked, but not locking any queues that would not already get locked. Also, because I'm updating the queue during my check, when the processor does get called the lock should not last as long as it would otherwise, as there is less work to do. So overall lock time should be affected only minimally. Thoughts? ---
[GitHub] nifi issue #3131: NIFI-3229 When a queue contains only Penalized FlowFile's ...
Github user markap14 commented on the issue: https://github.com/apache/nifi/pull/3131 @patricker thanks for the PR! I had gone down this path before but I backed out the changes. The changes in this PR will result in obtaining a Write Lock on the queue of every incoming connection for every running processor in the graph. This can become quite expensive for a complex flow that is made up of thousands (or even 10's of thousands) of processors) and result in overall system performance suffering. This is why we are so care in the FlowFile Queue's implementation to ensure that isActiveQueueEmpty() never obtains a lock but instead only references AtomicReference variables. We should be able to do better, though. For example, when we pull a FlowFile from the queue, we check if it's penalized. If so, we throw it back on. Since the queue is ordered, we could do some smart things like looking at the FlowFile expiration date, then keeping track of the fact that we know all FlowFiles are penalized until that time is reached - or until a non-penalized FlowFile is added to the queue. ---