Very slow file mapping?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kid joe

    #1

    Very slow file mapping?

    Hi

    I need to share about 10 MB of data between two processes. In the first
    process, I do something similar to:

    HANDLE hBuffer = CreateFileMappi ng(INVALID_HAND LE_VALUE, NULL,
    PAGE_READWRITE, 0, 10000000, "This is a test");
    // <- Check for errors
    void *buffer = MapViewOfFile(h Buffer,FILE_MAP _WRITE, 0, 0, 0);
    // <- Check for errors
    // <- Write something in the buffer

    In the second process:

    HANDLE hBuffer = OpenFileMapping (FILE_MAP_WRITE , false, "This is a
    test");
    // <- Check for errors
    void *buffer = MapViewOfFile(h Buffer, FILE_MAP_WRITE, 0, 0, 0);
    // <- Check for errors
    // <- Read all the buffer

    What I read is what was written, which is okay. The problem is that, in
    the second process, it is about 10 (ten) times slower to read the buffer
    that was allocated in the first process than to read another 10 MB
    buffer allocated in the second process itself. Is it normal? Is there a
    way to share memory more efficiently?

    Thanks

    Joe

    --
    .--------------------.
    | |
    | Good Morning.... | .--.--.
    | | .; .;|;. ;.
    `-------------. ,---' .;_;' `;_;.
    \| ; ;' `; ;
    \ ;;'.--.___.--.`;;
    ;-( o )=3D( o )-;
    ( `--' | `--' )
    \| . . |/
    ........... . .:::::. . .______
    / . '---` . '\
    .' `. .' \
    | ____,.- . | `.....' | _______ |
    | ,-' \ /|\'' \.-- |
    | / \.'\ /,'. \. - |
    | /| ` `\ / \ |
    | ,/ _ '/ '\ |
    ,-' ,-. |o '
    / '| | | | \
    / ,/| |o | \ `
    | .' | |.' |. \ \
    ________/ .'____|________ _______________ _||__`. `__________
    ( \ ) / )
    '-. '-. ( .-` .-`
    '-. .-'--.__. .-.__.--`-. .-`
    '-..' \--' : ~`:=3D,`- `..-`
    \ .. \\ |`-'|`-, /
    \\\\\\\) | |`-'/.'/
    \)\)\\ `-' `-'
    `



  • Nick Keighley

    #2
    Re: Very slow file mapping?

    On 5 Nov, 10:38, kid joe <spamt...@spamt rap.invalidwrot e:
    I need to share about 10 MB of data between two processes. In the first
    process, I do something similar to:
    <snip>

    standard C has no support for processes. Re-post in a platform
    specific group.

    --
    Nick Keighley

    Comment

    • jacob navia

      #3
      Re: Very slow file mapping?

      kid joe wrote:
      Hi
      >
      I need to share about 10 MB of data between two processes. In the first
      process, I do something similar to:
      >
      HANDLE hBuffer = CreateFileMappi ng(INVALID_HAND LE_VALUE, NULL,
      PAGE_READWRITE, 0, 10000000, "This is a test");
      // <- Check for errors
      void *buffer = MapViewOfFile(h Buffer,FILE_MAP _WRITE, 0, 0, 0);
      // <- Check for errors
      // <- Write something in the buffer
      >
      In the second process:
      >
      HANDLE hBuffer = OpenFileMapping (FILE_MAP_WRITE , false, "This is a
      test");
      // <- Check for errors
      void *buffer = MapViewOfFile(h Buffer, FILE_MAP_WRITE, 0, 0, 0);
      // <- Check for errors
      // <- Read all the buffer
      >
      What I read is what was written, which is okay. The problem is that, in
      the second process, it is about 10 (ten) times slower to read the buffer
      that was allocated in the first process than to read another 10 MB
      buffer allocated in the second process itself. Is it normal? Is there a
      way to share memory more efficiently?
      >
      Thanks
      >
      Joe
      >
      Hi Joe.
      1) You open the read part with FILE_MAP_WRITE. .. why? If you are just
      going to read it would be better to ask for read access only. If not,
      the synchronization problems could bog you down.

      2) You have to experiment with different setups... What about a pipe?
      Or other solutions? Just look the documentation in MSDN.



      --
      jacob navia
      jacob at jacob point remcomp point fr
      logiciels/informatique
      http://www.cs.virginia.edu/~lcc-win32

      Comment

      • CBFalconer

        #4
        [OT] Very slow file mapping?

        jacob navia wrote:
        kid joe wrote:
        >
        >I need to share about 10 MB of data between two processes. In
        >the first process, I do something similar to:
        >>
        >HANDLE hBuffer = CreateFileMappi ng(INVALID_HAND LE_VALUE, NULL,
        >PAGE_READWRITE , 0, 10000000, "This is a test");
        >
        .... snip ...
        >
        1) You open the read part with FILE_MAP_WRITE. .. why? If you are just
        going to read it would be better to ask for read access only. If not,
        the synchronization problems could bog you down.
        >
        2) You have to experiment with different setups... What about a pipe?
        Or other solutions? Just look the documentation in MSDN.
        This is all off-topic on c.l.c. Find a windows newsgroup.

        --
        [mail]: Chuck F (cbfalconer at maineline dot net)
        [page]: <http://cbfalconer.home .att.net>
        Try the download section.

        Comment

        Working...