-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace pure function invocations in path expressions with their result
In path expressions, we generally need to evaluate functions against every node that we consider for the result set. For example, in the path expression /files/etc/hosts/*[ipaddr =~ regexp('127\\.')], the regexp function was evaluated against every entry in /etc/hosts. Evaluating that function requires the construction and compilation of a new regexp. Because of how memory is managed during evaluation of path expressions, the memory used by all these copies of the same regexp is only freed after we are done evaluating the path expression. This causes unacceptable memory usage in large files (see #569) To avoid these issues, we now distinguish between pure and impure functions in the path expression interpreter. When we encounter a pure function, we change the AST for the path expression so that the function invocation is replaced with the result of invoking the function. With the example above, that means we only construct and compile the regexp '127\\.' once, regardless of how many nodes it gets checked against. That leads to a dramatic reduction in the memory required to evaluate path expressions with such constructs against large files. Fixes #569
- Loading branch information
Showing
2 changed files
with
43 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters