public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14613] New: missed optimization in strcspn
@ 2012-09-24 20:20 eblake at redhat dot com
  2012-12-19 21:08 ` [Bug libc/14613] " neleai at seznam dot cz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: eblake at redhat dot com @ 2012-09-24 20:20 UTC (permalink / raw)
  To: glibc-bugs


http://sourceware.org/bugzilla/show_bug.cgi?id=14613

             Bug #: 14613
           Summary: missed optimization in strcspn
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: eblake@redhat.com
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


I ran into an instance of someone using strcspn(var,"=") to find the offset of
a single rejection byte, and arguing that glibc should know better:
https://www.redhat.com/archives/libvir-list/2012-September/msg01630.html

The current glibc code is rather inefficient in this case; the naive C fallback
does a strchr(reject,s[i]) for each byte of s, and even the assembly versions
in the various .S files tend to start by computing a table of 256 bits (8
bytes) to learn which characters are in reject, before even starting to make a
pass through s.

But when the second argument of strcspn is exactly one byte long, it seems like
it should be much more efficient to do the equivalent of a single pass:
 strchrnul(s,*reject)-s
Since there is real code out there that uses strcspn() on single-byte
rejections in order to avoid a subtraction outside of the library code, it
seems like glibc should be catering to this optimization.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/14613] missed optimization in strcspn
  2012-09-24 20:20 [Bug libc/14613] New: missed optimization in strcspn eblake at redhat dot com
@ 2012-12-19 21:08 ` neleai at seznam dot cz
  2014-06-17  4:20 ` fweimer at redhat dot com
  2015-08-27 22:13 ` [Bug string/14613] " jsm28 at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: neleai at seznam dot cz @ 2012-12-19 21:08 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14613

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |neleai at seznam dot cz
         AssignedTo|unassigned at sourceware    |neleai at seznam dot cz
                   |dot org                     |

--- Comment #1 from Ondrej Bilka <neleai at seznam dot cz> 2012-12-19 21:08:42 UTC ---
I will address this in my optimized strcspn patch that is in my TODO list. 

Upto three character needles I am faster than sse4.2 version.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/14613] missed optimization in strcspn
  2012-09-24 20:20 [Bug libc/14613] New: missed optimization in strcspn eblake at redhat dot com
  2012-12-19 21:08 ` [Bug libc/14613] " neleai at seznam dot cz
@ 2014-06-17  4:20 ` fweimer at redhat dot com
  2015-08-27 22:13 ` [Bug string/14613] " jsm28 at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-17  4:20 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14613

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug string/14613] missed optimization in strcspn
  2012-09-24 20:20 [Bug libc/14613] New: missed optimization in strcspn eblake at redhat dot com
  2012-12-19 21:08 ` [Bug libc/14613] " neleai at seznam dot cz
  2014-06-17  4:20 ` fweimer at redhat dot com
@ 2015-08-27 22:13 ` jsm28 at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-08-27 22:13 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14613

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |string

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-27 22:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-24 20:20 [Bug libc/14613] New: missed optimization in strcspn eblake at redhat dot com
2012-12-19 21:08 ` [Bug libc/14613] " neleai at seznam dot cz
2014-06-17  4:20 ` fweimer at redhat dot com
2015-08-27 22:13 ` [Bug string/14613] " jsm28 at gcc dot gnu.org

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).