-
Notifications
You must be signed in to change notification settings - Fork 110
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
[WIP] Implement boolean preambles #204
base: master
Are you sure you want to change the base?
Conversation
Note: While looking into this subject, I noticed that |
This is very interesting, thanks. I hadn't thought of using the new defpred macro to define normalizer- and preamble-only versions of the booleans. Assuming that everything works as intended, and we don't cause any edge cases to regress in performance, this is certainly an improvement I'd like to make. Here are a few thoughts from a quick look:
I'm not sure what you mean. If its preamble is unused, what else would it do? And Thanks for your work on this. |
I agree that it is difficult to read. But what would be an alternative to get preamble/normalization recursively? The best way I can see is documenting it as you did for
Those are generated by expansion of
It is related to another idea I have not mentioned here. I wanted to make use of predicates :body code moving point. For now, if predicate code moves the point, org-ql continues the search from the heading next to the new position. This might be useful for additional speedup. Say, outline-path predicate could search forward for regexp With current Anyway, It is not reletad to this particular pull request and I will remove
Intresting. Thanks for the pointer.
|
Ah, you're right, I think I copied that from the old, giant I'm not sure of the best way to handle that. It might be an acceptable transgression for us to keep using it this way, for now, anyway, but I should probably at least add relevant comments in the code. In the long run, it should probably be cleaned up.
Hmm, I may be mistaken, because I did that work a while ago, but I don't think the existing code on
I would certainly appreciate keeping those changes separate. (Fair warning, I doubt I would approve of that idea. It's interesting, but it would significantly increase complexity and make mistakes much more likely. I don't think it would be worth it. Rather, I think optimization efforts should focus on using preambles better.)
I see. Well, 1. why are you disabling preambles? =) 2. Feel free to open an issue suggesting that that function be improved to only get inherited tags when necessary. That might be doable without too much complexity. OTOH, that would probably mean more branching in the common case, which might reduce performance generally, so it would need to be carefully benchmarked. |
As tentative solution, I changed
Yep. The warning were related to the new approach. I fixed the warnings now. Defpred
Sure. Done.
That's the only idea I came up with to speed up outline-path queries. I use those frequently and they are unacceptably slow now. Is there even a way to construct preamble for outline-path predicate?
In this particular case, it was the result of changes I made in this pull request. However, preambles would not be used on master in queries like
What about simply using normalizer:
|
Otherwise, children queries may generate wrong tags and pollute tag cache.
a4f5917
to
567c4c4
Compare
4f5fbc4
to
d0acc8c
Compare
059b10c
to
77b4c2b
Compare
I have been recently playing with idea of automatic preamble calculation for
(or ...)
,(and ...)
and similar queries.If I understand correctly, preamble is dropped on master for any boolean expression, except
(and ...)
. However,(or ...)
could also be optimised if all the sexps insideor
have non-nil predicates.This pull request is a not-yet-ready-to-merge draft where I want to ask your opinion about this idea. I implemented boolean expressions
(and ...)
,(or ...)
,(when ...)
,(unless ...)
, and(not ...)
as actual predicates, so that preambles can be transparently defined.Some benchmarks with
elp
on my setup with complex agenda queries:;;Function number_of_invocations total_time average_time
;; Old (agenda n)
;;org-agenda 1 45.655149553 45.655149553
;;org-ql--select 2255 37.698226351 0.0167176170
;;re-search-forward 336625 6.2799195780 1.865...e-05
;;org-ql--query-preamble 2265 0.0108973820 4.811...e-06
;;org-ql--normalize-query 2265 0.0088714750 3.916...e-06
;; New (agenda n)
;;org-agenda 1 22.979330424 22.979330424
;;org-ql--select 1261 15.829318511 0.0125529885
;;re-search-forward 256703 4.8654712150 1.895...e-05
;;org-ql--normalize-query 1274 0.0073856340 5.797...e-06
;;org-ql--query-preamble 1274 0.0045016170 3.533...e-06
Note the difference in number of
re-search-forward
calls: 256703 (new) vs. 336625 (old). This is mostly because(or ...)
queries can now have preamble. I have seen up to several times less calls depending on what kind of query I am using.The caveat is (sometimes) increased time spend on each
re-search-forward
. Combined preamble for(or ...)
consists of(rx
(| individual-preambles))` increasing the complexity of preamble regexp. For very small queries involving many timestamps, regexp search sometimes ate up all the speed improvement as the time for each individual regexp search increased several times.