Sender: Jorrit DOT Tyberghein AT uz DOT kuleuven DOT ac DOT be Message-Id: <31B29BA0.2F06@uz.kuleuven.ac.be> Date: Mon, 03 Jun 1996 10:00:32 +0200 From: Jorrit Tyberghein Organization: Universitaire Ziekenhuizen Leuven Mime-Version: 1.0 To: DJGPP AT delorie DOT com Subject: fseek slow in DJGPP 2.0? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, Recently I upgraded from DJGPP 2.0beta3 to the non-beta version of DJGPP. When I recompiled my program with the new DJGPP it worked perfectly except for one thing. Some parts of the program appeared to be unbearably slow. I traced the problem down to the 'fseek' function. There are several places in my program where I scan a file while I only need several scattered bytes from the file. For example: the 'x' represent bytes that I need to read, the dots represents bytes that I want to skip: File: xxxx.......xxx.........xxxxxxxx.......xx.......xxxxx............. These files are rather large (about 700K) and there are about 10000 skips to be made. The code to read this file is something like this: while (busy) { fread (&struct, size, 1, file); fseek (file, struct.offset, SEEK_CUR); } The beta3 version of DJGPP apparantly had no problem with this code. The 'fseek' function in that version of DJGPP seemed to be efficient. But it appears that the non-beta version of DJGPP clears the buffer everytime an fseek happens. If I rewrite the code to something like this (dummy is a buffer pointing to some allocated memory): while (busy) { fread (&struct, size, 1, file); fread (dummy, struct.offset, 1, file); } I almost achieve the same speed as the before. But this is not elegant and only works if the file is read sequentially. This is not always the case. Sometimes I need to access the file randomly. This is now much slower with the new DJGPP 2.0. What's happening here? Why is fseek rewritten in such a way? Can I get the old behaviour back? My system: Pentium with 16M DOS 7.0 (Window 95) LFN=n (in DJGPP.ENV) DJGPP 2.0 (latest version, only downloaded one week ago) GCC 2.7.2 included with DJGPP. Greetings and many thanks in advance, -- ============================================================================== Jorrit DOT Tyberghein AT uz DOT kuleuven DOT ac DOT be, University Hospitals KU Leuven BELGIUM People who used magic without knowing what they were doing usually came to a sticky end. All over the entire room, sometimes. -- (Terry Pratchett, Moving Pictures) ==============================================================================