aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-12 00:03:49 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-12 00:03:49 +0000
commit1224b6d62b7214a4afca27695ff7d789fb6f93d3 (patch)
tree66fb08633714e7e0eab91df29ca12e7a7d95f8b9 /src/fs/fs_api.c
parent9a112a7aa7c1703a9489da7306293ee1b9df7331 (diff)
downloadgnunet-1224b6d62b7214a4afca27695ff7d789fb6f93d3.tar.gz
gnunet-1224b6d62b7214a4afca27695ff7d789fb6f93d3.zip
start fewer FS probes concurrently, run them all in the same task to avoid undue pressure on the scheduler
Diffstat (limited to 'src/fs/fs_api.c')
-rw-r--r--src/fs/fs_api.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c
index 29fc0cdd7..302020d7d 100644
--- a/src/fs/fs_api.c
+++ b/src/fs/fs_api.c
@@ -65,9 +65,13 @@ start_job (struct GNUNET_FS_QueueEntry *qe)
65 "Starting job %p (%u active)\n", 65 "Starting job %p (%u active)\n",
66 qe, 66 qe,
67 qe->h->active_downloads); 67 qe->h->active_downloads);
68 GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, qe->h->pending_tail, qe); 68 GNUNET_CONTAINER_DLL_remove (qe->h->pending_head,
69 GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, qe->h->running_tail, 69 qe->h->pending_tail,
70 qe->h->running_tail, qe); 70 qe);
71 GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head,
72 qe->h->running_tail,
73 qe->h->running_tail,
74 qe);
71} 75}
72 76
73 77
@@ -207,19 +211,25 @@ process_job_queue (void *cls,
207 num_downloads_expired, 211 num_downloads_expired,
208 num_downloads_waiting); 212 num_downloads_waiting);
209 /* calculate start/stop decisions */ 213 /* calculate start/stop decisions */
210 if (h->active_downloads + num_downloads_waiting > h->max_parallel_requests) 214 if (h->active_downloads + num_downloads_waiting > h->max_parallel_downloads)
211 { 215 {
212 /* stop probes if possible */ 216 /* stop as many probes as there are downloads and probes */
213 num_probes_change = - num_probes_active; 217 num_probes_change = - GNUNET_MIN (num_probes_active,
214 num_downloads_change = h->max_parallel_requests - h->active_downloads; 218 num_downloads_waiting);
219 /* start as many downloads as there are free slots, including those
220 we just opened up */
221 num_downloads_change = h->max_parallel_downloads - h->active_downloads - num_probes_change;
215 } 222 }
216 else 223 else
217 { 224 {
218 /* start all downloads */ 225 /* start all downloads (we can) */
219 num_downloads_change = num_downloads_waiting; 226 num_downloads_change = num_downloads_waiting;
220 /* start as many probes as we can */ 227 /* also start probes if there is room, but use a lower cap of (mpd/4) + 1 */
221 num_probes_change = GNUNET_MIN (num_probes_waiting, 228 if (h->max_parallel_downloads / 2 >= (h->active_downloads + num_downloads_change))
222 h->max_parallel_requests - (h->active_downloads + num_downloads_waiting)); 229 num_probes_change = GNUNET_MIN (num_probes_waiting,
230 (1 + h->max_parallel_downloads / 4) - (h->active_downloads + num_downloads_change));
231 else
232 num_probes_change = 0;
223 } 233 }
224 234
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,