Skip to content
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

Dead rules elimination #1

Open
vvvvalvalval opened this issue Oct 10, 2016 · 0 comments
Open

Dead rules elimination #1

vvvvalvalval opened this issue Oct 10, 2016 · 0 comments

Comments

@vvvvalvalval
Copy link
Owner

vvvvalvalval commented Oct 10, 2016

Currently, datalog-rules/rules can only return the whole list of registered rules, which potentially contains tens or hundreds of rules.

As long as you only use the returned list without post-processing it, this is fine, because the Datalog engine itself will cache the compilation of this monolithic list of rules. However, if you want to do something fancy e.g adding a programmatically generated rule, you won't hit the cache, causing compilation and caching of a large ruleset at each call, which would be problematic for performance.

Most of the time, a query only needs a very small subset of the registered rules to run. Therefore, we could enhance datalog-rules by adding an option to explicitly state which rules to export, using dependency tracking behind the scenes to export only those rules and their dependencies.

The API could look like:

(dr/rules rs :only [rule-name-1 rule-name-2])

Implementation difficulties:

  • The dependency digraph between rules may not be acyclic, because of mutual recursion.
  • In order to know which rules a given rule depends on, one needs to identify the rule-exprs in its body, which may require nontrivial parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant