-
Notifications
You must be signed in to change notification settings - Fork 119
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
Resize tracon count table #1403
Conversation
@ampli I am merging this now, because it seems like the right thing to do. But please review; I do appreciate the comments you make. |
I found several problems.
In addition, if this is as intended, then I don't understand it: link-grammar/link-grammar/parse/count.c Lines 130 to 152 in 8c945d0
link-grammar/link-grammar/parse/count.c Lines 1639 to 1643 in 8c945d0
You allocate here at once a memory block equal to the upper bound. I also found that the Regarding table size: link-grammar/link-grammar/parse/count.c Lines 115 to 116 in 8c945d0
You have changed it from |
OK, I did not understand. Restored in 1193ddd |
For me, I added print statements to link-grammar/link-grammar/parse/count.c Line 210 in 1193ddd
to see if the table doubles past 32 bits. I haven't seen that yet. Whatever; I will change things to use size_t and remove the warning. Also, I removed the large-table warning and went to size_t tables in commit 8b87635 I changed the pool chunk size in 7951ed8 ... I had not previously understood this was a chunk size. Perhaps it might be better to hard-code this size, after all? The last four changes were direct pushes into the repo; would it be better if I had made these into pull reqs, instead? |
I meant the famous sentence from But now I see the reason of link-grammar/link-grammar/parse/count.c Lines 471 to 473 in 7951ed8
link-grammar/link-grammar/parse/count.c Lines 195 to 212 in 7951ed8
Regarding the table size print at line 198, the intention was to print its size after the doubling (the previous code did that). The original code has this: Now there is no limit. In 32 bits it is not a good idea to let it become too big.
Note that we observed the problem of big allocation when the table already used tracons.
The original minimum size was 4096, found after profiling. I will check it again later. More later. |
I don't find a benefit in hard coding that. |
For small changes like typos, comment fixes, code formatting and insignificant changes (like making initializations at declarations instead of code body), direct pushes seems fine. But for more significant changes I thing PR are preferable. |
Mysterious to me too, for now. |
You had originally set it to 16384: link-grammar/link-grammar/parse/count.c Lines 1605 to 1608 in 30065d6
I changed this to be dynamic, but I mis-understood how pools worked when I made this change. That number in Let me know if my logic is still bad, here. |
Per discussion on opencog#1403, and especially comment opencog#1403 (comment) and also opencog#1403 (comment)
OK, I'm putting this back now. See #1405 |
Sorry, I totally misunderstood you. For some reason, I thought that we are talking about hard coding a value in the memory-pool management...
We can think of other strategies for the pool block size that may have a benefit:
|
A fixed size 16384 seems OK. (Or maybe 16383 would be better) Why? The "alloced table connectors" graph in repost: Each horizontal line is a re-alloc of 16K elements. Counting the line, I see that there are 12 lines, 12 allocs that cover almost all cases. The most useful thing to do would be to free all but the bottom 12 blocks during re-use, and possibly adjust the block size at that time. I will write this up more clearly in #1406 (The bottom-most line extends far to the left, cut off in the graph, showing that 16K is much too large for small sentences. But that seems OK...) |
But note that free/malloc cycles are costly, so maybe it is better not to free. BTW, the current memory-pool element alignment code is buggy, and I have a branch that fixes it (need to convert to PR). Other code locations also use non-optimal variable alignments (to be fixed in the same PR). |
Most of this conversation should be moved to #1406 |
Based on the measurements made in #1402, we now have an accurate estimate for the number of tracons that will actually be used during parsing, both for contentional and for MST parsing. Implement those estimates.