Tabling space error

Good evening :slight_smile:

I have a program that uses tabling on 4 predicates. Seemingly randomly I get an error:
ERROR: '$tbl_variant_table'/6: Not enough resources: private_table_space

Running the program at other times it completes really quickly. I don’t really understand why.

Anybody have any suggestions? Is there a point in increasing the space for tabling? I think its at 1 GB right now.

/JC

I noted here that the use of tabling with impure programs can cause problems. I had a ->/2 and a cut. I’ll remove these first to see if things improve. I also have a retract/1 and assert/1. I guess I should try table as incremental on these. Or maybe remove any asserts or retracts.

Commits (->, !) are ok as long as the goals that are cut are fully evaluated. The current SWI-Prolog implementation does, unlike XSB, not verify this.

assert/1 and retract/1 on anything that affects the outcome of tabled predicates leads to problems. Incremental tabling re-evaluates affected tables, but completing the table may not use assert/retract on predicates that are dependents from the tabled goal being reevaluated. That is verified at runtime and a violating assert/retract results in a permission exception.

Note that in general the order of results under tabling is undefined and may differ between runs of the same goal (after wiping the table, otherwise it simply returns the content of the table). This can lead do differences in memory usage between runs. Illegal assert/retract and ->, ! can cause widely different results due to reordering. Otherwise the set of solutions must be the same each run, only the order may differ.

Thanks for the detailed answer @jan ! This helps me to head in the right direction :slight_smile:

What does “fully evaluated” mean? I found this in the documentation, but it didn’t illuminate me:

Notably pruning choice points of an incomplete tabled goal may cause an incomplete table and thus cause subsequent queries for the same goal to return an incomplete set of answers. (The word “completed” is marked as “jargon”, but I couldn’t see a definition of it.)

(My guess is that “completed” and “fully evaluated” both mean "the table contains all the answers for this query and there’s no need to evaluate the query further.)