Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Aug 2010 18:31:59 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Daniel Braniss <danny@cs.huji.ac.il>
Cc:        "Julian H. Stacey" <jhs@berklix.com>, Gabor Kovesdan <gabor@freebsd.org>, "Sean C. Farley" <scf@freebsd.org>, current@freebsd.org
Subject:   Re: Official request: Please make GNU grep the default
Message-ID:  <20100814153159.GC2396@deviant.kiev.zoral.com.ua>
In-Reply-To: <E1OkIaR-00086E-Em@kabab.cs.huji.ac.il>
References:  <201008141040.o7EAeiuR093012@fire.js.berklix.net> <alpine.BSF.2.00.1008140802510.35204@thor.farley.org> <E1OkIaR-00086E-Em@kabab.cs.huji.ac.il>

next in thread | previous in thread | raw e-mail | index | archive | help

--FhvelBhrd33NvMcY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Aug 14, 2010 at 06:23:55PM +0300, Daniel Braniss wrote:
> > On Sat, 14 Aug 2010, Julian H. Stacey wrote:
> >=20
> > >> why would you want to lock a file for reading anyways?
> > >
> > > Does current bsdgrep read lock by default ?
> > > If so, it would be better off by default, enabled by an option.
> > > 8.0-RELEASE man grep (gnu) does not mention locking.
> >=20
> > bsdgrep in -current does lock via the call to fgetc().  That is why I=
=20
> > suggested using flockfile/getchar_unlocked+/funlockfile instead.  Other=
=20
> > unlocked functions would also be useful, i.e., feof_unlocked().=20
> > Avoiding fgetc() does not completely solve the speed issue, yet it=20
> > certainly helps.
> >=20
> > Just for reference:  older bsdgrep used fgetln().
>=20
> let me rephrase the question:
> 	why would you want to lock a file for reading anyways??
>=20
> there is no real benefit that I can see in locking a file for searching
> a pattern. On a single file the overhead is irrelevant, but for 'grep -r?'
Locked is not a file, but FILE. It is a measure to establish consistency
in the stdio structures in the multithreaded environment, and not a
file-system level lock of any kind. See the description of the flockfile()
in the SUSv4.

On the other hand, the overhead of locking in !mt process for FILE in
our libc should be unmeasurable.

--FhvelBhrd33NvMcY
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkxmtu4ACgkQC3+MBN1Mb4gUbgCg9ZRS9vh2EqymvaaILDfKJsfn
AcIAn12itL2EA3aostuXud5aKFr8EGGq
=fkkg
-----END PGP SIGNATURE-----

--FhvelBhrd33NvMcY--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100814153159.GC2396>