# Detailed tabling statistics

**URL:** <https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730>\
**Category:** Help!\
**Created:** [May 27, 2019, 2:14pm UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730 "2019-05-27T14:14:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![damiazz94](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@damiazz94](https://swi-prolog.discourse.group/u/damiazz94)\
**Post date:** [May 27, 2019, 2:14pm UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730/1 "2019-05-27T14:14:15Z")

</div>

Hi. I’m wondering if there is some predicate that can display detailed informations about tabling. Something like `statistics/2` with a key for tabling. For instance, in XSB, `statistics/0` displays also informations about tabling. I cannot see something similar in SWI Prolog.

Thanks.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 28, 2019, 12:53pm UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730/2 "2019-05-28T12:53:21Z")

</div>

Not really. You can enumerate the tries and get some statistics on them. Tabling is much in flux. I am very much interested in peoples practical experience, also to know where to put priorities. What are you looking for?

---

<div class="post-metadata">

**Author:** ![damiazz94](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@damiazz94](https://swi-prolog.discourse.group/u/damiazz94)\
**Post date:** [May 28, 2019, 8:55pm UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730/3 "2019-05-28T20:55:24Z")

</div>

Something interesting could be for instance the memory usage or the number of time a tabled predicate is called during the resolution.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 29, 2019, 6:52am UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730/4 "2019-05-29T06:52:57Z")

</div>

You can get a reasonable view on the memory usage using the predicates to find the answer tries and use trie\_property/2 to find the memory usage of each trie. Would be nice to write some utilities on top of that. I already have some in my private library, but memory consumption is not on the top of my agenda right now. These are correctness and performance.

To find calls, simply use the profiler. The interesting part is the number of suspensions that are restarted. These are in call\_continuation/1, but it would be interesting to have timings on the various continuations individually. That is not easily accessible. Still, the profiler gives a lot of information, also to figure out what goes on inside tabling.

---

<div class="post-metadata">

**Author:** ![damiazz94](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@damiazz94](https://swi-prolog.discourse.group/u/damiazz94)\
**Post date:** [May 29, 2019, 1:12pm UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730/5 "2019-05-29T13:12:30Z")

</div>

Is there any example on how to use trie and relative predicates such as trie\_property? I’ve looked into the documentation but i didn’t get how to use it, thanks!

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 29, 2019, 1:41pm UTC](https://swi-prolog.discourse.group/t/detailed-tabling-statistics/730/6 "2019-05-29T13:41:14Z")

</div>

Try

```prolog
?- current_table(M:H, Table),
   trie_property(Table, size(Bytes)).

```

Note that current\_table/2 has a bit odd semantics, interpreting `H` as a variant if it is non-var and as a pattern to access all tables if it is var. Most likely these will be replaced by the table predicates from XSB that are available in `library(dialect/xsb/tables)`
