Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the overhead of using procedures in Singular #410

Open
zickgraf opened this issue Mar 2, 2021 · 0 comments
Open

Reduce the overhead of using procedures in Singular #410

zickgraf opened this issue Mar 2, 2021 · 0 comments

Comments

@zickgraf
Copy link
Member

zickgraf commented Mar 2, 2021

Currently, using procedures in Singular causes overhead:

  1. When calling a procedure, the arguments are copied, and
  2. 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:

  1. Get rid of aliases. For example, SyzForHomalg and SyzygiesGeneratorsOfRows seem to be aliases.
  2. Inline some procedure calls in Singular.gi. For example, DecideZeroColumns could directly call reduce instead of calling DecideZeroRows.
  3. Do not use procedures at all but put the code directly into SingularBasic.gi.
  4. 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?
  5. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant