Re: [elixir-core:11721] Performance of local function capture

2024-03-26 Thread Michał Muskała
The are some subtle differences - the function needs to be exported (remote capture doesn't work with defp). Furthermore, there's a difference in case of module reloading - local capture will always dispatch into the version of the module that created it, remote capture will always dispatch to the

Re: [elixir-core:11721] Performance of local function capture

2024-03-26 Thread Paul Schoenfelder
They aren't exactly equivalent. The difference comes into play with code loading. The local captures will reference the version of the module they were captured with, while remote/external captures will always reference the latest version of the module. Depending on what the closure is doing, t

Re: [elixir-core:11721] Performance of local function capture

2024-03-26 Thread 'Rudolf Manusadzhian' via elixir-lang-core
Looking at this PR (when the recommendation to use external functions was added to :telemetry) ... when anonymous functions are copied into the process heap from ETS, a global reference counter is incremented ... And from this comment

Re: [elixir-core:11721] Performance of local function capture

2024-03-26 Thread 'Rudolf Manusadzhian' via elixir-lang-core
The description of this PR and this comment suggest that the issue shows up when multiple processes concurrently call the function ... the issue is the copying of

Re: [elixir-core:11721] Performance of local function capture

2024-03-26 Thread 'Rudolf Manusadzhian' via elixir-lang-core
The description and the comments in this PR suggest that the issue appears when multiple processes concurrently call the function > ... the issue is the copying of the anonymous function from ETS to the process heap (caller) requires a reference counter to be incremented for garbage collection.