diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-21 10:23:24 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-21 10:23:24 +0000 |
commit | ab8a8a6b9177b4af9aa923315a5dbf540091d3fa (patch) | |
tree | 75eb59c7049cb8508813d632eb8af64ec689d6d0 /src/fs | |
parent | e2931e9e5cffd9f3dc37b71b2a01ed151c0dd4e5 (diff) | |
download | gnunet-ab8a8a6b9177b4af9aa923315a5dbf540091d3fa.tar.gz gnunet-ab8a8a6b9177b4af9aa923315a5dbf540091d3fa.zip |
-towards better download prioritization
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_api.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 28c887ddd..8a5b1df76 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -106,10 +106,79 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
106 | struct GNUNET_TIME_Relative restart_at; | 106 | struct GNUNET_TIME_Relative restart_at; |
107 | struct GNUNET_TIME_Relative rst; | 107 | struct GNUNET_TIME_Relative rst; |
108 | struct GNUNET_TIME_Absolute end_time; | 108 | struct GNUNET_TIME_Absolute end_time; |
109 | unsigned int num_download_waiting; | ||
110 | unsigned int num_download_active; | ||
111 | unsigned int num_download_expired; | ||
112 | unsigned int num_probes_active; | ||
113 | unsigned int num_probes_waiting; | ||
114 | unsigned int num_probes_expired; | ||
115 | int num_probes_change; | ||
116 | int num_download_change; | ||
109 | 117 | ||
110 | h->queue_job = GNUNET_SCHEDULER_NO_TASK; | 118 | h->queue_job = GNUNET_SCHEDULER_NO_TASK; |
111 | restart_at = GNUNET_TIME_UNIT_FOREVER_REL; | 119 | restart_at = GNUNET_TIME_UNIT_FOREVER_REL; |
112 | /* first, see if we can start all the jobs */ | 120 | /* first, see if we can start all the jobs */ |
121 | num_probes_waiting = 0; | ||
122 | num_download_waiting = 0; | ||
123 | for (qe = h->pending_head; NULL != qe; qe = qe->next) | ||
124 | { | ||
125 | switch (qe->priority) | ||
126 | { | ||
127 | case GNUNET_FS_QUEUE_PRIORITY_PROBE: | ||
128 | num_probes_waiting++; | ||
129 | break; | ||
130 | case GNUNET_FS_QUEUE_PRIORITY_NORMAL: | ||
131 | num_download_waiting++; | ||
132 | break; | ||
133 | default: | ||
134 | GNUNET_break (0); | ||
135 | break; | ||
136 | } | ||
137 | } | ||
138 | num_probes_active = 0; | ||
139 | num_probes_expired = 0; | ||
140 | num_download_active = 0; | ||
141 | num_download_expired = 0; | ||
142 | for (qe = h->running_head; NULL != qe; qe = qe->next) | ||
143 | { | ||
144 | run_time = | ||
145 | GNUNET_TIME_relative_multiply (h->avg_block_latency, | ||
146 | qe->blocks * qe->start_times); | ||
147 | switch (qe->priority) | ||
148 | { | ||
149 | case GNUNET_FS_QUEUE_PRIORITY_PROBE: | ||
150 | num_probes_active++; | ||
151 | /* run probes for at most 1s * number-of-restarts; note that | ||
152 | as the total runtime of a probe is limited to 2m, we don't | ||
153 | need to additionally limit the total time of a probe to | ||
154 | strictly limit its lifetime. */ | ||
155 | run_time = GNUNET_TIME_relative_min (run_time, | ||
156 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
157 | 1 + qe->start_times)); | ||
158 | end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); | ||
159 | rst = GNUNET_TIME_absolute_get_remaining (end_time); | ||
160 | restart_at = GNUNET_TIME_relative_min (rst, restart_at); | ||
161 | if (0 == rst.rel_value) | ||
162 | num_probes_expired++; | ||
163 | break; | ||
164 | case GNUNET_FS_QUEUE_PRIORITY_NORMAL: | ||
165 | num_download_active++; | ||
166 | end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); | ||
167 | rst = GNUNET_TIME_absolute_get_remaining (end_time); | ||
168 | restart_at = GNUNET_TIME_relative_min (rst, restart_at); | ||
169 | if (0 == rst.rel_value) | ||
170 | num_download_expired++; | ||
171 | break; | ||
172 | default: | ||
173 | GNUNET_break (0); | ||
174 | break; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | // FIXME: calculate how many probes/downloads to start/stop | ||
179 | num_probes_change = 42; | ||
180 | num_download_change = 42; | ||
181 | |||
113 | next = h->pending_head; | 182 | next = h->pending_head; |
114 | while (NULL != (qe = next)) | 183 | while (NULL != (qe = next)) |
115 | { | 184 | { |
@@ -151,6 +220,7 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
151 | break; | 220 | break; |
152 | default: | 221 | default: |
153 | GNUNET_break (0); | 222 | GNUNET_break (0); |
223 | break; | ||
154 | } | 224 | } |
155 | end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); | 225 | end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); |
156 | rst = GNUNET_TIME_absolute_get_remaining (end_time); | 226 | rst = GNUNET_TIME_absolute_get_remaining (end_time); |