Re: [go-nuts] Getting disk block size

1,003 views
Skip to first unread message

Vasiliy Tolstov

unread,
Jul 23, 2012, 4:14:41 AM7/23/12
to cch...@gmail.com, golan...@googlegroups.com
2012/7/23 <cch...@gmail.com>:
> To stream a large audio file efficiently I would like to read in disk block
> sized chunks from the file. Is there a way to know what chunk size I should
> use?

Hmm. Maybe use dumpe2fs and get needed size....

--
Vasiliy Tolstov,
Clodo.ru
e-mail: v.to...@selfip.ru
jabber: va...@selfip.ru

Philip

unread,
Jul 23, 2012, 4:54:55 AM7/23/12
to golan...@googlegroups.com, cch...@gmail.com
This should do the job: http://golang.org/pkg/syscall/#Stat

Philip


Am Montag, 23. Juli 2012 10:07:58 UTC+2 schrieb cch...@gmail.com:
To stream a large audio file efficiently I would like to read in disk block sized chunks from the file. Is there a way to know what chunk size I should use?

Am Montag, 23. Juli 2012 10:07:58 UTC+2 schrieb cch...@gmail.com:
To stream a large audio file efficiently I would like to read in disk block sized chunks from the file. Is there a way to know what chunk size I should use?

peterGo

unread,
Jul 23, 2012, 9:01:00 AM7/23/12
to golang-nuts
cche...,

For Windows, try multiples (n = 1, 2, ...) of the disk cluster size: n
* SectorsPerCluster * BytesPerSector.

GetDiskFreeSpace function
http://msdn.microsoft.com/en-us/library/aa364935.aspx

The cluster is the allocation unit. The sector is the smallest
addressable unit. The sector size on old disks is usually 512, on some
newer disks it is 4096. The NTFS formatted disk cluster size usually
defaults to 4096.

As always, benchmark your performance hypothesis. In the past, my C
and Go benchmarks reading CD and DVD sized chunks of data have favored
4096 as the buffer size.

Peter

On Jul 23, 6:43 am, cche...@gmail.com wrote:
> Does thaht work under Windows?

peterGo

unread,
Jul 23, 2012, 9:05:22 AM7/23/12
to golang-nuts
cche...,

Linux on 4KB-sector disks: Practical advice
http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/

Peter

On Jul 23, 9:01 am, peterGo <go.peter...@gmail.com> wrote:
> cche...,
>
> For Windows, try multiples (n = 1, 2, ...) of the disk cluster size: n
> * SectorsPerCluster * BytesPerSector.
>
> GetDiskFreeSpace functionhttp://msdn.microsoft.com/en-us/library/aa364935.aspx

Albert Strasheim

unread,
Jul 24, 2012, 2:20:37 AM7/24/12
to golan...@googlegroups.com, cch...@gmail.com
On Monday, July 23, 2012 10:07:58 AM UTC+2, cch...@gmail.com wrote:
To stream a large audio file efficiently I would like to read in disk block sized chunks from the file. Is there a way to know what chunk size I should use?

In the world of page caches, disk caches, readahead, etc. any chunk size in the tens to hundreds of kilobytes should suffice. Or a few megabyte in extreme cases.

That is, unless you take special measures to bypass all this caching. On Linux you have O_DIRECT or fadvise(DONTNEED), but you also mention Windows below. Not quite sure how it works there.

Cheers

Albert
Reply all
Reply to author
Forward
0 new messages