Open
Description
Currently, using procedures in Singular causes overhead:
- When calling a procedure, the arguments are copied, and
- when returning multiple values, the values have to be copied (twice in the current implementation, Return list expressions instead of lists in Singular #409 reduces this to one copy).
This causes unexpected peak RAM usage and slowdowns, noticeable for large (say, 10000x10000) matrices.
There are multiple possible solutions/improvements:
- Get rid of aliases. For example,
SyzForHomalg
andSyzygiesGeneratorsOfRows
seem to be aliases. - Inline some procedure calls in
Singular.gi
. For example,DecideZeroColumns
could directly callreduce
instead of callingDecideZeroRows
. - Do not use procedures at all but put the code directly into
SingularBasic.gi
. - Use references to avoid the copies: https://www.singular.uni-kl.de/Manual/4-2-0/sing_200.htm#SEC240 References are a feature marked as experimental, but since we would use them in a very basic way, we might be safe?
- Talk to the Singular people about some way to pass arguments by reference and some way to avoid copies when returning multiple values (for single values there actually is some logic preventing unnecessary copies).
As always, there are obvious pros and cons :D
Edit: I just noticed that even kernel functions (e.g. module
) and syntactic structures (see example below) have a similar overhead. So I'm not sure if it really makes sense to invest time here.
Example:
ring R;
matrix A[10000][10000];
matrix B[10000][10000];
matrix C[20000][10000] = A,B;
During the computation of C
there is a noticeable peak in RAM usage. I assume this is also due to copying some stuff internally stuff.
Metadata
Metadata
Assignees
Labels
No labels