Skip to contentSkip to conversation

Fix thinktime handling and minimal rate calculation

PATCH In review HongweiQin 2 participants 5 messages Jan 17, 2021

lore
Share & tools
lore

HongweiQin

author
#0 lore raw

v2 cover Fix thinktime handling and minimal rate calculation

This patch series fix the thinktime handling procedure and take the thinktime into consideration when checking the minimal rate.

HongweiQin (2):
Fix thinktime_blocks
Fix handle_thinktime

 backend.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v2 1/2 Fix thinktime_blocks

According to the manual, the thinktime_blocks controls how many blocks to issue (instead of complete) before waiting.

---
 backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
backend.c +1 -1
index e20a2e0..c85669c 100644
@@ -864,7 +864,7 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir)
 	uint64_t total;
 	int left;
 
-	b = ddir_rw_sum(td->io_blocks);
+	b = ddir_rw_sum(td->io_issues);
 	if (b % td->o.thinktime_blocks)
 		return;
 
Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH v2 2/2 Fix handle_thinktime

In reply to HongweiQin

This patch handles thinktime before checking td->bytes_done. This avoids skipping the thinktime handling when the thread just starts.

Besides, the handle_thinktime also updates the comp_time so that the rate calculation of check_min_rate() is based on the time after the thinktime.

---
 backend.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
backend.c +9 -4
index c85669c..b3e13cb 100644
@@ -858,7 +858,8 @@ static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
 	return 0;
 }
 
-static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir)
+static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir,
+			     struct timespec *time)
 {
 	unsigned long long b;
 	uint64_t total;
@@ -898,6 +899,9 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir)
 		/* adjust for rate_process=poisson */
 		td->last_usec[ddir] += total;
 	}
+
+	if (time && should_check_rate(td))
+		fio_gettime(time, NULL);
 }
 
 /*
@@ -1076,6 +1080,10 @@ reap:
 		}
 		if (ret < 0)
 			break;
+
+		if (ddir_rw(ddir) && td->o.thinktime)
+			handle_thinktime(td, ddir, &comp_time);
+
 		if (!ddir_rw_sum(td->bytes_done) &&
 		    !td_ioengine_flagged(td, FIO_NOIO))
 			continue;
@@ -1090,9 +1098,6 @@ reap:
 		}
 		if (!in_ramp_time(td) && td->o.latency_target)
 			lat_target_check(td);
-
-		if (ddir_rw(ddir) && td->o.thinktime)
-			handle_thinktime(td, ddir);
 	}
 
 	check_update_rusage(td);
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH v2 1/2] Fix thinktime_blocks

In reply to HongweiQin

Hi Sitsofe,

Quoted 4 lines

At this point wouldn't it be better to update the help to reflect the code rather than the other way around?

Consider this configuration:
[global]
thread
kb_base=1000
direct=1
size=28GiB
group_reporting
io_size=64KiB
ioengine=libaio
iodepth=32
bs=4096
filename=/dev/qblkdev

[fio_randwrite]
rw=randwrite
thinktime_blocks=4
thinktime=1s

I write this job file to simulate a data server that periodically writes back a certain amount of data (In this case,16KiB per second). Note that we cannot use the rate_iops here because it will send 1 request per 250ms.
If we keep the code as it is, the job will finish immediately after the test starts.
And this is usually not what the user wants.

Or, should we introduce a new parameter to distinguish between "think after finish" and "think after issue"?

Regards,
Hongwei

Quoted 24 lines · HongweiQin

According to the manual, the thinktime_blocks controls how many blocks to issue (instead of complete) before waiting.

---
 backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
backend.c +1 -2
index e20a2e0..c85669c 100644
@@ -864,7 +864,7 @@ static void handle_thinktime(struct thread_data *td, enum fio_ddir ddir)
        uint64_t total;
        int left;
 
-       b = ddir_rw_sum(td->io_blocks);
+       b = ddir_rw_sum(td->io_issues);
        if (b % td->o.thinktime_blocks)
                return;
 
--

1.8.3.1

#3 lore raw

Re: [PATCH v2 1/2] Fix thinktime_blocks

Hi Hongwei,

Quoted 34 lines · Hongwei Qin

Hi Sitsofe,

Quoted 4 lines

At this point wouldn't it be better to update the help to reflect the code rather than the other way around?

Consider this configuration:
[global]
thread
kb_base=1000
direct=1
size=28GiB
group_reporting
io_size=64KiB
ioengine=libaio
iodepth=32
bs=4096
filename=/dev/qblkdev

[fio_randwrite]
rw=randwrite
thinktime_blocks=4
thinktime=1s

I write this job file to simulate a data server that periodically writes back a certain amount of data (In this case,16KiB per second). Note that we cannot use the rate_iops here because it will send 1 request per 250ms.
If we keep the code as it is, the job will finish immediately after the test starts.
And this is usually not what the user wants.

Quoted 2 lines

Or, should we introduce a new parameter to distinguish between "think after finish" and "think after issue"?

I like the idea of a new parameter! Maybe it would act as a toggle because it doesn't make sense to set both together...

Signature · 1 line
Sitsofe