Explosive RAM usage #1402
Replies: 14 comments 34 replies
-
Parse time goes as the square of the number of disjuncts: The number of Each Note the vertical scale. The right-most data cross is at 15 GBytes, which matches the max RAM usage for The remaining work is to figure out how to put a cap on this, so that I can avoid RAM consumption explosions. Maybe Raw data and graphs are in https://github.com/linas/link-grammar/tree/r18-overflow/link-grammar/parse |
Beta Was this translation helpful? Give feedback.
-
Here is another: the number of parse-set buckets allocated as a function of the number of disjuncts in the sentence. These are the buckets in the What is interesting here is that the number of buckets goes as the 1.5 power of the number of disjuncts. So .. neither a square nor linear, but exactly in between ... how surprising! Somewhat upsetting is that the predictive power of the number of disjuncts starts failing when #djs is greater than about 40K -- note that just past 40K, there are some cases with 1024 buckets (the minimum in Anyway, as a result of this, I plan to change the |
Beta Was this translation helpful? Give feedback.
-
Here is how the number of the number of table-connectors scales with the number of disjuncts. The graph stops at exactly 30K disjuncts; I put in a hard-stop there, because otherwise parses take too long. BTW, to measure this, I did a Two lines, one with power of 1.2 and one with power 1.4 .. these are eyeballed fits. Given the earlier results that |
Beta Was this translation helpful? Give feedback.
-
To be investigated...
We can even try |
Beta Was this translation helpful? Give feedback.
-
It seems I missed something. Which one? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
*Edited: I removed three graphs that were mistaken. Nothing depends on For buckets, lets try graphing vs. disjuncts per word. This looks much better. For the Above graph is for |
Beta Was this translation helpful? Give feedback.
-
Regarding the |
Beta Was this translation helpful? Give feedback.
-
More graphs. This shows The sentence Exp pool is used before the disjuncts are built. We've got no prior size from which to estimate what the above could be. It is what it is. The only optimization I see here is to delete the However, the This shows Maybe the This shows The MST Note the strange pathology at the upper right. Pool sizes get strangely large for some rare cases w/ MST parsing, when there are more than 25K disjuncts. Don't know why this happens. Like above, except its MLC vs exp. The various lines are attempts to estimate the MLC pool size, and to place an upper bound on it (derived from the expression pool size). This is done in #1414 I have no clue what wordvecs are. This graph is weird and hard to understand it. The "poolsize" is |
Beta Was this translation helpful? Give feedback.
-
@ampli Do you have any idea why parse-choices are appended to the tail? Here: link-grammar/link-grammar/parse/extract-links.c Lines 126 to 142 in 7951ed8 Seems to me we could chain to the head, and save a pointer in the bucket. If for some reason the order is important, it could always be reversed later? ?? |
Beta Was this translation helpful? Give feedback.
-
The graph below will form the basis for estimating the Below is the same graph, except this time, the actual number of buckets issued is graphs, instead of buckets alloced. Thus, the horizontal bars go away. The stepped black line is the result of taking the ceil of the size estimate, making the hash table size always be a power of two. Below is the same graph as above, but now extended to smaller sizes. Huh. Go figure. |
Beta Was this translation helpful? Give feedback.
-
Time to wrap it up. More or less everything noted above has been implemented, except for a few ideas that don't see so important any more. -- #1406 and #1413 Lets remeasure parse time. Above is just what it says it is. Several things that are notable:
|
Beta Was this translation helpful? Give feedback.
-
The End. I think I'm done. Once again, all code is in https://github.com/linas/link-grammar/tree/r18-overflow/link-grammar/parse *.dat, *.gplot and the *.png can be recreated from the gplot files. |
Beta Was this translation helpful? Give feedback.
-
@ampli For your entertainment... I've been chasing something that feels like a mem leak, but isn't. I'm starting to understand it; I don't quite completely, so this is a developing story.
During parsing, I'm seeing memory consumption shooting up to 20GB, 50GB, 100GB RAM -- just outrageous RAM usage. Feels like a mem-leak, right? But its not. I'd hunted for mem leaks before, in discussion #1373 and there aren't any.
Ran a nice tool called
heaptrack
to collect a malloc/free trace. It also confirms that there are no memleaks. It does show, however, a "peak use" of 15GB (on a small dataset) inmake_choice()
in the amount of RAMParse_choice
. So I printed out how many of these get alloced per sentence. I'm also tracking the time to parse, and the number of disjuncts (after pruning). I made some graphs. It's interesting.But first: some comments about the dictionary: It's unusual: it consists only of links between word-pairs, with a cost on each word-pair. When the parser asks for word expressions, the dict finds every possible word pair involving that word, and creates an expression of four optional connectors to the other word in the pair. The cost on that expression is the sum of the costs on the links. That's the word expression.
The result of parsing with this expression is called a "minimum spanning tree parse"; the final parse is the one that minimizes the total cost of all the links between word-pairs.
So, for example, parsing "this is a test", the pair
(this, is)
gets an autogenerated link typeA
and(this, apple)
getsB
and(this, cat)
getsC
...many thousands.(is, test)
getsP
and(is, dog)
getsQ
... so the word expression foris
is created asso clearly this is very large. But .. not a problem. Expression pruning and power pruning chops this down to size in a few milliseconds; its very impressive how fast these are.
This leaves me with sentences that have 10K to 30K disjuncts in them, total. (All of my "sentences" are exactly 9 words long). Now, on to counting and building parse choices... see below.
Beta Was this translation helpful? Give feedback.
All reactions