pensieve
pensieve copied to clipboard
question about sleep_time in sim/fixed_env.py
Hi, Hongzi
I can't understand the calculation method of the sleep_time
in the sim/fixed_env.py
.
When the buffer size is larger than the BUFFER_THRESH
,we need to sleep until the buffer size is less than the BUFFER_THRESH
.And then we need to skip some "durations" in the trace file.I understand this process.
But I don't understand the code with red box in the pic above.Using this code, the
sleep_time
in the return value isn't the original sleep_time
(code in green box), but the original sleep_time
minus several "duration" time.
Howerver, I think the sleep_time
in the return value should be the original sleep_time
in the green box,because actually we sleep that long,isn't it?
I'm not sure about this question,can you help me?Look forward to your reply.Thank you.
Thanks for your question. I think your understanding of our intent for sleep_time
is correct. However, notice that the red box part of the code is in a while loop. What we did was simulate the sleep until the time has passed (in the trace file). Basically, we jump forward the pointer in the trace file (mahimahi_ptr
) until the sleep time is up. In this process, the sleep_time
may be up in the middle of of a trace row. Thus you see a break and the last_mahimahi_time
to remember the fraction time.
Overall, this goal of part of the function isn't to "return a sleep_time", rather to simulate the sleep process when buffer exceeds the threshold.
Hope these help!