Async I/O always better than sync I/O?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan Liu

    Async I/O always better than sync I/O?

    Hi,

    Is Async I/O (e.g. NetworkStream.B egin/End Read/Write) always better than
    synchronous I/O? At least as good?

    When I don't concern about easy or difficult to write code, should I always
    use Async I/O?



    Thanks!


  • kodehoved

    #2
    Re: Async I/O always better than sync I/O?

    On May 20, 1:27 pm, "Ryan Liu" <r...@powercati .comwrote:
    Hi,
    >
    Is Async I/O (e.g. NetworkStream.B egin/End Read/Write) always better than
    synchronous I/O? At least as good?
    >
    When I don't concern about easy or difficult to write code, should I always
    use Async I/O?
    >
    Thanks!
    Well, that really depends on what you want to achieve. If you have a
    CPU bound task you don't want to delay while doing I/O, async is the
    way to go. On the other hand if you application is mainly doing I/O
    you will most likely not see a big gain by using async I/O. Also,
    synchronous I/O is a lot simpler than async I/O so even tough you say
    you don't care, you'll be facing more problems if you go with async I/
    O if you don't really need it but of course it's your choice.

    Regards,
    Brian

    Comment

    • Barry Kelly

      #3
      Re: Async I/O always better than sync I/O?

      Ryan Liu wrote:
      Is Async I/O (e.g. NetworkStream.B egin/End Read/Write) always better than
      synchronous I/O? At least as good?
      If your code is I/O bound (so you don't have spare work to do) and
      doesn't need to scale (so you'd have more parallel I/O-bound code
      running), then you don't need the complexity of async.

      Otherwise, assuming you write it correctly, you can scale to more
      parallel I/O operations and you can fit in more compute work while I/O
      is pending, if you use async.
      When I don't concern about easy or difficult to write code, should I always
      use Async I/O?
      Don't underestimate the cost (in maintenance, debugging, design,
      implementation, documentation, explanation to other coders) of async
      code.

      -- Barry

      --

      Comment

      • Peter Duniho

        #4
        Re: Async I/O always better than sync I/O?

        On Tue, 20 May 2008 04:27:37 -0700, Ryan Liu <rliu@powercati .comwrote:
        Is Async I/O (e.g. NetworkStream.B egin/End Read/Write) always better
        than
        synchronous I/O? At least as good?
        "Better" is far too vague to really able to answer. Except perhaps that
        inasmuch as "better" can carry many meanings, then obviously one
        particular i/o paradigm cannot possibly always be "better". :)
        When I don't concern about easy or difficult to write code, should I
        always
        use Async I/O?
        Personally, I like the async i/o API and don't find it more difficult. If
        anything, I find it less difficult. But I have a fair amount of
        experience with asynchronous i/o programming and the async i/o API works
        well for me. Even so, I don't use it when I'm dealing with brief i/o or
        i/o on a small scale that I know won't be interrupted, even if that i/o
        will take longer.

        Sometimes simplicity is "better" than efficiency.

        Pete

        Comment

        Working...