On 17.4.2011 20:18, Nico Golde wrote:
> Hi,
> * MP <t...@centrum.cz> [2011-04-17 19:47]:
>> tcpxtract calls sync() after extracting each packet of data to one of the 
>> output files.
>> This has as a result of huge harddisk activity even when both source and 
>> destination lies in ramdisk (tmpfs)
>>
>> Once sync() calls get removed using attached patch, time to extract files 
>> from a 10 mb stream decreases from
>> several minutes (during which harddisk emits loud noise) to about a second.
> 
> Wow you are right. I also don't see why this call is made there. Instead of 
> removing it completely, what do you think about:

sync() will flush all buffers in whole system (which resulted in all the
harddisk rattling even when everything was done in ramdisk when I found out
about this), so I don't think is is good idea to call it anywhere.

What might be useful is calling "fsync(eptr->fd)" just before the close
(which will flush just the file in question) but not sync().

When the sync() is moved there, it is still called about 500 times to sync
all the system cache even when not necessary when doing it on my dump in
which I encountered the problem originally (though still better than
syncing after every written packet).

Martin Petricek

> --- a/extract.c
> +++ b/extract.c
> @@ -163,7 +163,6 @@ static void extract_segment(extract_list_t *elist, const 
> uint8_t *data)
>          error("Quiting.");
>      }
>      elist->nwritten += nbytes;
> -    sync();
>  }
>  
>  /* remove all finished extracts from the list */
> @@ -182,6 +181,8 @@ static void sweep_extract_list(extract_list_t **elist)
>                  eptr->next->prev = eptr->prev;
>              if (*elist == eptr)
>                  *elist = eptr->next;
> +
> +            sync();
>              close(eptr->fd);
>              free(eptr);
>          }
> 
> Cheers
> Nico



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to