Project

General

Profile

Support #1814

Ensure tests do not need too much RAM

Added by John Abbott 23 days ago. Updated 7 days ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
Safety
Target version:
Start date:
07 Apr 2024
Due date:
% Done:

30%

Estimated time:
Spent time:

Description

Ulrich also reported that test-SparsePolyRing2 now needs about 3GiB of RAM at some point. That is rather a lot!
Consider imposing a limit on the amount of RAM a test may use. And verify that all tests are below the limit!


Related issues

Related to CoCoALib - Slug #1813: Some tests have become slowerIn Progress2024-04-07

History

#1 Updated by John Abbott 23 days ago

  • Related to Slug #1813: Some tests have become slower added

#2 Updated by John Abbott 23 days ago

  • Category set to Safety
  • Target version set to CoCoALib-0.99900

On my linux box the command ulimit -v 1048576 will limit memory use to 1GiB (which seems a reasonable limit to me).
I confirm that test-SparsePolyRing2 fails with this limit. I have no tried any other tests.

#3 Updated by John Abbott 23 days ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Assuming that ulimit -v does what I think/hope it does, I confirm that the only test to fail with a limit of 250000kiB is test-SparsePolyRing2.

PS I ran the tests with debugging active.
PPS with a limit of about 100MB also test-DynamicBitset1 and test-RadicalMembership1 failed.

#4 Updated by John Abbott 23 days ago

Strictly this is not CoCoALib but CoCoA-5.
I ran the CoCoA-5 tests with about 0.5GiB memory: there was 1 failure, namely test-radical.cocoa5

Also tried with a limit of about 100Mbytes; again only test-radical failed (but it produced a SEGV?!?)

#5 Updated by Ulrich von der Ohe 23 days ago

The tests test-RadicalMembership1 and test-SparsePolyRing2 are the only ones where memory usage considerably worsened with version 0.99850:

~10 MiB to ~200 MiB (test-RadicalMembership1),
~6 MiB to ~3.2 GiB (test-SparsePolyRing2).

The other tests' memory needs are under 10 MiB, with only two exceptions: test-DynamicBitset1 (~130 MiB) and test-RingFq1 (~30 MiB).

The test test-SparsePolyRing2 didn't change. The 500-fold increased memory consumption is a regression in version 0.99850.

#6 Updated by Ulrich von der Ohe 22 days ago

CoCoALib | Test                      | Wall clock | Max. res. set size (kbytes)
-------------------------------------------------------------------------------
0.99818    test-RadicalMembership1-a   0:00.68         8728
0.99824    test-RadicalMembership1-b   0:01.08        10972
0.99850    test-RadicalMembership1-b   0:01.26       207820

0.99818    test-SparsePolyRing1-a      0:00.00         6108
0.99824    test-SparsePolyRing1-a      0:00.00         6224
0.99850    test-SparsePolyRing1-b      0:00.24         6496

0.99818    test-SparsePolyRing2        0:01.24         6284
0.99824    test-SparsePolyRing2        0:01.19         6288
0.99850    test-SparsePolyRing2        0:04.73      3438404

Appended -a/-b to discriminate between tests that have changed between versions. Those changes in the tests might explain some minor differences.

Changed test do NOT explain the big differences in memory usage coming with 0.99850 in the first and third test, as those tests have not changed between 0.99824 (a prerelease version dated March 18) and 0.99850 (the release, March 29).

PS: Data obtained with /usr/bin/time -v.

#7 Updated by Ulrich von der Ohe 22 days ago

CoCoALib | Test                   | Wall clock | Max. res. set size (kbytes)
----------------------------------------------------------------------------
0.99818    test-SparsePolyRing1-b   0:00.10      6160
0.99824    test-SparsePolyRing1-b   0:00.10      6156
0.99850    test-SparsePolyRing1-a   0:00.01      6184

Thus for test-SparsePolyRing1 it seems to be a combination: The new test takes more time than the old test (also with older CoCoALib versions) and the new CoCoALib version is slower than the older versions for this new test (and also for the older test).

To be clear:
test-SparsePolyRing1-a: test-SparsePolyRing1.C from CoCoALib-0.99818
test-SparsePolyRing1-b: test-SparsePolyRing1.C from CoCoALib-0.99850

#8 Updated by Ulrich von der Ohe 22 days ago

I realize that this issue was intended to be about something else. Feel free to move my posts as you see fit -- sorry for the inconvenience. I think it is more urgent to fix this severe memory usage and performance regression than to introduce checks to prevent similar issues in the future.

#9 Updated by John Abbott 22 days ago

It is not clear to me why test-SparsePolyRing1-b.C should have become slower by a factor of 2.
I'm not surprised by the change in resources needed for test-RadicalMembership1.C since the test has changed considerably (and a bug in the impl was fixed, making the code slower but correct).
As I wrote before, I think I know what the problem with test-SparsePolyRing2.C is; maybe I have an idea how to fix it... It is in the new code Anna introduced for computing radicals (and following a suggestion of mine).

#10 Updated by John Abbott 22 days ago

My idea did not produce much gain (neither regarding time nor memory requirement).
There's a loop somewhere which is creating lots of rings, but I don't know where/why.
Taking a break.

#11 Updated by Ulrich von der Ohe 21 days ago

John Abbott wrote:

I'm not surprised by the change in resources needed for test-RadicalMembership1.C since the test has changed considerably (and a bug in the impl was fixed, making the code slower but correct).

test-RadicalMembership1.C did not change from 0.99824 to 0.99850. Do you think the 20-fold increase in memory usage between these versions is due to the fixed bug?

#12 Updated by John Abbott 21 days ago

I'm not sure if I am recalling correctly the time-line...
  • there was a bug in IsInRadical which meant that it always returned true IIRC
  • I discussed with Anna about speculatively computing radicals of generators when computing radicals of ideals -- this is a good strategy provided that the radical of a polynomial can be computed quickly, but this may not be the case if the characteristic is less than the degree (because the GCD is computed via a syzygy computation)

So, I'm not entirely sure that these change could cause an increase in time and memory requirement... I'm a bit tired this eevening to undertake an investigation -- I did try with valgrind and kcachegrind but that was less helpful than hoped. I hope to discuss with Anna soon, and resolve the matter within a week.

#13 Updated by Ulrich von der Ohe 21 days ago

John Abbott wrote:

  • there was a bug in IsInRadical which meant that it always returned true IIRC

test-RadicalMembership1-b.C (from 0.99824/50) fails when compiled against CoCoALib-0.99718 -- due to a wrong result returned by IsInRadical.

Since the same test succeeds against 0.99824, it seems that that bug is already fixed in 0.99824 (the source code also seems to support this).

Since 0.99824 does not suffer the memory/speed issue, I'd suspect that this issue is NOT due to the bugfix for IsInRadical.

Obviously I'm guessing here which bug you are referring to -- it might be a different one than what the new test checks.

#14 Updated by Anna Maria Bigatti 20 days ago

Ulrich von der Ohe wrote:

test-RadicalMembership1.C did not change from 0.99824 to 0.99850. Do you think the 20-fold increase in memory usage between these versions is due to the fixed bug?

I'll check. I changed the algorithm for the 0-dimensional case: it computes some powers and checks if that is in the ideal. That might be the reason of the increase in memory.
I'll check whether there is also a decent gain in time.

#15 Updated by John Abbott 15 days ago

Anna plans to investigate today

#16 Updated by John Abbott 15 days ago

  • % Done changed from 10 to 20

Anna thinks she has found the cause. She'll do some more tests to confirm; then we hope to fix it.

#17 Updated by John Abbott 7 days ago

  • % Done changed from 20 to 30

I created a memory leak in the gcd function for multivariate polynomials over a finite field. I have a first fix, and am testing it. The CoCoALib and CoCoA-5 tests all pass. The problem with excessive memory consumption seems to be resolved now, but the execution times are still rather slow...
I'll do more testing before checking in.... but not tonight!

Also available in: Atom PDF