Subject: Re: Using Cygwin on NT 4.0 and Win2000; a user experience
From: "Max Bowsher" <[email-masked]>
To: <[email-masked]>
Cc: <[email-masked]>
Date: Mon, 19 May 2003 00:32:33 +0100

Martin Buchholz wrote:
> Max> Actual test data relating to this would be very interesting to see.
>
> Some was included in my other post.  I would have done a more
> conclusive test, but I now have a working machine that is doing
> productive work, and I hesitate to go through another two cycles of
> painful cygwin1.dll installs.  But I would be willing to do this if
> that's what it would take to convince you folks to undo the sparse
> file patch.
>
> If you have a Windows 2000 machine (no service packs) and a recent
> cygwin, try this experiment:
>
> $ ls -l /etc/passwd
> -rw-rw-rw-    1 Martin B Users         628 May 13 04:10 /etc/passwd
> $ perl -e 'system("df ."); for (1 ... 1024) { system("cp /etc/passwd
> foobar$_"); } system("df .")' Filesystem           1k-blocks      Used
> Available Use% Mounted on
> d:                    11767580   4290332   7477248  37% /d
> Filesystem           1k-blocks      Used Available Use% Mounted on
> d:                    11767580   4290332   7477248  37% /d
>
> That's 4kb per small (but not tiny) file with my patch applied.
> How much space does yours take?  It would be interesting to see
> results on Windows XP as well.
>
> (again:) For best reproducibility, I suggest
> - windows 2000, no service packs
> - do the experiment on an ntfs partition formatted by windows 2000.
>
> I have not done this exact experiment on an unpatched Cygwin, but I
> predict it would take either 32kb or 64kb per file (also dependent on
> the filesystem cluster size, but that should default to 4kb).

max@pomello [~] $ CYGWIN=sparse perl -e 'system("df ."); for (1 ... 1024)
{ sys
tem("cp /etc/passwd foobar$_"); } system("df .")'; rm foobar*
Filesystem           1k-blocks      Used Available Use% Mounted on
M:\cygwin             18892436  13175484   5716952  70% /
Filesystem           1k-blocks      Used Available Use% Mounted on
M:\cygwin             18892436  13177408   5715028  70% /
max@pomello [~] $ CYGWIN=nosparse perl -e 'system("df ."); for (1 ... 1024)
{ s
ystem("cp /etc/passwd foobar$_"); } system("df .")'; rm foobar*
Filesystem           1k-blocks      Used Available Use% Mounted on
M:\cygwin             18892436  13175552   5716884  70% /
Filesystem           1k-blocks      Used Available Use% Mounted on
M:\cygwin             18892436  13175552   5716884  70% /

Well, here is my run of that, on WinXPSP1. All I can say is... wow!

As you can see, I don't change DLL between these tests. I attach my patch
which allows environment-variable control over sparse file creation.

Max.
Index: src/winsup/cygwin/environ.cc
===================================================================
RCS file: /home/max/cvsmirror/src-cvs/src/winsup/cygwin/environ.cc,v
retrieving revision 1.91
diff -u -p -r1.91 environ.cc
--- src/winsup/cygwin/environ.cc	13 Feb 2003 15:15:32 -0000	1.91
+++ src/winsup/cygwin/environ.cc	18 May 2003 22:34:03 -0000
@@ -37,6 +37,7 @@ extern BOOL strip_title_path;
 extern int pcheck_case;
 extern int subauth_id;
 BOOL reset_com = FALSE;
+BOOL sparse_files = FALSE;
 static BOOL envcache = TRUE;
 
 static char **lastenviron;
@@ -516,6 +517,7 @@ static struct parse_thing
   {"ntea", {&allow_ntea}, justset, NULL, {{FALSE}, {TRUE}}},
   {"ntsec", {&allow_ntsec}, justset, NULL, {{FALSE}, {TRUE}}},
   {"smbntsec", {&allow_smbntsec}, justset, NULL, {{FALSE}, {TRUE}}},
+  {"sparse", {&sparse_files}, justset, NULL, {{FALSE}, {TRUE}}},
   {"reset_com", {&reset_com}, justset, NULL, {{FALSE}, {TRUE}}},
   {"strip_title", {&strip_title_path}, justset, NULL, {{FALSE}, {TRUE}}},
   {"subauth_id", {func: &subauth_id_init}, isfunc, NULL, {{0}, {0}}},
Index: src/winsup/cygwin/fhandler_disk_file.cc
===================================================================
RCS file: /home/max/cvsmirror/src-cvs/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.50
diff -u -p -r1.50 fhandler_disk_file.cc
--- src/winsup/cygwin/fhandler_disk_file.cc	11 May 2003 21:52:09 -0000	1.50
+++ src/winsup/cygwin/fhandler_disk_file.cc	18 May 2003 22:34:57 -0000
@@ -31,6 +31,8 @@ details. */
 #define _COMPILING_NEWLIB
 #include <dirent.h>
 
+extern BOOL sparse_files;
+
 static int __stdcall
 num_entries (const char *win32_name)
 {
@@ -409,7 +411,7 @@ fhandler_disk_file::open (path_conv *rea
     set_file_attribute (has_acls (), get_win32_name (), mode);
 
   /* Set newly created and truncated files as sparse files. */
-  if ((real_path->fs_flags () & FILE_SUPPORTS_SPARSE_FILES)
+  if (sparse_files && (real_path->fs_flags () & FILE_SUPPORTS_SPARSE_FILES)
       && (get_access () & GENERIC_WRITE) == GENERIC_WRITE
       && (get_flags () & (O_CREAT | O_TRUNC)))
     {

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/