Showing the changes to git-features/src (1 of 2 files). Show all
Unified · Split
| @@ -134,16 +134,14 @@ pub fn optimize_chunk_size_and_thread_limit( · 133 unmodified lines | ||
| 134 | 134 | let desired_chunks_per_thread_at_least = 2; |
| 135 | 135 | let (chunk_size, thread_limit) = num_chunks |
| 136 | 136 | .map(|num_chunks| { |
| 137 | − let thread_limit = if num_chunks <= available_threads * desired_chunks_per_thread_at_least { | |
| 137 | + let items = num_chunks * desired_chunk_size; | |
| 138 | + let chunk_size = (items / (available_threads * desired_chunks_per_thread_at_least)).max(1); | |
| 139 | + let num_chunks = items / chunk_size; | |
| 140 | + let thread_limit = if num_chunks <= available_threads { | |
| 138 | 141 | (num_chunks / desired_chunks_per_thread_at_least).max(1) |
| 139 | 142 | } else { |
| 140 | 143 | available_threads |
| 141 | 144 | }; |
| 142 | − let chunk_size = if num_chunks / thread_limit > desired_chunks_per_thread_at_least { | |
| 143 | − (desired_chunk_size * (num_chunks / thread_limit / desired_chunks_per_thread_at_least)).max(1) | |
| 144 | − } else { | |
| 145 | − desired_chunk_size | |
| 146 | − }; | |
| 147 | 145 | (chunk_size, thread_limit) |
| 148 | 146 | }) |
| 149 | 147 | .unwrap_or((desired_chunk_size, available_threads)); |