diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-12 00:03:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-12 00:03:49 +0000 |
commit | 1224b6d62b7214a4afca27695ff7d789fb6f93d3 (patch) | |
tree | 66fb08633714e7e0eab91df29ca12e7a7d95f8b9 /src/fs/fs_api.c | |
parent | 9a112a7aa7c1703a9489da7306293ee1b9df7331 (diff) |
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.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 29fc0cdd7e..302020d7d3 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c @@ -65,9 +65,13 @@ start_job (struct GNUNET_FS_QueueEntry *qe) "Starting job %p (%u active)\n", qe, qe->h->active_downloads); - GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, qe->h->pending_tail, qe); - GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, qe->h->running_tail, - qe->h->running_tail, qe); + GNUNET_CONTAINER_DLL_remove (qe->h->pending_head, + qe->h->pending_tail, + qe); + GNUNET_CONTAINER_DLL_insert_after (qe->h->running_head, + qe->h->running_tail, + qe->h->running_tail, + qe); } @@ -207,19 +211,25 @@ process_job_queue (void *cls, num_downloads_expired, num_downloads_waiting); /* calculate start/stop decisions */ - if (h->active_downloads + num_downloads_waiting > h->max_parallel_requests) + if (h->active_downloads + num_downloads_waiting > h->max_parallel_downloads) { - /* stop probes if possible */ - num_probes_change = - num_probes_active; - num_downloads_change = h->max_parallel_requests - h->active_downloads; + /* stop as many probes as there are downloads and probes */ + num_probes_change = - GNUNET_MIN (num_probes_active, + num_downloads_waiting); + /* start as many downloads as there are free slots, including those + we just opened up */ + num_downloads_change = h->max_parallel_downloads - h->active_downloads - num_probes_change; } else { - /* start all downloads */ + /* start all downloads (we can) */ num_downloads_change = num_downloads_waiting; - /* start as many probes as we can */ - num_probes_change = GNUNET_MIN (num_probes_waiting, - h->max_parallel_requests - (h->active_downloads + num_downloads_waiting)); + /* also start probes if there is room, but use a lower cap of (mpd/4) + 1 */ + if (h->max_parallel_downloads / 2 >= (h->active_downloads + num_downloads_change)) + num_probes_change = GNUNET_MIN (num_probes_waiting, + (1 + h->max_parallel_downloads / 4) - (h->active_downloads + num_downloads_change)); + else + num_probes_change = 0; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |