@@ -681,6 +681,8 @@ class NavyConfig {
681
681
682
682
static constexpr folly::StringPiece kAdmPolicyRandom {" random" };
683
683
static constexpr folly::StringPiece kAdmPolicyDynamicRandom {" dynamic_random" };
684
+ static constexpr uint32_t kDefaultNumReaderThreads {32 };
685
+ static constexpr uint32_t kDefaultNumWriterThreads {32 };
684
686
685
687
bool usesSimpleFile () const noexcept { return !fileName_.empty (); }
686
688
bool usesRaidFiles () const noexcept { return raidPaths_.size () > 0 ; }
@@ -714,7 +716,7 @@ class NavyConfig {
714
716
bool getTruncateFile () const { return truncateFile_; }
715
717
uint32_t getDeviceMaxWriteSize () const { return deviceMaxWriteSize_; }
716
718
IoEngine getIoEngine () const { return ioEngine_; }
717
- unsigned int getQDepth () const { return qDepth_; }
719
+ uint32_t getQDepth () const { return qDepth_; }
718
720
BadDeviceStatus hasBadDeviceForTesting () const { return testingBadDevice_; }
719
721
720
722
// Return a const BigHashConfig to read values of its parameters.
@@ -730,13 +732,19 @@ class NavyConfig {
730
732
}
731
733
732
734
// ============ Job scheduler settings =============
733
- unsigned int getReaderThreads () const { return readerThreads_; }
734
- unsigned int getWriterThreads () const { return writerThreads_; }
735
+ uint32_t getReaderThreads () const {
736
+ // return default value if it's not explicitly set
737
+ return (readerThreads_ == 0 ) ? kDefaultNumReaderThreads : readerThreads_;
738
+ }
739
+ uint32_t getWriterThreads () const {
740
+ // return default value if it's not explicitly set
741
+ return (writerThreads_ == 0 ) ? kDefaultNumWriterThreads : writerThreads_;
742
+ }
735
743
uint64_t getNavyReqOrderingShards () const { return navyReqOrderingShards_; }
736
744
737
- unsigned int getMaxNumReads () const { return maxNumReads_; }
738
- unsigned int getMaxNumWrites () const { return maxNumWrites_; }
739
- unsigned int getStackSize () const { return stackSize_; }
745
+ uint32_t getMaxNumReads () const { return maxNumReads_; }
746
+ uint32_t getMaxNumWrites () const { return maxNumWrites_; }
747
+ uint32_t getStackSize () const { return stackSize_; }
740
748
// ============ other settings =============
741
749
uint32_t getMaxConcurrentInserts () const { return maxConcurrentInserts_; }
742
750
uint64_t getMaxParcelMemoryMB () const { return maxParcelMemoryMB_; }
@@ -806,8 +814,23 @@ class NavyConfig {
806
814
// If enabled already via job config settings, this will override
807
815
// the qDepth_ or enableIoUring_.
808
816
// If qDepth is 0, existing qDepth_ will be used
817
+ // * CAUTION: This version of enableAsyncIo() is DEPRECATED.
818
+ // Please use the version with four arguments below
809
819
void enableAsyncIo (unsigned int qDepth, bool enableIoUring);
810
820
821
+ // Enable async IO (IO to the device) - either libaio or io_uring
822
+ // - maxNumReads : the number of concurrent reads issued to the queues and in
823
+ // process
824
+ // - maxNumWrites: the number of concurrent writes issued to the queues
825
+ // and in process
826
+ // - useIoUring : true to use io_uring
827
+ // - stackSizeKB : size of the stack for each fibers with the async job
828
+ // scheduler. 0 for default stack size
829
+ void enableAsyncIo (uint32_t maxNumReads,
830
+ uint32_t maxNumWrites,
831
+ bool useIoUring,
832
+ uint32_t stackSizeKB = 0 );
833
+
811
834
// ============ BlockCache settings =============
812
835
// Return BlockCacheConfig for configuration.
813
836
BlockCacheConfig& blockCache () noexcept {
@@ -828,12 +851,19 @@ class NavyConfig {
828
851
// ============ Job scheduler settings =============
829
852
// Set the number of reader threads and writer threads.
830
853
// If maxNumReads and maxNumWrites are all 0, sync IO will be used
854
+ // * CAUTION: This version of setReaderAndWriterThreads() is DEPRECATED.
855
+ // Please use the version with two arguments below.
831
856
void setReaderAndWriterThreads (unsigned int readerThreads,
832
857
unsigned int writerThreads,
833
- unsigned int maxNumReads = 0 ,
834
- unsigned int maxNumWrites = 0 ,
858
+ unsigned int maxNumReads,
859
+ unsigned int maxNumWrites,
835
860
unsigned int stackSizeKB = 0 );
836
861
862
+ // ============ Job scheduler settings =============
863
+ // Set the number of reader threads and writer threads.
864
+ void setReaderAndWriterThreads (uint32_t readerThreads,
865
+ uint32_t writerThreads);
866
+
837
867
// Set Navy request ordering shards (expressed as power of two).
838
868
// @throw std::invalid_argument if the input value is 0.
839
869
void setNavyReqOrderingShards (uint64_t navyReqOrderingShards);
@@ -893,7 +923,7 @@ class NavyConfig {
893
923
894
924
// Number of queue depth per thread for async IO.
895
925
// 0 for Sync io engine and >1 for libaio and io_uring
896
- unsigned int qDepth_{0 };
926
+ uint32_t qDepth_{0 };
897
927
898
928
// ============ Engines settings =============
899
929
// Currently we support one pair of engines.
@@ -903,9 +933,9 @@ class NavyConfig {
903
933
904
934
// ============ Job scheduler settings =============
905
935
// Number of asynchronous worker thread for read operation.
906
- unsigned int readerThreads_{32 };
936
+ uint32_t readerThreads_{0 };
907
937
// Number of asynchronous worker thread for write operation.
908
- unsigned int writerThreads_{32 };
938
+ uint32_t writerThreads_{0 };
909
939
// Number of shards expressed as power of two for native request ordering in
910
940
// Navy.
911
941
// This value needs to be non-zero.
@@ -915,11 +945,11 @@ class NavyConfig {
915
945
// This needs to be a multiple of the number of readers and writers.
916
946
// Setting this to non-0 will enable async IO where fibers are used
917
947
// for Navy operations including device IO
918
- unsigned int maxNumReads_{0 };
919
- unsigned int maxNumWrites_{0 };
948
+ uint32_t maxNumReads_{0 };
949
+ uint32_t maxNumWrites_{0 };
920
950
921
951
// Stack size of fibers when async-io is enabled. 0 for default
922
- unsigned int stackSize_{0 };
952
+ uint32_t stackSize_{0 };
923
953
924
954
// ============ Other settings =============
925
955
// Maximum number of concurrent inserts we allow globally for Navy.
0 commit comments