Bug 216794 - growisofs buffer size ridiculously small, disregard bufsize option
growisofs buffer size ridiculously small, disregard bufsize option
Product: Fedora
Classification: Fedora
Component: dvd+rw-tools (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Harald Hoyer
Depends On:
  Show dependency treegraph
Reported: 2006-11-21 19:43 EST by Juliano F. Ravasi
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-01-15 07:29:00 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to fix this problem (763 bytes, patch)
2006-11-21 20:58 EST, Juliano F. Ravasi
no flags Details | Diff

  None (edit)
Description Juliano F. Ravasi 2006-11-21 19:43:05 EST
Description of problem:
When burning DVDs, growisofs is not honoring the --use-the-force-luke=bufsize:X
option, allocating an internal ring buffer ridiculously small, so that DVD
burning is affected by frequent buffer underruns (the speed drops from 8x to as
low as 2x).

I verified via /proc/<growisofs_pid>/smaps that the allocation that seems to be
the ring buffer is not of constant size. It varies for each burn, from 1MB to
4MB, even though k3b informs --use-the-force-luke=bufsize:128M (I have 1GB of
RAM in this machine, so 128M is nothing).

This problem started after the recent update from dvd+rw-tools-6.1-4.1 to
dvd+rw-tools-7.0-0.fc6.2. Downgrading to dvd+rw-tools-6.1-4.1 (from FC6
installation media) fixes the problem.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. growisofs -Z /dev/hdb=file.iso -dvd-compat -speed=8
2. check memory mappings at /proc/`pidof growisofs`/smaps (here, the ring buffer
is the forth last mapping)

Actual results:
The ring buffer is 1 to 4 MBs in size. High risk of buffer underruns.

Expected results:
The ring buffer should have the size given by the front-end via the
--use-the-force-luke=bufsize:X option.
Comment 1 Juliano F. Ravasi 2006-11-21 20:11:18 EST
I went to investigate the bug by looking into the source. It seems to be a bug
introduced on dvd+rw-tools version 7.0. The changelog for growisofs.c states:

 * 7.0:
 * - limit ring buffer size to 1/4 of RAM;

But it doesn't match for me, since I have 1GB of RAM and sometimes growisofs
allocates only 1MB of buffer size. So I went down to where this is limited and
found this (growisofs.c:3100):

    size_t phys_mem = (size_t)sysconf(_SC_AVPHYS_PAGES) *
    if (phys_mem)
    {   phys_mem /= 2;  /* normally AVPHYS is a bit smaller, so
                         *  we commonly land on 1/4 RAM */
        while (the_buffer_size > phys_mem) the_buffer_size /= 2;

This is pretty clear the problem. _SC_AVPHYS_PAGES returns the number of
available, really free memory pages, not the total number of memory pages. Linux
tends to use all available memory with buffers and cache, and keep just a bare
minimum of free pages during normal use.

So, this code cuts the size of the buffer in half again and again until it is
less or equal to half the size of free memory.

Right now free informs me that I have 7MB of really free memory, but 594MB of
"available" memory (discounting space used by buffers and cache), out of a total
of 940MB (1GB physical). So, if I started burning a DVD right now, it would give
me 2MB of buffer, that is the biggest power of 2 smaller than 3.5MB, that is
half of 7MB.
Comment 2 Juliano F. Ravasi 2006-11-21 20:58:07 EST
Created attachment 141860 [details]
Patch to fix this problem

This fixes the problem for me.

I'll ask dvd+rw-tools' maintainer (Andy Polyakov) to take a look here.
Comment 3 Juliano F. Ravasi 2006-11-30 20:18:18 EST
Andy Polyakov doesn't answer my e-mails.

Could this bug be fixed by Fedora? The patch is in the attachment 141860 [details].
Comment 4 Harald Hoyer 2006-12-13 09:16:52 EST
dvd+rw-tools-7.0-0.fc6.3 should appear soon in the testing repo
Comment 6 Juliano F. Ravasi 2006-12-14 14:49:13 EST
Harald: tested dvd+rw-tools-7.0-0.fc6.4 from updates-testing and it worked! Thanks!

I don't have RHEL5, so I can't test the last one.

Note You need to log in before you can comment on or make changes to this bug.