* Re: Overlay tree. Stuck again
2017-01-13 11:56 ` Joakim Jalap
@ 2017-01-13 13:22 ` Fabrice Popineau
2017-01-13 14:20 ` Joakim Jalap
2017-01-13 13:54 ` Eli Zaretskii
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Fabrice Popineau @ 2017-01-13 13:22 UTC (permalink / raw)
To: Joakim Jalap; +Cc: Eli Zaretskii, Emacs developers
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
2017-01-13 12:56 GMT+01:00 Joakim Jalap <joakim.jalap@fastmail.com>:
> However, I just had another idea about how to do this (about the 43rd I
> guess), so I will try that and report back in a few weeks :)
>
>
And the 42nd wasn't the right answer? Or what was the question?
(Sorry, couldn't resist).
Fabrice
[-- Attachment #2: Type: text/html, Size: 717 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-01-13 13:22 ` Fabrice Popineau
@ 2017-01-13 14:20 ` Joakim Jalap
0 siblings, 0 replies; 11+ messages in thread
From: Joakim Jalap @ 2017-01-13 14:20 UTC (permalink / raw)
To: Fabrice Popineau; +Cc: Emacs developers
Fabrice Popineau <fabrice.popineau@centralesupelec.fr> writes:
> 2017-01-13 12:56 GMT+01:00 Joakim Jalap <joakim.jalap@fastmail.com>:
>
> However, I just had another idea about how to do this (about the 43rd I
> guess), so I will try that and report back in a few weeks :)
>
> And the 42nd wasn't the right answer? Or what was the question?
When the 42nd failed I decided to ask emacs-devel ;)
> (Sorry, couldn't resist).
Understandable :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-01-13 11:56 ` Joakim Jalap
2017-01-13 13:22 ` Fabrice Popineau
@ 2017-01-13 13:54 ` Eli Zaretskii
2017-01-13 14:26 ` Joakim Jalap
2017-02-03 8:27 ` Andreas Politz
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2017-01-13 13:54 UTC (permalink / raw)
To: Joakim Jalap; +Cc: emacs-devel
> From: Joakim Jalap <joakim.jalap@fastmail.com>
> Cc: emacs-devel@gnu.org
> Date: Fri, 13 Jan 2017 12:56:15 +0100
>
> > This might be a silly idea, but did you try removing them from the
> > tree, and then re-adding them? (I assume that adding a node will
> > produce an ordered tree.)
>
> Yes, that is the "big hammer" approach :) I hae thought about it, but I
> think the problem is that it will be too expensive.
I suggest to implement it and time it. You might be surprised. Even
if you are right, and it is indeed too expensive, you will at the very
least have a base-line performance figure against which you could
compare the alternative solutions.
> However, I just had another idea about how to do this (about the 43rd I
> guess), so I will try that and report back in a few weeks :)
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-01-13 13:54 ` Eli Zaretskii
@ 2017-01-13 14:26 ` Joakim Jalap
0 siblings, 0 replies; 11+ messages in thread
From: Joakim Jalap @ 2017-01-13 14:26 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Joakim Jalap <joakim.jalap@fastmail.com>
>> Cc: emacs-devel@gnu.org
>> Date: Fri, 13 Jan 2017 12:56:15 +0100
>>
>> > This might be a silly idea, but did you try removing them from the
>> > tree, and then re-adding them? (I assume that adding a node will
>> > produce an ordered tree.)
>>
>> Yes, that is the "big hammer" approach :) I hae thought about it, but I
>> think the problem is that it will be too expensive.
>
> I suggest to implement it and time it. You might be surprised. Even
> if you are right, and it is indeed too expensive, you will at the very
> least have a base-line performance figure against which you could
> compare the alternative solutions.
>
If the 43rd fails I will try it :)
Actually I'm afraid it will be too slow anyway. It seems a lot of the
use of overlays is not as "static" as one would like. For example magit
deletes and recreates its overlays every time point moves, even if they
stay in the same place. For such uses I guess a linked list will be a
lot faster than a self balancing tree.
But first I will try to make it work at all :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-01-13 11:56 ` Joakim Jalap
2017-01-13 13:22 ` Fabrice Popineau
2017-01-13 13:54 ` Eli Zaretskii
@ 2017-02-03 8:27 ` Andreas Politz
2017-02-03 8:28 ` Andreas Politz
2017-02-03 8:28 ` Andreas Politz
4 siblings, 0 replies; 11+ messages in thread
From: Andreas Politz @ 2017-02-03 8:27 UTC (permalink / raw)
To: Joakim Jalap; +Cc: Eli Zaretskii, emacs-devel
Joakim Jalap <joakim.jalap@fastmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>> [...] try removing them from the tree, and then re-adding them [...]
>
> Yes, that is the "big hammer" approach :) I hae thought about it, but I
> think the problem is that it will be too expensive. [...]
Joakim, I think that trying to somehow manually fix the disorder is at
least as expensive as a deletion and reinsertion. Because if it weren't
you would have essentially discovered a better algorithm for balancing
trees then the one you've got.
The trick is probably to gather the dirty nodes in post-order and delete
them all at once. This way you're only removing a node, if its
corresponding sub-tree is in order. After that you're free to reinsert
them again.
-ap
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-01-13 11:56 ` Joakim Jalap
` (2 preceding siblings ...)
2017-02-03 8:27 ` Andreas Politz
@ 2017-02-03 8:28 ` Andreas Politz
2017-02-03 12:35 ` Joakim Jalap
2017-02-03 8:28 ` Andreas Politz
4 siblings, 1 reply; 11+ messages in thread
From: Andreas Politz @ 2017-02-03 8:28 UTC (permalink / raw)
To: Joakim Jalap; +Cc: Eli Zaretskii, emacs-devel
Joakim Jalap <joakim.jalap@fastmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>> [...] try removing them from the tree, and then re-adding them [...]
>
> Yes, that is the "big hammer" approach :) I hae thought about it, but I
> think the problem is that it will be too expensive. [...]
Joakim, I think that trying to somehow manually fix the disorder is at
least as expensive as a deletion and reinsertion. Because if it weren't
you would have essentially discovered a better algorithm for balancing
trees then the one you've got.
The trick is probably to gather the dirty nodes in post-order and delete
them all at once. This way you're only removing a node, if its
corresponding sub-tree is in order. After that you're free to reinsert
them again.
-ap
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-02-03 8:28 ` Andreas Politz
@ 2017-02-03 12:35 ` Joakim Jalap
0 siblings, 0 replies; 11+ messages in thread
From: Joakim Jalap @ 2017-02-03 12:35 UTC (permalink / raw)
To: Andreas Politz; +Cc: emacs-devel
Andreas Politz <politza@hochschule-trier.de> writes:
> Joakim Jalap <joakim.jalap@fastmail.com> writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>> [...] try removing them from the tree, and then re-adding them [...]
>>
>> Yes, that is the "big hammer" approach :) I hae thought about it, but I
>> think the problem is that it will be too expensive. [...]
>
> Joakim, I think that trying to somehow manually fix the disorder is at
> least as expensive as a deletion and reinsertion. Because if it weren't
> you would have essentially discovered a better algorithm for balancing
> trees then the one you've got.
Well this case isn't really about rebalncing, since the tree was
balanced to begin with, and no nodes are deleted or inserted. The
problem is that a few overlays end up in the wrong place in the tree
since I sort by different criteria (memory address) than before for
those overlays which happened to end up with the same start/end.
> The trick is probably to gather the dirty nodes in post-order and delete
> them all at once. This way you're only removing a node, if its
> corresponding sub-tree is in order. After that you're free to reinsert
> them again.
Yes, that should do it. But that would be many traversals of the tree,
so I'm afraid it would be too slow.
Anyway, I'm trying a new approach now, where the tree is separate from
the acual struct Lisp_Overlays, but each overlay is linked to a node in
the tree with a pointer (and vice versa). I think this might be easier
(that's my theory at least).
>
> -ap
-- Joakim
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Overlay tree. Stuck again
2017-01-13 11:56 ` Joakim Jalap
` (3 preceding siblings ...)
2017-02-03 8:28 ` Andreas Politz
@ 2017-02-03 8:28 ` Andreas Politz
4 siblings, 0 replies; 11+ messages in thread
From: Andreas Politz @ 2017-02-03 8:28 UTC (permalink / raw)
To: Joakim Jalap; +Cc: Eli Zaretskii, emacs-devel
Joakim Jalap <joakim.jalap@fastmail.com> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>> [...] try removing them from the tree, and then re-adding them [...]
>
> Yes, that is the "big hammer" approach :) I hae thought about it, but I
> think the problem is that it will be too expensive. [...]
Joakim, I think that trying to somehow manually fix the disorder is at
least as expensive as a deletion and reinsertion. Because if it weren't
you would have essentially discovered a better algorithm for balancing
trees then the one you've got.
The trick is probably to gather the dirty nodes in post-order and delete
them all at once. This way you're only removing a node, if its
corresponding sub-tree is in order. After that you're free to reinsert
them again.
-ap
^ permalink raw reply [flat|nested] 11+ messages in thread