Dear R developers,

R makes some functions interruptible, thanks to a call to R_CheckUserInterrupt. 
Simple arithmetic operations can be interrupted avoiding freezes when using 
huge arrays (e.g. length > 1 billion).

But many operations, such as matrix multiplication, are not interruptible. I 
estimated that a multiplication of two 10000�10000 square matrices would freeze 
R for at least 7 days on my computer, unless I kill the process.


I found an old commit that deleted the calls to R_CheckUserInterrupt in many 
basic operations 
(https://github.com/wch/r-source/commit/b99cd362a65012335a853d954cbeb1c782e6ae37)


Why were they deleted ?


First hypothesis : this slowed down the code too much, because it was done 
suboptimally, with an integer division (high latency CPU operation) at each 
iteration.

Second hypothesis : this introduced bugs, such as memory leaks, in code that 
did not handle interruptions gracefully.


If the first hypothesis is correct, I can write much better code, with almost 
zero penalty, using R_ITERATE_CHECK (in R_ext/Itermacros.h) and a new macro I 
wrote: ITERATE_BY_REGION_CHECK.


That would make more operations interruptible and would even provide 
performances improvements in loops that were not optimized for ALTREPs.


Are you interested in patches?



PS: the slow integer division is actually not very slow with recent GCC 
versions, because this compiler is smart enough to replace it by a 
multiplication and a shift because the divisor is known at compile time. Older 
compilers may not be that smart.


--

Sincerely

Andr� GILLIBERT

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to