Thanks for taking a deeper look. Unfortunately, divisions (modulo) are even 
more expensive, so would be good to avoid them.

I think the solution can be actually a bit simpler. It would probably be 
sufficient to simply initialize the array to `INT_MAX - 1` replace the 
`this.returnArray[0] = 0;` in the original code with `this.returnArray[0] = 
resetValue()`. Inside the `resetValue()` you can do the initialization.

That way, common cases have no additional check, and the overflow/reset case 
gets one additional branch, which is already a good improvement.

We could possibly do a followup optimization, where outputs that have only one 
channel swap in a special selector that always returns just `0`. The 
one-channel-only case is probably the one that would be affected most by this 
change, because it always overflows each time.

[ Full content available at: https://github.com/apache/flink/pull/6544 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to