grep-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to profile the grep engine despite the "/dev/null optimization"


From: alexandre . ferrieux
Subject: Re: How to profile the grep engine despite the "/dev/null optimization" ?
Date: Mon, 29 May 2023 23:27:09 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:91.0) Gecko/20100101 Thunderbird/91.10.0



On 5/29/23 23:18, Zev Weiss wrote:
On Sat, May 27, 2023 at 02:20:02PM PDT, alexandre.ferrieux@orange.com wrote:
>
[...] nowadays, grep *detects* /dev/null and behaves differently in that case:
it sets the done_on_match flag, and accordingly exits very quickly, on the first matching line of your hundreds-of-gigabytes test file....

Note that while it's far less commonly used in this way, /dev/zero provides the same property of discarding all written data -- and from a quick inspection of src/grep.c, grep does not appear to detect it for optimization purposes, so I suspect it would suit your purposes well.

Wow, thanks a lot Zev ! I was completely unaware of the input semantics of /dev/zero :)

Indeed it solves the problem for me. However, I'm still perplexed by the (7-yr-old) decision to let grep "behave as grep -q" without warning (nor documentation).
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations 
confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce 
message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou 
falsifie. Merci.

This message and its attachments may contain confidential or privileged 
information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete 
this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been 
modified, changed or falsified.
Thank you.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]