-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
status/need-investigationThis needs more in-depth investigationThis needs more in-depth investigationtype/enhancementA general enhancementA general enhancement
Milestone
Description
Motivation - Wide internal type-system
instanceof overhead
At the current moment inside the Project Reactor we have a design flaw caused by too broad internal typing causing significant overhead during the construction:
- assembly time and related
Fuseable,Callable, and other type checks (mostly related to Macro-optimizations e.g zipWith, then, similar mutation-related operations) which cause an overhead if the type check fails (a reference benchmark of type check viainstanceofvs bitwise check for characteristics). - subscription time does check for instance type (
instanceofConditionalvsNormal) + in fuseable operators does check forQueueSubscrtiptiontype (with extra requestFusion overhead)
Code Duplicatio
as the result of having wide internal types we are mandated to support identical code for separate implementations (e.g. MapSubscriber vs MapConditionalSubscriber vs MapFuseableSubscriber vs MapFuseableSubscriber)
Context Propagation
TBD
Resource Lifecycle
TBD
Solution
To solve the problem we need to have a generic, unified internal Subscriber type which can resolve all the problems:
public interface InternalCoreSubscriber<T> extends CoreSubscriber<T> {
@Override
default void onSubscribe(Subscription s) {
}
@Override
default void onNext(T value) {
onNext(value, Context.empty());
}
long onSubscribe(CoreSubscription cs, int supportedFusionMode);
long onNext(T value, ContextView context);
void onComplete();
void onError();
/**
* Handles upstream resource termination. Must be called by upstream after their
* emission of onComplete/onError or upon reception of cancel signals.
*
* Intermediate operators MUSt delegate the call of this method to its upstream source
*/
void onClosed();
}
interface CoreSubscription extends Subscription {
@Nullable
<T> Queue<T> requestFusion(int fusion);
}Alternatives
Metadata
Metadata
Assignees
Labels
status/need-investigationThis needs more in-depth investigationThis needs more in-depth investigationtype/enhancementA general enhancementA general enhancement