1515
1616import com .facebook .airlift .configuration .Config ;
1717import com .facebook .airlift .units .DataSize ;
18+ import com .facebook .airlift .units .Duration ;
1819import com .google .common .collect .ImmutableMap ;
1920
2021import java .util .Map ;
22+ import java .util .concurrent .TimeUnit ;
2123
2224import static java .util .Objects .requireNonNull ;
2325
@@ -34,7 +36,6 @@ public class NativeExecutionSystemConfig
3436 private static final String HTTP_SERVER_HTTP_PORT = "http-server.http.port" ;
3537 private static final String HTTP_SERVER_REUSE_PORT = "http-server.reuse-port" ;
3638 private static final String HTTP_SERVER_BIND_TO_NODE_INTERNAL_ADDRESS_ONLY_ENABLED = "http-server.bind-to-node-internal-address-only-enabled" ;
37- private static final String REGISTER_TEST_FUNCTIONS = "register-test-functions" ;
3839 // Number of I/O thread to use for serving http request on presto-native (proxygen server)
3940 // this excludes worker thread used by velox
4041 private static final String HTTP_SERVER_HTTPS_PORT = "http-server.https.port" ;
@@ -86,17 +87,12 @@ public class NativeExecutionSystemConfig
8687 // Presto-on-Spark, we set it to 'query-memory-gb' to allocate all the
8788 // memory arbitrator capacity to the query memory pool on its creation as
8889 // there is only one query running at a time.
89- private static final String MEMORY_POOL_INIT_CAPACITY = "memory-pool-init -capacity" ;
90+ private static final String SHARED_ARBITRATOR_MEMORY_POOL_INITIAL_CAPACITY = "shared-arbitrator. memory-pool-initial -capacity" ;
9091 // Set the reserved memory capacity when we create a query memory pool. For
9192 // Presto-on-Spark, we set this to zero as there is only one query running
9293 // at a time.
93- private static final String MEMORY_POOL_RESERVED_CAPACITY = "memory-pool-reserved-capacity" ;
94- // Set the minimal memory capacity transfer between memory pools under
95- // memory arbitration. For Presto-on-Spark, there is only one query running
96- // so this specified how much memory to reclaim from a query when it runs
97- // out of memory.
98- private static final String MEMORY_POOL_TRANSFER_CAPACITY = "memory-pool-transfer-capacity" ;
99- private static final String MEMORY_RECLAIM_WAIT_MS = "memory-reclaim-wait-ms" ;
94+ private static final String SHARED_ARBITRATOR_MEMORY_POOL_RESERVED_CAPACITY = "shared-arbitrator.memory-pool-reserved-capacity" ;
95+ private static final String SHARED_ARBITRATOR_MAX_MEMORY_ARBITRATION_TIME = "shared-arbitrator.max-memory-arbitration-time" ;
10096 // Spilling related configs.
10197 private static final String SPILLER_SPILL_PATH = "experimental.spiller-spill-path" ;
10298 private static final String TASK_MAX_DRIVERS_PER_TASK = "task.max-drivers-per-task" ;
@@ -140,22 +136,19 @@ public class NativeExecutionSystemConfig
140136 // spilling and cache prefetch.
141137 private DataSize queryMemoryGb = new DataSize (8 , DataSize .Unit .GIGABYTE );
142138
143- private DataSize queryReservedMemoryGb = new DataSize (0 , DataSize .Unit .GIGABYTE );
144139 private boolean useMmapAllocator = true ;
145140 private String memoryArbitratorKind = "SHARED" ;
146141 private int memoryArbitratorCapacityGb = 8 ;
147142 private DataSize sharedArbitratorReservedCapacity = new DataSize (0 , DataSize .Unit .GIGABYTE );
148- private long memoryPoolInitCapacity = 8L << 30 ;
149- private long memoryPoolReservedCapacity ;
150- private long memoryPoolTransferCapacity = 2L << 30 ;
151- private long memoryReclaimWaitMs = 300_000 ;
143+ private DataSize sharedArbitratorMemoryPoolInitialCapacity = new DataSize (4 , DataSize .Unit .GIGABYTE );
144+ private DataSize sharedArbitratorMemoryPoolReservedCapacity = new DataSize (32 , DataSize .Unit .MEGABYTE );
145+ private Duration sharedArbitratorMaxMemoryArbitrationTime = new Duration (5 , TimeUnit .MINUTES );
152146 private String spillerSpillPath = "" ;
153147 private int concurrentLifespansPerTask = 5 ;
154148 private int maxDriversPerTask = 15 ;
155149 private boolean enableOldTaskCleanUp ; // false;
156150 private String prestoVersion = "dummy.presto.version" ;
157151 private String shuffleName = "local" ;
158- private boolean registerTestFunctions ;
159152 private boolean enableHttpServerAccessLog = true ;
160153 private boolean coreOnAllocationFailureEnabled ;
161154 private boolean spillEnabled = true ;
@@ -164,6 +157,18 @@ public class NativeExecutionSystemConfig
164157 private boolean orderBySpillEnabled = true ;
165158 private Long maxSpillBytes = 600L << 30 ;
166159
160+ // TODO: Deprecate following configs
161+ private static final String REGISTER_TEST_FUNCTIONS = "register-test-functions" ;
162+ private static final String MEMORY_POOL_INIT_CAPACITY = "memory-pool-init-capacity" ;
163+ private static final String MEMORY_POOL_RESERVED_CAPACITY = "memory-pool-reserved-capacity" ;
164+ private static final String MEMORY_POOL_TRANSFER_CAPACITY = "memory-pool-transfer-capacity" ;
165+ private static final String MEMORY_RECLAIM_WAIT_MS = "memory-reclaim-wait-ms" ;
166+ private boolean registerTestFunctions ;
167+ private long memoryPoolInitCapacity ;
168+ private long memoryPoolReservedCapacity ;
169+ private long memoryPoolTransferCapacity ;
170+ private long memoryReclaimWaitMs ;
171+
167172 public Map <String , String > getAllProperties ()
168173 {
169174 ImmutableMap .Builder <String , String > builder = ImmutableMap .builder ();
@@ -174,7 +179,6 @@ public Map<String, String> getAllProperties()
174179 .put (HTTP_SERVER_HTTP_PORT , String .valueOf (getHttpServerPort ()))
175180 .put (HTTP_SERVER_REUSE_PORT , String .valueOf (isHttpServerReusePort ()))
176181 .put (HTTP_SERVER_BIND_TO_NODE_INTERNAL_ADDRESS_ONLY_ENABLED , String .valueOf (isHttpServerBindToNodeInternalAddressOnlyEnabled ()))
177- .put (REGISTER_TEST_FUNCTIONS , String .valueOf (isRegisterTestFunctions ()))
178182 .put (HTTP_SERVER_HTTPS_PORT , String .valueOf (getHttpsServerPort ()))
179183 .put (HTTP_SERVER_HTTPS_ENABLED , String .valueOf (isEnableHttpsCommunication ()))
180184 .put (HTTPS_CIPHERS , String .valueOf (getHttpsCiphers ()))
@@ -193,10 +197,9 @@ public Map<String, String> getAllProperties()
193197 .put (MEMORY_ARBITRATOR_KIND , String .valueOf (getMemoryArbitratorKind ()))
194198 .put (MEMORY_ARBITRATOR_CAPACITY_GB , String .valueOf (getMemoryArbitratorCapacityGb ()))
195199 .put (SHARED_ARBITRATOR_RESERVED_CAPACITY , String .valueOf (getSharedArbitratorReservedCapacity ()))
196- .put (MEMORY_POOL_INIT_CAPACITY , String .valueOf (getMemoryPoolInitCapacity ()))
197- .put (MEMORY_POOL_RESERVED_CAPACITY , String .valueOf (getMemoryPoolReservedCapacity ()))
198- .put (MEMORY_POOL_TRANSFER_CAPACITY , String .valueOf (getMemoryPoolTransferCapacity ()))
199- .put (MEMORY_RECLAIM_WAIT_MS , String .valueOf (getMemoryReclaimWaitMs ()))
200+ .put (SHARED_ARBITRATOR_MEMORY_POOL_INITIAL_CAPACITY , String .valueOf (getSharedArbitratorMemoryPoolInitialCapacity ()))
201+ .put (SHARED_ARBITRATOR_MEMORY_POOL_RESERVED_CAPACITY , String .valueOf (getSharedArbitratorMemoryPoolReservedCapacity ()))
202+ .put (SHARED_ARBITRATOR_MAX_MEMORY_ARBITRATION_TIME , String .valueOf (getSharedArbitratorMaxMemoryArbitrationTime ()))
200203 .put (SPILLER_SPILL_PATH , String .valueOf (getSpillerSpillPath ()))
201204 .put (TASK_MAX_DRIVERS_PER_TASK , String .valueOf (getMaxDriversPerTask ()))
202205 .put (ENABLE_OLD_TASK_CLEANUP , String .valueOf (getOldTaskCleanupMs ()))
@@ -208,6 +211,11 @@ public Map<String, String> getAllProperties()
208211 .put (JOIN_SPILL_ENABLED , String .valueOf (getJoinSpillEnabled ()))
209212 .put (ORDER_BY_SPILL_ENABLED , String .valueOf (getOrderBySpillEnabled ()))
210213 .put (MAX_SPILL_BYTES , String .valueOf (getMaxSpillBytes ()))
214+ .put (REGISTER_TEST_FUNCTIONS , String .valueOf (registerTestFunctions ))
215+ .put (MEMORY_POOL_INIT_CAPACITY , String .valueOf (memoryPoolInitCapacity ))
216+ .put (MEMORY_POOL_RESERVED_CAPACITY , String .valueOf (memoryPoolReservedCapacity ))
217+ .put (MEMORY_POOL_TRANSFER_CAPACITY , String .valueOf (memoryPoolTransferCapacity ))
218+ .put (MEMORY_RECLAIM_WAIT_MS , String .valueOf (memoryReclaimWaitMs ))
211219 .build ();
212220 }
213221
@@ -295,18 +303,6 @@ public NativeExecutionSystemConfig setHttpServerBindToNodeInternalAddressOnlyEna
295303 return this ;
296304 }
297305
298- @ Config (REGISTER_TEST_FUNCTIONS )
299- public NativeExecutionSystemConfig setRegisterTestFunctions (boolean registerTestFunctions )
300- {
301- this .registerTestFunctions = registerTestFunctions ;
302- return this ;
303- }
304-
305- public boolean isRegisterTestFunctions ()
306- {
307- return registerTestFunctions ;
308- }
309-
310306 @ Config (HTTP_SERVER_NUM_IO_THREADS_HW_MULTIPLIER )
311307 public NativeExecutionSystemConfig setHttpServerNumIoThreadsHwMultiplier (double httpServerNumIoThreadsHwMultiplier )
312308 {
@@ -511,52 +507,40 @@ public DataSize getSharedArbitratorReservedCapacity()
511507 return sharedArbitratorReservedCapacity ;
512508 }
513509
514- @ Config (MEMORY_POOL_INIT_CAPACITY )
515- public NativeExecutionSystemConfig setMemoryPoolInitCapacity (long memoryPoolInitCapacity )
516- {
517- this .memoryPoolInitCapacity = memoryPoolInitCapacity ;
518- return this ;
519- }
520-
521- public long getMemoryPoolInitCapacity ()
510+ @ Config (SHARED_ARBITRATOR_MEMORY_POOL_INITIAL_CAPACITY )
511+ public NativeExecutionSystemConfig setSharedArbitratorMemoryPoolInitialCapacity (DataSize sharedArbitratorMemoryPoolInitialCapacity )
522512 {
523- return memoryPoolInitCapacity ;
524- }
525-
526- @ Config (MEMORY_POOL_RESERVED_CAPACITY )
527- public NativeExecutionSystemConfig setMemoryPoolReservedCapacity (long memoryPoolReservedCapacity )
528- {
529- this .memoryPoolReservedCapacity = memoryPoolReservedCapacity ;
513+ this .sharedArbitratorMemoryPoolInitialCapacity = sharedArbitratorMemoryPoolInitialCapacity ;
530514 return this ;
531515 }
532516
533- public long getMemoryPoolReservedCapacity ()
517+ public DataSize getSharedArbitratorMemoryPoolInitialCapacity ()
534518 {
535- return memoryPoolReservedCapacity ;
519+ return sharedArbitratorMemoryPoolInitialCapacity ;
536520 }
537521
538- @ Config (MEMORY_POOL_TRANSFER_CAPACITY )
539- public NativeExecutionSystemConfig setMemoryPoolTransferCapacity ( long memoryPoolTransferCapacity )
522+ @ Config (SHARED_ARBITRATOR_MEMORY_POOL_RESERVED_CAPACITY )
523+ public NativeExecutionSystemConfig setSharedArbitratorMemoryPoolReservedCapacity ( DataSize sharedArbitratorMemoryPoolReservedCapacity )
540524 {
541- this .memoryPoolTransferCapacity = memoryPoolTransferCapacity ;
525+ this .sharedArbitratorMemoryPoolReservedCapacity = sharedArbitratorMemoryPoolReservedCapacity ;
542526 return this ;
543527 }
544528
545- public long getMemoryPoolTransferCapacity ()
529+ public DataSize getSharedArbitratorMemoryPoolReservedCapacity ()
546530 {
547- return memoryPoolTransferCapacity ;
531+ return sharedArbitratorMemoryPoolReservedCapacity ;
548532 }
549533
550- @ Config (MEMORY_RECLAIM_WAIT_MS )
551- public NativeExecutionSystemConfig setMemoryReclaimWaitMs ( long memoryReclaimWaitMs )
534+ @ Config (SHARED_ARBITRATOR_MAX_MEMORY_ARBITRATION_TIME )
535+ public NativeExecutionSystemConfig setSharedArbitratorMaxMemoryArbitrationTime ( Duration sharedArbitratorMaxMemoryArbitrationTime )
552536 {
553- this .memoryReclaimWaitMs = memoryReclaimWaitMs ;
537+ this .sharedArbitratorMaxMemoryArbitrationTime = sharedArbitratorMaxMemoryArbitrationTime ;
554538 return this ;
555539 }
556540
557- public long getMemoryReclaimWaitMs ()
541+ public Duration getSharedArbitratorMaxMemoryArbitrationTime ()
558542 {
559- return memoryReclaimWaitMs ;
543+ return sharedArbitratorMaxMemoryArbitrationTime ;
560544 }
561545
562546 @ Config (SPILLER_SPILL_PATH )
@@ -702,4 +686,67 @@ public NativeExecutionSystemConfig setMaxSpillBytes(Long maxSpillBytes)
702686 this .maxSpillBytes = maxSpillBytes ;
703687 return this ;
704688 }
689+
690+ // TODO: All following configs are deprecated and will be removed after references from all
691+ // other systems are cleared.
692+
693+ @ Config (REGISTER_TEST_FUNCTIONS )
694+ public NativeExecutionSystemConfig setRegisterTestFunctions (boolean registerTestFunctions )
695+ {
696+ this .registerTestFunctions = registerTestFunctions ;
697+ return this ;
698+ }
699+
700+ public boolean isRegisterTestFunctions ()
701+ {
702+ return registerTestFunctions ;
703+ }
704+
705+ @ Config (MEMORY_POOL_INIT_CAPACITY )
706+ public NativeExecutionSystemConfig setMemoryPoolInitCapacity (long memoryPoolInitCapacity )
707+ {
708+ this .memoryPoolInitCapacity = memoryPoolInitCapacity ;
709+ return this ;
710+ }
711+
712+ public long getMemoryPoolInitCapacity ()
713+ {
714+ return memoryPoolInitCapacity ;
715+ }
716+
717+ @ Config (MEMORY_POOL_RESERVED_CAPACITY )
718+ public NativeExecutionSystemConfig setMemoryPoolReservedCapacity (long memoryPoolReservedCapacity )
719+ {
720+ this .memoryPoolReservedCapacity = memoryPoolReservedCapacity ;
721+ return this ;
722+ }
723+
724+ public long getMemoryPoolReservedCapacity ()
725+ {
726+ return memoryPoolReservedCapacity ;
727+ }
728+
729+ @ Config (MEMORY_POOL_TRANSFER_CAPACITY )
730+ public NativeExecutionSystemConfig setMemoryPoolTransferCapacity (long memoryPoolTransferCapacity )
731+ {
732+ this .memoryPoolTransferCapacity = memoryPoolTransferCapacity ;
733+ return this ;
734+ }
735+
736+ public long getMemoryPoolTransferCapacity ()
737+ {
738+ return memoryPoolTransferCapacity ;
739+ }
740+
741+ @ Config (MEMORY_RECLAIM_WAIT_MS )
742+ public NativeExecutionSystemConfig setMemoryReclaimWaitMs (long memoryReclaimWaitMs )
743+ {
744+ this .memoryReclaimWaitMs = memoryReclaimWaitMs ;
745+ return this ;
746+ }
747+
748+ public long getMemoryReclaimWaitMs ()
749+ {
750+ return memoryReclaimWaitMs ;
751+ }
705752}
0 commit comments