Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 280257 - Enhancement: mount tmpfs on /var/tmp/portage
Summary: Enhancement: mount tmpfs on /var/tmp/portage
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: Catalyst (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-04 05:08 UTC by Tom Stellard
Modified: 2012-11-11 06:08 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to add an option for mounting a tmpfs (tmpfs.diff,3.19 KB, patch)
2009-08-04 05:09 UTC, Tom Stellard
Details | Diff
Patch to add an option for mounting a tmpfs (tmpfs.diff,3.74 KB, patch)
2009-08-07 06:26 UTC, Tom Stellard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Stellard 2009-08-04 05:08:17 UTC
I would like to have the ability to mount a tmpfs on /var/tmp/portage when I am building a stage.  I have attached a patch that adds this functionality to catalyst.  This patch adds a new option "tmpfs" and the config value "tmpfs_opts".  tmpfs_opts can be used to set the size of the tmpfs.  It uses the same syntax as options passed to mount -o.                      
For example tempfs_opts="size=1G,nr_inodes=10".

Reproducible: Always
Comment 1 Tom Stellard 2009-08-04 05:09:15 UTC
Created attachment 200106 [details, diff]
Patch to add an option for mounting a tmpfs
Comment 2 Tom Stellard 2009-08-07 06:26:45 UTC
Created attachment 200473 [details, diff]
Patch to add an option for mounting a tmpfs

This patch fixes a bug where a directory called tmpfs was being created in the current working directory when catalyst was run.
Comment 3 Andrew Gaffney (RETIRED) gentoo-dev 2009-08-23 16:13:27 UTC
This is rather...specific. While this would give some speed improvements, there is also a lot of time lost on disk I/O when unpacking stage tarballs or rsyncing from the source_subpath's build dir. I'd much prefer to have automatic tmpfs support like this use a tmpfs for the entire build directory. 

However, it has problems of its own. After the build completes, you'd lose the build directory, and the next step in the process would have to unpack the tarball. In the case of livecd-stage1->livecd-stage2, there is no tarball to unpack.

I think this particular feature would be one much better put in portage than catalyst.
Comment 4 Matt Turner gentoo-dev 2011-06-25 15:59:15 UTC
What do you think about adding a feature to portage to handle this, Zac?
Comment 5 SpanKY gentoo-dev 2011-06-25 17:22:43 UTC
only trouble i see is people would probably whine when it fills up because they tried to build OOo on a system with 2GiB of memory, and they'll want portage to autodetect that situation
Comment 6 Zac Medico gentoo-dev 2011-06-25 20:34:15 UTC
I recall reports that tmpfs tends to have poor behavior in low-memory situations, when the tmpfs blocks tend to displace processes from memory and leads to a ridiculous amount of swapping. I haven't tested this case, but if it's still an issue then it seems like tmpfs should be fixed be given a mount option that gives higher priority to processes for allocation of physical memory pages.
Comment 7 Matt Turner gentoo-dev 2011-06-29 18:04:36 UTC
Thinking about this a bit, what about

adding a PORTAGE_TMPFS_SIZE variable that allows the user to specify the maximum size of the tmpfs mount. It would default to "0", disabling portage from creating a tmpfs mount.

Some packages (eg openoffice, libreoffice, icc) already have CHECKREQS_ for hard disk space and memory size in pkg_setup(). I think this information could be leveraged.

Questions: Should the tmpfs mount be one large mount for /var/tmp/portage, or would making individual mounts per-package help anything? What to do in the case of package failure (prompt the user and ask before unmounting/deleting the temporary contents?)?
Comment 8 Zac Medico gentoo-dev 2011-06-29 22:43:54 UTC
(In reply to comment #7)
> Questions: Should the tmpfs mount be one large mount for /var/tmp/portage, or
> would making individual mounts per-package help anything?

I think one large mount is desirable, for the sake of simplicity. In fact, given that the user can easily configure this via /etc/fstab, I'd prefer for portage not to get involved (for the sake of simplicity).

> What to do in the
> case of package failure (prompt the user and ask before unmounting/deleting the
> temporary contents?)?

If we leave it to the user to configure via /etc/fstab, the it's no concern of portage. Users who use tmpfs for /var/tmp/portage can set FEATURES=fail-clean to have temp directories cleaned up on failure. If they'd like to do something more complex then then can use register_die_hook to make a tarball out of $PORTAGE_BUILDDIR before FEATURES=fail-clean does its thing. Something like this in /etc/portage/bashrc will do the trick:

backup_after_die() {
  cd "$PORTAGE_BUILDDIR" || return
  addwrite /var/tmp/build_failures
  mkdir /var/tmp/build_failures/$CATEGORY
  tar -czf /var/tmp/failures/$CATEGORY/$PF.tar.gz .
}

register_die_hook backup_after_die
Comment 9 Matt Turner gentoo-dev 2011-06-30 00:07:21 UTC
(In reply to comment #8)
>

Right, the bug report was originally filed against catalyst and then shoveled off to portage.

Mounting the var/tmp/portage of various catalyst builds can't really be done, especially when most of catalyst is run automatically.

Do you think perhaps that the original idea of implementing this in catalyst should be done instead of portage? It does seem to me that the code would be better off in portage itself.
Comment 10 Zac Medico gentoo-dev 2011-06-30 00:43:28 UTC
(In reply to comment #9)
> Do you think perhaps that the original idea of implementing this in catalyst
> should be done instead of portage?

Yes, I think so. Catalyst already does lots of mounting and unmounting, so it can be easily added to catalyst along with all the other mounts. OTOH, portage currently doesn't do any mounting or unmounting.
Comment 11 Rick Farina (Zero_Chaos) gentoo-dev 2012-11-11 06:08:58 UTC
I apologize, I didn't even notice this, but I independantly wrote this due to a bug in ZFS requiring me to do so. It's in 2.0.12.1, let me know if my way isn't good enough for some reason.