From 73bdfdc27f973a50f69bcb937b31eaa65d3f7c13 Mon Sep 17 00:00:00 2001 From: Vishwa Prakash Gayasen Date: Mon, 27 Jan 2025 12:13:25 -0800 Subject: [PATCH] Optimize context prop for reactive applications Summary: - Context prop in reactive application is expensive. This is because executing operator lift on each operator has a cost - A way to avoid this is by applying operator lift only with last operator - This technique will not work if there is a thread-hop in between the operators. Differential Revision: D68533949 fbshipit-source-id: 1f1f2cb975080111e35bf839e1c6a1e2b9d959b0 --- .../thrift/util/resources/ContextPropagationRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third-party/thrift/src/thrift/lib/java/runtime/src/main/java/com/facebook/thrift/util/resources/ContextPropagationRegistry.java b/third-party/thrift/src/thrift/lib/java/runtime/src/main/java/com/facebook/thrift/util/resources/ContextPropagationRegistry.java index ae29b11df2e982..bfc2f61a5714f7 100644 --- a/third-party/thrift/src/thrift/lib/java/runtime/src/main/java/com/facebook/thrift/util/resources/ContextPropagationRegistry.java +++ b/third-party/thrift/src/thrift/lib/java/runtime/src/main/java/com/facebook/thrift/util/resources/ContextPropagationRegistry.java @@ -45,7 +45,7 @@ public static void registerContextPropagationKey(String key) { // Register `ContextPropRunnable` and `ContextPropSubscriber` on first invocation. if (!hooksRegistered) { Schedulers.onScheduleHook("context.propagation", ContextPropRunnable::new); - Hooks.onEachOperator( + Hooks.onLastOperator( Operators.lift((scannable, subscriber) -> new ContextPropSubscriber<>(subscriber))); hooksRegistered = true; }