git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] Git.pm: Add faculties to allow temp files to be cached

From
EWEric Wong <normalperson@yhbt.net>
Date
Aug 14, 2008, 06:58 UTC
Message-ID
<20080814065800.GA16918@untitled>
In-Reply-To
<7vskt8mz0g.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
Show 33 quoted lines
> Lea Wiemann <lewiemann@gmail.com> writes:
> 
> > Marcus Griep wrote:
> >> diff --git a/perl/Git.pm b/perl/Git.pm
> >>
> >> +require File::Spec;
> >
> > This makes Git.pm dependent on Perl 5.6.1.
> 
> Ouch.  Thanks for being extra careful.
> 
> Unfortunately I've already pulled these changes via Eric.
> 
> Among the existing Perl scripts, cvsexportcommit and cvsimport already do
> use it, so do svnimport and cidaemon in contrib.
> 
> > ...  Hence to avoid
> > complaints about failing tests, I suggest that you add a check for
> > File::Spec availability at the beginning of any test that (indirectly)
> > uses Git.pm.
> 
> Hmm, wouldn't something like this (untested) be more contained?
> 
> ---
>  perl/Git.pm |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/perl/Git.pm b/perl/Git.pm
> index 405f68f..2a92945 100644
> --- a/perl/Git.pm
> +++ b/perl/Git.pm
> @@ -1023,7 +1035,7 @@ sub _temp_cache {
>  		}

What about just lazy requiring inside _temp_cache() so it won't get loaded by folks that don't need it? (completely untested):

		eval { require File::Temp };
		if ($@) {
			throw Error::Simple("couldn't require File::Temp: $@");
		}
		eval { require File::Spec };
		if ($@) {
			throw Error::Simple("couldn't require File::Spec: $@");
		}

It'll also remove the minor performance hit CGI/gitweb users got since we won't load these extra modules during startup.

Show 7 quoted lines
>  		$$temp_fd = File::Temp->new(
>  			TEMPLATE => 'Git_XXXXXX',
> -			DIR => File::Spec->tmpdir
> +			DIR => $tmpdir,
>  			) or throw Error::Simple("couldn't open new temp file");
>  		$$temp_fd->autoflush;
>  		binmode $$temp_fd;

Fwiw, git-svn has been a File::Temp user for a few months since Adam's cat-file optimization; but it also has lower visibility since boxes with <5.6.1 probably don't have SVN. git-svn previously used IO::File->new_tmpfile exclusively (and very heavily).

-- 
Eric Wong
Previous: Lea WiemannNext: Marcus Griep
Message 36 of 43 in “git-svn: Make it scream by minimizing temp files”
  1. git-svn: Make it scream by minimizing temp filesMarcus Griep, Aug 8, 2008
  2. Junio C HamanoAug 8, 2008
  3. Marcus GriepAug 9, 2008
  4. Eric WongAug 9, 2008
  5. Marcus GriepAug 9, 2008
  6. Eric WongAug 10, 2008
  7. Junio C HamanoAug 10, 2008
  8. Eric WongAug 10, 2008
  9. Junio C HamanoAug 10, 2008
  10. Eric WongAug 10, 2008
  11. 0/3 git-svn and temporary file improvementsMarcus Griep, Aug 11, 2008
  12. 1/3 Git.pm: Add faculties to allow temp files to be cachedMarcus Griep, Aug 11, 2008
  13. 2/3 git-svn: Make it scream by minimizing temp filesMarcus Griep, Aug 11, 2008
  14. 3/3 git-svn: Reduce temp file usage when dealing with non-linksMarcus Griep, Aug 11, 2008
  15. Eric WongAug 12, 2008
  16. Marcus GriepAug 12, 2008
  17. 3/3 git-svn: Reduce temp file usage when dealing with non-linksMarcus Griep, Aug 12, 2008
  18. 3/3 git-svn: Reduce temp file usage when dealing with non-linksMarcus Griep, Aug 12, 2008
  19. Eric WongAug 13, 2008
  20. Marcus GriepAug 13, 2008
  21. Eric WongAug 13, 2008
  22. Eric WongAug 12, 2008
  23. Marcus GriepAug 12, 2008
  24. 2/3 git-svn: Make it incrementally faster by minimizing temp filesMarcus Griep, Aug 12, 2008
  25. Eric WongAug 13, 2008
  26. Eric WongAug 12, 2008
  27. Marcus GriepAug 12, 2008
  28. 1/3 Git.pm: Add faculties to allow temp files to be cachedMarcus Griep, Aug 12, 2008
  29. Eric WongAug 13, 2008
  30. Lea WiemannAug 13, 2008
  31. Marcus GriepAug 13, 2008
  32. Marcus GriepAug 13, 2008
  33. Junio C HamanoAug 13, 2008
  34. Lea WiemannAug 13, 2008
  35. Git.pm: require Perl 5.6.1Lea Wiemann, Aug 13, 2008
  36. Eric WongAug 14, 2008
  37. Git.pm: Make File::Spec and File::Temp requirement lazyMarcus Griep, Aug 15, 2008
  38. Bryan DonlanAug 15, 2008
  39. Marcus GriepAug 15, 2008
  40. Git.pm: Make File::Spec and File::Temp requirement lazyMarcus Griep, Aug 15, 2008
  41. Miklos VajnaAug 13, 2008
  42. Junio C HamanoAug 14, 2008
  43. Marcus GriepAug 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.