Skip to content

Commit

Permalink
feat: set default n_threads to min(4, proc_count)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Mar 22, 2023
1 parent dce190b commit 87d0b02
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions android/src/main/jni/whisper/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ static inline int min(int a, int b) {
return (a < b) ? a : b;
}

static inline int max(int a, int b) {
return (a > b) ? a : b;
}

extern "C" {

JNIEXPORT jlong JNICALL
Expand Down Expand Up @@ -63,7 +59,7 @@ Java_com_rnwhisper_WhisperContext_fullTranscribe(
jfloat *audio_data_arr = env->GetFloatArrayElements(audio_data, nullptr);
const jsize audio_data_length = env->GetArrayLength(audio_data);

int max_threads = max(1, min(8, get_nprocs() - 2));
int max_threads = min(4, get_nprocs());

LOGI("About to create params");

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ SPEC CHECKSUMS:
ReactCommon: b49a4b00ca6d181ff74b17c12b2d59ac4add0bde
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
whisper-rn: 76657e7d6abe0d1a1a6a0ab6726eb10918bd29f0
whisper-rn: e29e387a3a39d9573246e444d55a1c39fe657135
Yoga: 79dd7410de6f8ad73a77c868d3d368843f0c93e0
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

Expand Down
2 changes: 1 addition & 1 deletion ios/RNWhisper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ @implementation RNWhisper

const int max_threads = options[@"maxThreads"] != nil ?
[options[@"maxThreads"] intValue] :
MIN(8, (int)[[NSProcessInfo processInfo] processorCount]) - 2;
MIN(4, (int)[[NSProcessInfo processInfo] processorCount]);

if (options[@"beamSize"] != nil) {
params.strategy = WHISPER_SAMPLING_BEAM_SEARCH;
Expand Down

0 comments on commit 87d0b02

Please sign in to comment.