4 ms·
> For example, manual loop unrolling is seldom a win in Java Just like practically everywhere else. Besides, it increases code size, and can decrease performa
by vardump 9y ago
> For example, manual loop unrolling is seldom a win in Java
Just like practically everywhere else.
Besides, it increases code size, and can decrease performance just for that reason, L1 code cache spills.
Intel CPUs have increasingly improved loop buffers as well. If the loop qualifies, unrolling has no positive effect at all.
Low end microcontrollers are another matter, that's where unrolling can still sometimes yield significant wins.
I think the biggest issue I had with high performance Java is lack of memory alignment control and (at least last time I checked) vector intrinsics. JNI time...
- physguy1123 9y agoI reliably see gains from unrolling relatively simple loops on very recent cpus. Going to 8+ iterations is usually overkill, but it can help. Sometimes one can split a dependency chain by unrolling as well.
- vardump 9y ago> I reliably see gains from unrolling relatively simple loops on very recent cpus. Maybe you didn't have multiple of 4 uops in the loop? Or hit some other (?) loop buffer limitation. Dependency chain splitting is also indeed a good reason to "unroll". Although it's a bit more complex transformation than simple unrolling.
- barrkel 9y agoLoop unrolling can definitely still be a win if it's in the form of vectorising or otherwise processing multiple elements at a time.