RxInfer.jl icon indicating copy to clipboard operation
RxInfer.jl copied to clipboard

Inplace message passing

Open bartvanerp opened this issue 2 years ago • 1 comments

Not sure whether it should be mentioned here or in ReactiveMP.jl, but for certain applications it is highly beneficial to support inplace operations (rules, computations, basically everything). In my experiments I am running into the issue where memory consumption roughly blows up with 1GB per second, significantly slowing down the inference speed. Especially in the rxinference() function, where the same model gets used to process a stream of data it is very important to have these inplace operations to prevent memory from leaking away and to prevent the garbage collection from slowing down the inference speed.

bartvanerp avatar Feb 28 '23 11:02 bartvanerp

Encountered a similar issue today for a generic function and was thinking about the following to retain backwards compatibility

struct FunctionWithMemory{F <: Function, M} <: Function
    f :: F
    memory :: M
end
(f::FunctionWithMemory)(x...) = f.f(x..., f.memory)

There are probably some flaws with this approach, but might be nice as we then do not have to overhaul all rules at once.

bartvanerp avatar Dec 04 '23 14:12 bartvanerp