Search code examples
c#.netsystem.reactivecompiler-flags

What is the NO_PERF flag in reactive extensions source code doing


In the ReactiveExtensions source code there are huge swathes of codes switching between different implementations such as

https://github.com/Reactive-Extensions/Rx.NET/blob/master/Rx.NET/Source/System.Reactive.Linq/Reactive/Linq/QueryLanguage.StandardSequenceOperators.cs

and a snippet

#if !NO_PERF
    return new Distinct<TSource, TSource>(source, x => x, EqualityComparer<TSource>.Default);
#else
     return Distinct_(source, x => x, EqualityComparer<TSource>.Default);
#endif

what is the intention of this flag NO_PERF and what is the difference in behaviour between the library compiled with it and without it.


Solution

  • As a member of the Rx team, I can answer this:

    The answer goes back to our changes from Rx 1.1 to Rx 2.0. We wanted the ability to keep the old style of using AnonymouseObservable around just in case, but for most of the time, you want the performance enhanced version.

    There are big differences in both performance, and in some cases more eager disposal. You can find out more information about our changes here.