0

I am completely confused with what I had just read on these two pages:

http://www.scsifaq.org/scsifaq.html#_Hlk410546176 http://www.cse.scu.edu/~tschwarz/coen180/LN/scsi.html

Both claim that SCSI asynchronous IO is slower than synchronous one. How come? Why would anyone bother to write async procedure only to loose performance?

It contradicts my expectation!

Especially that, in case of SSD, I am using libaio to read asynchronously to get much better performance.

Furthermore, the first list synchronous as send send send wait wait wait... That is exactly what asynchronous is in case of libaio.

Anyone can shed a light on it for me, please?!

Edit 1

Let me clarify my problem. I may have a problem with correct understanding of a difference between asynchronous and synchronous IO.

  • Synchronous: It waits for each operation to complete
  • Asynchronous: It never waits for each operation to complete

Now, I would assume that if I had to read sequentially a few gigs of data, reading it in a simple synchronous loop:

while ( num_blocks-- > 0 )
    read_block() ;

Would have a "request, pause, request" type of queries. Practically I see that if I change it to multithreaded procedure, span several (6-8) threads that would take 'next location to read' and then requested it, I could get almost maximum read performance.

Something like this:

struct request
{
    ...

    boost::mutex mutex ;
    uint64_t     block ;

    uint64_t get_block_location()
    {
        boost::mutex::scoped_lock lock( mutex ) ;
        return block++ ;
    }
} ;

void readth( request* r )
{
    try
    {
        for( ;; )
        {
            read_block( r->get_block_location()) ;
        }
    }
    catch( const FinishedException& )
    {}
}

I thought, and now, I think I start getting it after rethinking what I had just read with a help from @Robert Harvey that async/sync is really only a matter of 'saving time' on waiting for the result...

I am leaving this question just in case someone has cognitive problems like mine!

2

Asynchronous I/O is not about improving the speed of disk performance. You can't do that by making I/O asynchronous; the disk platters spin at the same speed regardless of the manner in which you make I/O calls.

The purpose of Asynchronous I/O is to make it possible to go and do other things while you're waiting on the data. While that can appear to be a performance improvement, what you're really doing is freeing up a processor from having to idle while the data arrives.

6
  • What about spin up and spin down in case of physical disk? I have noticed that if I 'flood' scsi with bunch of sequential requests in separate threads, I get much better performance (possibly due to controller sorting them out.) When I use block after block, even when sequential, it is slower because each time I have to wait for the response, and then initiate another read. I was expecting that in case of asynchronous read it is the scsi driver that will do all of that. – Grzegorz Apr 7 '14 at 16:41
  • Did you read the post you linked? It says "the asynchronous transfer option waits for each byte to be transferred before it is acknowledged. With synchronous protocol, the device sending the data is allowed to get ahead of the device receiving the data by a number of bytes (called the offset). The offset is negotiated between the initiator and the target some time prior to the transfer beginning. The synchronous protocol is considerably more efficient and therefore faster than asynchronous." – Robert Harvey Apr 7 '14 at 16:45
  • yes :D ... and that is why I got confused, and posted this question. – Grzegorz Apr 7 '14 at 16:48
  • I think you'd better be more specific about the problem you're trying to solve, because in the absence of that, this is merely a curiosity question. That description is very specific, and in so many words it says that the synchronous protocol is more efficient because it was designed in a way that makes it more efficient. Can you explain how a better understanding of "more efficient" helps you solve the problem you're having? – Robert Harvey Apr 7 '14 at 16:51
  • I am in the process of editing my question. I believe that I have a conflict of expectation and reality, and I need clarification in order to make it correct. Thanks for you time! – Grzegorz Apr 7 '14 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.