scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Add statistics/2 (cputime and inferences)

Open aarroyoc opened this issue 4 years ago • 4 comments

I'm not very sure that I'm counting inferences in the right place (I'm a noob in WAM things). I've seen that CallPolicy has an inference counter also, but it is designed to count only if it has been configured first.

aarroyoc avatar Dec 28 '20 23:12 aarroyoc

This is a hard one for a good first issue. The new module to contain statistics/2 could be named statistics, informations, status, report, gathering or information_gathering.

  1. How would the predicate statistics/2 be used? For inferences, time, ...

An u64 should be enough to count inferences (there aren't 1 BLIPS engines yet).

Having simple code is good but:

  1. Is it required to measure the number of inferences for every execution?

And only some instructions count as inferences. This new feature will also have an impact on the design.

CallPolicy is a trait and CWILCallPolicy has the counter.

... but it is designed to count only if it has been configured first.

Zero-cost abstraction?

ghost avatar Dec 29 '20 11:12 ghost

Thank you a lot for working on this! library(statistics) sounds nice!

As to what is an inference: I think first and foremost call and execute instructions in the WAM should count.

There are also the arithmetic relations one could count. However, they are a bit strange: For example, X is 8^8^8 may count as a single inference, but take thousands of times longer than an inference that only invokes a user-defined predicate.

triska avatar Dec 30 '20 18:12 triska

I do not think that having a u64 for inferences is reasonable, at least if we want Scryer to be stable long time running (I don't know what are BLIPS engines). I've modified the measure place to only count call and execute instructions. If this are the right places, maybe CWICallPolicy should be modified to just take an inferences value at the start and then check the current inference counter (similar to what time is doing).

aarroyoc avatar Jan 08 '21 16:01 aarroyoc

The definition of LIPS and here it's being used to show how fast the engine is. The right unit should be GLIPS.

The inference counter isn't public, so it should be stable. An u64 can store a very big number.

ghost avatar Jan 08 '21 17:01 ghost