From: Eric Wong <normalperson@yhbt.net>
To: rack-devel@googlegroups.com
Subject: Re: Not cleaning up tempfiles for multipart?
Date: Sun, 7 Mar 2010 16:18:34 -0800 [thread overview]
Message-ID: <20100308001834.GA18365@dcvr.yhbt.net> (raw)
In-Reply-To: <f04d2211003070627i79e7368fl98e7cd947eda156@mail.gmail.com>
Charles Oliver Nutter <headius@headius.com> wrote:
> On Sat, Mar 6, 2010 at 1:55 AM, Eric Wong <normalperson@yhbt.net> wrote:
> > Charles Oliver Nutter <headius@headius.com> wrote:
> >> If I'm correct, this is a bug. Tempfiles should not be relied upon to
> >> clean themselves up in response to GC, since you don't know when GC
> >> will fire...
> >
> > Why not? Tempfiles are objects, too. It's perfectly reasonable
> > to let GC clean them up like any other object.
> >
> >
> > I don't know why RewindableInput is monkeying with Tempfile internals,
> > though.
>
> It's roundly considered by every programming language community in the
> world to be *really* bad form to let GC clean up IO. There's tons of
> reasons for this:
You're forgetting there are programming language communities that
consider GC to be bad form in the first place :)
Given that Ruby does have a GC, I'd prefer to be as lazy as possible and
let the runtime deal with it.
> * GC may not run as soon as you like, causing you to hold IO resources
> too long (and under heavy load, potentially use up all descriptors for
> a process)
MRI considers EMFILE/ENFILE to be analogous to ENOMEM, and would trigger
GC in that case.
> * On some systems, old objects get promoted to heaps that are only
> rarely collected, resulting in them potentially never GCing (or only
> GCing extremely rarely)
Those GCs could be made smarter about dealing with IO objects.
> * There's no reason you *shouldn't* be able to close resources when
> they're no longer used. In this case, close any files opened for a
> give request once the request has been processed (async libraries
> using those files should expect them to be closed and deal with that
> accordingly).
Of course being able to close IO objects explicitly is good. In some
cases of socket/pipe IPC, it's the _only_ way to signal end-of-input.
HTTP/1.0 and HTTP/0.9 don't work otherwise.
> Bug-finding tools for several languages flag this sort of behavior as
> a high-priority bug. Languages like Go, C#, and Java have or are
> adding features to help guarantee you never do this. It's pretty much
> universally frowned upon.
As I understand it, C# and Java have to deal with operating/file
systems that don't work with unlinked files. I guess JRuby is limited
to only being able to use things that work on those platforms, and can't
work with unlinked temporary files reliably, my condolences.
I haven't had a chance to look Go...
> When I tweeted about Rubyists leaving IO objects to be cleaned up or
> closed by GC, *everyone* agreed that it's a bug in the code, and that
> nobody should ever rely on GC to release File/IO resources.
>
> What more can I say? :)
*everyone* meaning your followers on Twitter? I suspect your followers
on Twitter are more inclined to agree with you :)
--
Eric Wong
next prev parent reply other threads:[~2010-03-08 0:18 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-05 14:40 Not cleaning up tempfiles for multipart? Charles Oliver Nutter
2010-03-05 14:47 ` Charles Oliver Nutter
2010-03-05 14:48 ` Charles Oliver Nutter
2010-03-06 10:20 ` Hongli Lai
2010-03-07 14:25 ` Charles Oliver Nutter
2010-03-06 7:55 ` Eric Wong
2010-03-06 10:25 ` Hongli Lai
2010-03-07 14:34 ` Charles Oliver Nutter
2010-03-08 0:22 ` Eric Wong
2010-03-08 1:12 ` Eric Wong
2010-03-17 15:41 ` Charles Oliver Nutter
2010-03-18 9:54 ` Eric Wong
2014-01-06 22:45 ` Wojtek Kruszewski
2014-02-11 21:05 ` Eric Wong
2014-03-27 21:40 ` Lenny Marks
2010-03-07 23:53 ` Eric Wong
2010-03-08 11:26 ` Hongli Lai
2010-03-08 11:30 ` Hongli Lai
2010-03-08 14:33 ` Randy Fischer
2010-03-08 14:43 ` Charles Oliver Nutter
2010-03-08 14:49 ` James Tucker
2010-03-17 2:37 ` Eric Wong
2010-03-08 13:22 ` Charles Oliver Nutter
2010-03-08 14:42 ` James Tucker
2010-03-08 17:24 ` Hongli Lai
2010-03-09 7:43 ` Charles Oliver Nutter
2010-03-08 10:05 ` James Tucker
2010-03-07 14:27 ` Charles Oliver Nutter
2010-03-08 0:18 ` Eric Wong [this message]
2010-03-08 10:07 ` James Tucker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100308001834.GA18365@dcvr.yhbt.net \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).