Announcement

Collapse
No announcement yet.

Intel Further Speeds Up strnlen() In The GNU C Library For Recent Intel/AMD CPUs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Intel Further Speeds Up strnlen() In The GNU C Library For Recent Intel/AMD CPUs

    Phoronix: Intel Further Speeds Up strnlen() In The GNU C Library For Recent Intel/AMD CPUs

    Intel software engineers are responsible for many of the great x86_64-related optimizations to the GNU C Library "glibc" over the years. While they've extensively tuned many Glibc functions for achieving peak performance on their modern CPUs, it's a never-ending quest. Merged this week was another optimization to strnlen(), the function for determining the number of bytes in a fixed-size string...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    They should make it really slow. Null terminated strings are one of the worst C decisions to save some bytes in the '70.

    Comment


    • #3
      There are systems and corporations where glibc is forbidden. And C string where character zero is sign of the end of string and is also a mark of well designed system according C lang designer where compilation of 10-100 MLOC app(100k-500k is typical scholar project ) took at least half a day so it is also a wormsign

      Comment


      • #4
        Originally posted by patrick1946 View Post
        They should make it really slow. Null terminated strings are one of the worst C decisions to save some bytes in the '70.
        WP: """Null-terminated strings were produced by the .ASCIZ directive of the PDP-11 assembly languages and the ASCIZ directive of the MACRO-10 macro assembly language for the PDP-10. These predate the development of the C programming language [..]"""

        Comment


        • #5
          Originally posted by patrick1946 View Post
          They should make it really slow. Null terminated strings are one of the worst C decisions to save some bytes in the '70.
          It doesn't have to be NULL terminated when you're using strnlen(), so that's probably why it can be optimized.

          Comment


          • #6
            Originally posted by elbar View Post
            There are systems and corporations where glibc is forbidden. And C string where character zero is sign of the end of string and is also a mark of well designed system according C lang designer where compilation of 10-100 MLOC app(100k-500k is typical scholar project ) took at least half a day so it is also a wormsign
            What?

            Comment


            • #7
              I'd really like to understand where this optimization is useful enough. strnlen(), while being a vitally safe in a context when you aren't certain in input, is "critical path" for too few applications. Who asked glibc developers, or this is their own play?

              Comment


              • #8
                Originally posted by uxmkt View Post
                WP: """Null-terminated strings were produced by the .ASCIZ directive of the PDP-11 assembly languages and the ASCIZ directive of the MACRO-10 macro assembly language for the PDP-10. These predate the development of the C programming language [..]"""
                Yes, but so was string with a size to this time. So they chose it to save maybe one to 3 bytes. AFAIK to this time strings had commonly a 2byte size.

                Comment


                • #9
                  Originally posted by Volta View Post

                  It doesn't have to be NULL terminated when you're using strnlen(), so that's probably why it can be optimized.
                  Yes, if it can get it for a string literal, it can optimize it. Still, null-terminated strings are an anti-pattern.

                  Comment


                  • #10
                    Originally posted by patrick1946 View Post
                    They should make it really slow. Null terminated strings are one of the worst C decisions to save some bytes in the '70.
                    Go ahead and do that on your computer.
                    Write a custom library that has the same glibc signature for the functions you don't like. Make it like a million times slower for your own pleasure.
                    LD_PRELOAD that library system wide for everything you run.
                    And enjoy running - or rather snail pace crawling - your pc.

                    Comment

                    Working...
                    X