225 return;
226 }
227
228 size_t max = ShenandoahPacingMaxDelay;
229 double start = os::elapsedTime();
230
231 size_t total = 0;
232 size_t cur = 0;
233
234 while (true) {
235 // We could instead assist GC, but this would suffice for now.
236 // This code should also participate in safepointing.
237 // Perform the exponential backoff, limited by max.
238
239 cur = cur * 2;
240 if (total + cur > max) {
241 cur = (max > total) ? (max - total) : 0;
242 }
243 cur = MAX2<size_t>(1, cur);
244
245 os::sleep(JavaThread::current(), cur);
246
247 double end = os::elapsedTime();
248 total = (size_t)((end - start) * 1000);
249
250 if (total > max) {
251 // Spent local time budget to wait for enough GC progress.
252 // Breaking out and allocating anyway, which may mean we outpace GC,
253 // and start Degenerated GC cycle.
254 _delays.add(total);
255
256 // Forcefully claim the budget: it may go negative at this point, and
257 // GC should replenish for this and subsequent allocations
258 claim_for_alloc(words, true);
259 break;
260 }
261
262 if (claim_for_alloc(words, false)) {
263 // Acquired enough permit, nice. Can allocate now.
264 _delays.add(total);
265 break;
|
225 return;
226 }
227
228 size_t max = ShenandoahPacingMaxDelay;
229 double start = os::elapsedTime();
230
231 size_t total = 0;
232 size_t cur = 0;
233
234 while (true) {
235 // We could instead assist GC, but this would suffice for now.
236 // This code should also participate in safepointing.
237 // Perform the exponential backoff, limited by max.
238
239 cur = cur * 2;
240 if (total + cur > max) {
241 cur = (max > total) ? (max - total) : 0;
242 }
243 cur = MAX2<size_t>(1, cur);
244
245 JavaThread::current()->sleep(cur);
246
247 double end = os::elapsedTime();
248 total = (size_t)((end - start) * 1000);
249
250 if (total > max) {
251 // Spent local time budget to wait for enough GC progress.
252 // Breaking out and allocating anyway, which may mean we outpace GC,
253 // and start Degenerated GC cycle.
254 _delays.add(total);
255
256 // Forcefully claim the budget: it may go negative at this point, and
257 // GC should replenish for this and subsequent allocations
258 claim_for_alloc(words, true);
259 break;
260 }
261
262 if (claim_for_alloc(words, false)) {
263 // Acquired enough permit, nice. Can allocate now.
264 _delays.add(total);
265 break;
|