Unexpected back-to-back L1 performance

By: Antoine (apitrou.delete.delete@this.this.apache.org), October 15, 2020 3:31 pm
Room: Moderated Discussions

I have this UTF8 validation routine implemented using a state machine:

I would expect its performance to be limited by L1 cache latency: indeed, each state table lookup is dependent on the previous lookup (the current state participates in the address computation in the state table).

However, when I run this function over various kinds of valid UTF8 data (including randomly-generated UTF8 data), I get around 2.5 GB/sec on a Ryzen 9 3900X. Various sources indicate me that Zen 2 CPUs have a L1 latency of 4 to 5 cycles for integer code, so I would not expect more than 1 GB/sec.

Using `perf stat -ddd`, I can also confirm that the L1 cache does more than 5 GLoads per second on this benchmark.

What explanation am I missing? Perhaps the quoted L1 latencies are only worst case values?
 Next Post in Thread >
TopicPosted ByDate
Unexpected back-to-back L1 performanceAntoine2020/10/15 03:31 PM
  Unexpected back-to-back L1 performanceanon2020/10/15 05:25 PM
    Unexpected back-to-back L1 performanceMark Roulo2020/10/15 06:51 PM
      Unexpected back-to-back L1 performanceLinus Torvalds2020/10/15 07:26 PM
        Unexpected back-to-back L1 performanceAntoine2020/10/16 12:43 AM
          Unexpected back-to-back L1 performanceanon2020/10/16 12:48 PM
            String optimizations2020/10/16 01:48 PM
              String optimizationsFoo_2020/10/17 04:14 AM
                String optimizations & type systems2020/10/17 09:14 AM
                  String optimizations & type systemsLinus Torvalds2020/10/17 10:14 AM
                    String optimizations & type systems2020/10/17 11:01 AM
                      String optimizations & type systemsLinus Torvalds2020/10/17 12:34 PM
                        String optimizations & type systems2020/10/17 02:01 PM
                        Or pad?Mark Roulo2020/10/18 03:10 PM
                          Or pad?Björn Ragnar Björnsson2020/10/19 06:42 PM
                            Or pad?Mark Roulo2020/10/19 07:03 PM
                              Or pad?Brett2020/10/20 09:28 AM
                                Or pad?Gabriele Svelto2020/10/20 11:40 PM
                            Or pad?2020/10/20 07:22 AM
                        String optimizations & type systemsDoug S2020/10/19 07:59 AM
                          String optimizations & type systemsLinus Torvalds2020/10/19 10:11 AM
                            String optimizations & type systems2020/10/19 11:20 AM
                            String optimizations & type systemszArchJon2020/10/19 06:17 PM
                              String optimizations & type systemsAntoine2020/10/20 02:10 AM
                                String optimizations & type systemszArchJon2020/10/20 09:31 AM
                                String optimizations & type systemsBrett2020/10/20 09:43 AM
                                  String optimizations & type systemsJörn Engel2020/10/20 03:54 PM
                                    String optimizations & type systemsAdrian2020/10/21 01:18 AM
                                    String optimizations & type systemsDoug S2020/10/21 09:15 AM
                                      String optimizations & type systemsAndrey2020/10/21 09:53 AM
                                        String optimizations & type systemsBrett2020/10/21 04:18 PM
                                          String optimizations & type systemsJörn Engel2020/10/22 04:45 AM
                                            String optimizations & type systemsLinus Torvalds2020/10/22 12:00 PM
                                              String optimizations & type systemsBrett2020/10/22 01:46 PM
                                              String optimizations & type systems2020/10/22 01:55 PM
                                                String optimizations & type systemsBrendan2020/10/22 09:35 PM
                                                  String optimizations & type systems2020/10/23 03:30 AM
                                                    String optimizations & type systemsBrendan2020/10/23 01:55 PM
                                                      String optimizations & type systems2020/10/24 10:24 AM
                                  String optimizations & type systemsAndrey2020/10/21 03:32 AM
            Unexpected back-to-back L1 performancedmcq2020/10/17 04:35 AM
              Unexpected back-to-back L1 performancedmcq2020/10/17 08:19 AM
                Unexpected back-to-back L1 performanceMaynard Handley2020/10/17 10:00 AM
                strcpy in AVX512VL-.-2020/10/17 04:43 PM
          Unexpected back-to-back L1 performance-.-2020/10/17 05:33 AM
      Unexpected back-to-back L1 performanceanon22020/10/15 07:31 PM
      Unexpected back-to-back L1 performanceAntoine2020/10/16 12:27 AM
        Unexpected back-to-back L1 performancegallier22020/10/16 01:39 AM
          Unexpected back-to-back L1 performanceAntoine2020/10/16 01:53 AM
Reply to this Topic
Body: No Text
How do you spell avocado?