Skip to contentSkip to conversation

Question about drive mirror

Qemu-devel [email protected] 3 participants 4 messages Jan 13, 2014 – Jan 14, 2014

lore
Share & tools
lore
#0 lore raw

Hi,everyone.
I tested the capability of drive mirror, I found the IO is low. Then I read the code, The code mirror_run() will call mirror_iteration() to read the size of buffer data from source storage, when the read callback ,and then in mirror_read_complete () write the data to the target storage, It is serial.
Now, I hope when it is writing the data to target storage ,we can send the request of reading data from source storage. Because of using coroutine to do it ,there is some troubles to achieve it. why not use Multi-thread?
Some one can give me some idea?
Thanks.

zhang min

#1 lore raw
Quoted 9 lines · On Mon, 01/13 23:44, [email protected] wrote:

Hi,everyone.
I tested the capability of drive mirror, I found the IO is low. Then I read the code, The code mirror_run() will call mirror_iteration() to read the size of buffer data from source storage, when the read callback ,and then in mirror_read_complete () write the data to the target storage, It is serial.
Now, I hope when it is writing the data to target storage ,we can send the request of reading data from source storage. Because of using coroutine to do it ,there is some troubles to achieve it. why not use Multi-thread?
Some one can give me some idea?

Hi,

QEMU block layer has been using coroutine as the program model even before introducing these block jobs, so it was nature that block mirror followed this style. With coroutines, I believe it is as possible as with multi-thread, to have more outstanding IO requests, in order to speed up the mirroring. What's the trouble you have?

Multi-threading needs much more synchronization mechanism than what we have in block interface now. One day it may be possible to move block job to a thread, but it will require quite some work.

Fam

#2 lore raw
Quoted 5 lines · Fam Zheng
Quoted 4 lines · On Mon, 01/13 23:44, [email protected] wrote:

I tested the capability of drive mirror, I found the IO is low. Then I read the code, The code mirror_run() will call mirror_iteration() to read the size of buffer data from source storage, when the read callback ,and then in mirror_read_complete () write the data to the target storage, It is serial.

And it also uses throttling to avoid impacting the guest too much. It's considered a background job, i.e. not trying to saturate storage bandwidth.

That said, improving performance while keeping I/O isolated from higher priority guest I/O can be good.

Quoted 4 lines
Quoted 4 lines

Now, I hope when it is writing the data to target storage ,we can send the request of reading data from source storage. Because of using coroutine to do it ,there is some troubles to achieve it. why not use Multi-thread?
Some one can give me some idea?

It can be parallelized by splitting the code into two separate loops:

A reader coroutine that reads data from the source device and places buffers in a queue.

A writer coroutine that takes buffers from the queue and writes data to the target device.

(In fact there could be multiple readers and writers.)

Stefan

#3 lore raw

Thank you for your detailed reply.
Now, I am modifying the code to change the reading and writing processes, My purpose is that after it send the writing requestion and the writing requestion is not come back, then it send the reading requestion.
I think this way will be more reading and writing pressure than before.

I don't know why in mirror_iteration, each iteration send the number of data is continuous dirty data, the maximum is the size of free_buffer(default is 10M), I think the way will reduce the performance of IO,because the mirror will wait long time to send next reading requestion. I think each iteration send the number of data should base on the granularity ,we can set the granularity is 1M. This way may be let the reading and writing is parallel.

zhang min

From: Stefan Hajnoczi
Date: 2014-01-14 13:57
To: Fam Zheng
CC: [email protected]; rudy.zhangmin; qemu-devel
Subject: Re: [Qemu-devel] Question about drive mirror

Quoted 5 lines · Fam Zheng
Quoted 4 lines · On Mon, 01/13 23:44, [email protected] wrote:

I tested the capability of drive mirror, I found the IO is low. Then I read the code, The code mirror_run() will call mirror_iteration() to read the size of buffer data from source storage, when the read callback ,and then in mirror_read_complete () write the data to the target storage, It is serial.

And it also uses throttling to avoid impacting the guest too much. It's considered a background job, i.e. not trying to saturate storage bandwidth.

That said, improving performance while keeping I/O isolated from higher priority guest I/O can be good.

Quoted 4 lines
Quoted 4 lines

Now, I hope when it is writing the data to target storage ,we can send the request of reading data from source storage. Because of using coroutine to do it ,there is some troubles to achieve it. why not use Multi-thread?
Some one can give me some idea?

It can be parallelized by splitting the code into two separate loops:

A reader coroutine that reads data from the source device and places buffers in a queue.

A writer coroutine that takes buffers from the queue and writes data to the target device.

(In fact there could be multiple readers and writers.)

Stefan