Lines Matching refs:fc

22 gcs_fc_init (gcs_fc_t* fc,  in gcs_fc_init()  argument
27 assert (fc); in gcs_fc_init()
47 memset (fc, 0, sizeof(*fc)); in gcs_fc_init()
49 fc->hard_limit = hard_limit; in gcs_fc_init()
50 fc->soft_limit = fc->hard_limit * soft_limit; in gcs_fc_init()
51 fc->max_throttle = max_throttle; in gcs_fc_init()
58 gcs_fc_reset (gcs_fc_t* const fc, ssize_t const queue_size) in gcs_fc_reset() argument
60 assert (fc != NULL); in gcs_fc_reset()
63 fc->init_size = queue_size; in gcs_fc_reset()
64 fc->size = fc->init_size; in gcs_fc_reset()
65 fc->start = gu_time_monotonic(); in gcs_fc_reset()
66 fc->last_sleep = 0; in gcs_fc_reset()
67 fc->act_count = 0; in gcs_fc_reset()
68 fc->max_rate = -1.0; in gcs_fc_reset()
69 fc->scale = 0.0; in gcs_fc_reset()
70 fc->offset = 0.0; in gcs_fc_reset()
71 fc->sleep_count= 0; in gcs_fc_reset()
72 fc->sleeps = 0.0; in gcs_fc_reset()
109 gcs_fc_process (gcs_fc_t* fc, ssize_t act_size) in gcs_fc_process() argument
111 fc->size += act_size; in gcs_fc_process()
112 fc->act_count++; in gcs_fc_process()
114 if (fc->size <= fc->soft_limit) { in gcs_fc_process()
116 if (gu_unlikely(fc->debug > 0 && !(fc->act_count % fc->debug))) { in gcs_fc_process()
118 fc->size, ((double)fc->size)/fc->soft_limit*100.0); in gcs_fc_process()
122 else if (fc->size >= fc->hard_limit) { in gcs_fc_process()
123 if (0.0 == fc->max_throttle) { in gcs_fc_process()
135 double interval = ((end - fc->start) * 1.0e-9); in gcs_fc_process()
137 if (gu_unlikely (0 == fc->last_sleep)) { in gcs_fc_process()
140 fc->max_rate = (double)(fc->size - fc->init_size) / interval; in gcs_fc_process()
142 double s = (1.0 - fc->max_throttle)/(fc->soft_limit-fc->hard_limit); in gcs_fc_process()
145 fc->scale = s * fc->max_rate; in gcs_fc_process()
146 fc->offset = (1.0 - s*fc->soft_limit) * fc->max_rate; in gcs_fc_process()
149 interval = interval * (double)(fc->size - fc->soft_limit) / in gcs_fc_process()
150 (fc->size - fc->init_size); in gcs_fc_process()
154 fc->last_sleep = fc->soft_limit; in gcs_fc_process()
155 fc->start = end - interval * 1000000000; in gcs_fc_process()
160 fc->max_rate, fc->scale, fc->offset); in gcs_fc_process()
164 double desired_rate = fc->size * fc->scale + fc->offset; // linear decay in gcs_fc_process()
166 assert (desired_rate <= fc->max_rate); in gcs_fc_process()
168 double sleep = (double)(fc->size - fc->last_sleep) / desired_rate in gcs_fc_process()
171 if (gu_unlikely(fc->debug > 0 && !(fc->act_count % fc->debug))) { in gcs_fc_process()
176 fc->size, fc->act_count, in gcs_fc_process()
177 ((double)(fc->size - fc->last_sleep))/interval, in gcs_fc_process()
178 desired_rate, interval, sleep, fc->sleep_count, in gcs_fc_process()
179 fc->sleeps); in gcs_fc_process()
180 fc->sleep_count = 0; in gcs_fc_process()
181 fc->sleeps = 0.0; in gcs_fc_process()
190 fc->scale, fc->offset, fc->size); in gcs_fc_process()
195 fc->last_sleep = fc->size; in gcs_fc_process()
196 fc->start = end; in gcs_fc_process()
197 fc->sleep_count++; in gcs_fc_process()
198 fc->sleeps += sleep; in gcs_fc_process()
206 void gcs_fc_debug (gcs_fc_t* fc, long debug_level) { fc->debug = debug_level; } in gcs_fc_debug() argument