Repository: aptos-labs/aptos-core
File: config/src/config/api_config.rs (Rust)

Code before:
impl Default for ApiConfig {
    fn default() -> ApiConfig {
        ApiConfig {
            enabled: default_enabled(),
            address: format!("{}:{}", DEFAULT_ADDRESS, DEFAULT_PORT)
                .parse()
                .unwrap(),
            tls_cert_path: None,
            tls_key_path: None,
            content_length_limit: None,
            failpoints_enabled: default_disabled(),
            bcs_output_enabled: default_enabled(),
            json_output_enabled: default_enabled(),
            compression_enabled: default_enabled(),
            encode_submission_enabled: default_enabled(),
            transaction_submission_enabled: default_enabled(),
            transaction_simulation_enabled: default_enabled(),
            max_submit_transaction_batch_size: DEFAULT_MAX_SUBMIT_TRANSACTION_BATCH_SIZE,
            max_block_transactions_page_size: *MAX_RECEIVING_BLOCK_TXNS as u16,
            max_transactions_page_size: DEFAULT_MAX_PAGE_SIZE,
            max_events_page_size: DEFAULT_MAX_PAGE_SIZE,
            max_account_resources_page_size: DEFAULT_MAX_ACCOUNT_RESOURCES_PAGE_SIZE,
            max_account_modules_page_size: DEFAULT_MAX_ACCOUNT_MODULES_PAGE_SIZE,
            max_gas_view_function: DEFAULT_MAX_VIEW_GAS,
            max_runtime_workers: None,
            runtime_worker_multiplier: 1,
            gas_estimation: GasEstimationConfig::default(),
            periodic_gas_estimation_ms: Some(30_000),
            view_filter: ViewFilter::default(),
            periodic_function_stats_sec: Some(60),
            wait_by_hash_timeout_ms: 1_000,
            wait_by_hash_poll_interval_ms: 20,
            wait_by_hash_max_active_connections: 100,
            allow_encrypted_txns_submission: false,
        }
    }
}

impl ApiConfig {
    pub fn randomize_ports(&mut self) {
        self.address.set_port(utils::get_available_port());
    }

    pub fn content_length_limit(&self) -> u64 {
        match self.content_length_limit {
            Some(v) => v,
            None => DEFAULT_REQUEST_CONTENT_LENGTH_LIMIT,
        }
    }
}


Review comment (performance):
FYI, this was originally set to `2` because it was the most optimal from a performance perspective, i.e., the REST API could handle more QPS when we doubled the threads (likely because of thread blocking issues?). 

Code after:
impl Default for ApiConfig {
    fn default() -> ApiConfig {
        ApiConfig {
            enabled: default_enabled(),
            address: format!("{}:{}", DEFAULT_ADDRESS, DEFAULT_PORT)
                .parse()
                .unwrap(),
            tls_cert_path: None,
            tls_key_path: None,
            content_length_limit: None,
            failpoints_enabled: default_disabled(),
            bcs_output_enabled: default_enabled(),
            json_output_enabled: default_enabled(),
            compression_enabled: default_enabled(),
            encode_submission_enabled: default_enabled(),
            transaction_submission_enabled: default_enabled(),
            transaction_simulation_enabled: default_enabled(),
            max_submit_transaction_batch_size: DEFAULT_MAX_SUBMIT_TRANSACTION_BATCH_SIZE,
            max_block_transactions_page_size: *MAX_RECEIVING_BLOCK_TXNS as u16,
            max_transactions_page_size: DEFAULT_MAX_PAGE_SIZE,
            max_events_page_size: DEFAULT_MAX_PAGE_SIZE,
            max_account_resources_page_size: DEFAULT_MAX_ACCOUNT_RESOURCES_PAGE_SIZE,
            max_account_modules_page_size: DEFAULT_MAX_ACCOUNT_MODULES_PAGE_SIZE,
            max_gas_view_function: DEFAULT_MAX_VIEW_GAS,
            max_runtime_workers: None,
            runtime_worker_multiplier: 2,
            gas_estimation: GasEstimationConfig::default(),
            periodic_gas_estimation_ms: Some(30_000),
            view_filter: ViewFilter::default(),
            periodic_function_stats_sec: Some(60),
            wait_by_hash_timeout_ms: 1_000,
            wait_by_hash_poll_interval_ms: 20,
            wait_by_hash_max_active_connections: 100,
            allow_encrypted_txns_submission: false,
        }
    }
}

impl ApiConfig {
    pub fn randomize_ports(&mut self) {
        self.address.set_port(utils::get_available_port());
    }

    pub fn content_length_limit(&self) -> u64 {
        match self.content_length_limit {
            Some(v) => v,
            None => DEFAULT_REQUEST_CONTENT_LENGTH_LIMIT,
        }
    }
}