aardvark-platform / aardvark.base

Aardvark.Base is the foundation of the open-source Aardvark Platform for visual computing, real-time graphics, and visualization.
https://aardvarkians.com/
Apache License 2.0
154 stars 9 forks source link

AdaptiveSet passThrough optimization on Remove does not work #19

Closed haraldsteinlechner closed 8 years ago

haraldsteinlechner commented 8 years ago

in Remove:

                | None ->
                    r.RemoveOutput ri
                    readers.Remove ri |> ignore

                    if readerCount = 2 then
                        let r = readers |> Seq.exactlyOne
                        r.SetPassThru(true, false)
                        onlyReader <- Some r

            readerCount <- readerCount - 1

Seq.exactlyOne fails because of concurrent modification on readers if remove is called concurrently by the GC. For the moment i disabled the check and stay in non-pass-through

haraldsteinlechner commented 8 years ago

nothing helps here, it is very common that GC destroys all kinds of mutable state. Either more locking or less finalizers

haraldsteinlechner commented 8 years ago

6845501343a16ab1503ab50da77d59644843e88e at elast symptomatically solves some issues. firstly, remove shall only decrement readers count if the reader is a valid reader (and can thus be counted). Secondly, via finalizers, remove calls can be unsynchronized, therefore the additional (possibly nested) lock in local remove. Thirdly, MutableVolatileDirtySet now performs eval on a copy. This is not totally threadsafe but at least does not produce lost updates (eventually).

krauthaufen commented 8 years ago

Should be working right now...

krauthaufen commented 8 years ago

Test in aardvark.base.incremental.tests