English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 27 November 2020, 21:01   #1
temisu
Registered User
 
Join Date: Mar 2017
Location: Tallinn / Estonia
Posts: 74
Seek() and Read() performance and tuning

Hi,

There are certain things I've "known" for certain for example that Seek() on FFS is slow if you need to seek to the end of the large file. However, I don't really know if my assumptions are correct and before I start to do some testing on my own maybe someone knows answers to these questions for certain and can help me.

In short, if I have an application that use dos.library Seek() and Read() a lot, what are the constraints I have to keep in mind. (working 2.0+ OS)

Specifically I'm wondering about following cases.
  1. Seeking at large offsets. If the current file offset for reading in rather large. and I want to skip forward. Does it make a difference if I use OFFSET_BEGINNING or OFFSET_CURRENT for the Seek()? I sincerely hope that OFFSET_BEGINNING does not start counting blocks from the start of the file. Is the situation different if I want to Seek() backwards
  2. Reading data by chunks. Dos Library reads are non-cached. My assumption is that it is best to read the data by block size chunks. Should they also aligned to block offsets?
  3. Seeks versus reads. If Seek() is bad and I want to Seek() forward a bit. Does it make better to actually Read() the data instead?

Anyway, this might be me overthinking. If you have some insight please share.

Thanks.
temisu is offline  
Old 28 November 2020, 09:09   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,215
Quote:
Originally Posted by temisu View Post
There are certain things I've "known" for certain for example that Seek() on FFS is slow if you need to seek to the end of the large file.
That depends on the number of buffers and on the size of the file. What the FFS has to do is to find the file link blocks and follow their links to the end of the file.


Quote:
Originally Posted by temisu View Post

In short, if I have an application that use dos.library Seek() and Read() a lot, what are the constraints I have to keep in mind. (working 2.0+ OS)
Also depends on how much you read and how you seek. Seek() and Read() directly go down to the file system. If these are a lot of tiny reads and seeks, it is better to add another layer of buffering between them such that some of the operations go to the buffer instead to the file system.


In principle, FRead() of the dos.library could do that, but it is not a very smart implementation, thus is a lot slower (this will change with 3.2), and there is no obvious Seek() counterpart.


Quote:
Originally Posted by temisu View Post

Seeking at large offsets. If the current file offset for reading in rather large. and I want to skip forward. Does it make a difference if I use OFFSET_BEGINNING or OFFSET_CURRENT for the Seek()?
No, that is all the same.


Quote:
Originally Posted by temisu View Post


Reading data by chunks. Dos Library reads are non-cached. My assumption is that it is best to read the data by block size chunks. Should they also aligned to block offsets?
It would certainly help as then the FFS can read data directly to your buffers instead of going though another buffer, and copying data over to you. That is, the read positions could be aligned to the block positions.





Quote:
Originally Posted by temisu View Post

Seeks versus reads. If Seek() is bad and I want to Seek() forward a bit. Does it make better to actually Read() the data instead?
No, that is all the same. Quite the reverse, a read by an entire block will pull this block from the device, a seek will just skip it.
Thomas Richter is online now  
Old 28 November 2020, 13:18   #3
temisu
Registered User
 
Join Date: Mar 2017
Location: Tallinn / Estonia
Posts: 74
Thanks, that makes sense
temisu is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tuning AmiTCP / Easynet Pro McTrinsic support.Apps 3 07 May 2018 22:00
Puzzle, ROM & Resident modules, performance tuning. Michael Coders. System 10 14 September 2017 20:49
Amiga Hardware-Tuning (BookDisk) drwhy request.Other 8 18 January 2017 18:16
Fine-tuning custom FPS, please? aidenn request.UAE Wishlist 12 17 April 2010 20:35
Tuning A500 Dave_wb support.Hardware 2 08 December 2006 14:56

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:36.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08779 seconds with 15 queries