Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Investigate faf results on Plaintext #7402

Closed

Description

@sebastienros

It's currently over 8M RPS which is above the theorical limit of the network.

Activity

  1. sebastienros commented on Jun 7, 2022

    @sebastienros
    ContributorAuthor
  2. sumeetchhetri commented on Jun 9, 2022

    @sumeetchhetri
    Contributor

    Please look at the source for the framework here, the date value is passed along from the main event loop, also the date header validation does exist in the tfb toolset.

  3. sebastienros commented on Jun 9, 2022

    @sebastienros
    ContributorAuthor

    Thanks for confirming. Do you know how it's getting over the "physical" limits then? If not then I will try to check the full payload it's sending so I can understand.

  4. fafhrd91 commented on Jun 9, 2022

    @fafhrd91
    Contributor

    could process priority affect throughput?

  5. sebastienros commented on Jun 9, 2022

    @sebastienros
    ContributorAuthor

    @fafhrd91 historically all plaintext results have been capped at 7M rps because when you look at the minimum request size and the network packets, over a 10Gb/s network, it can't be faster than that.

    This was confirmed by:

    • stripping the /paintext url to /p (and triggered a new rule in the specs)
    • using smaller Server: ... headers (and triggered a new rule in the specs)
    • using a faster network card (in our Microsoft's lab) which improved all plaintext results for top frameworks (up to 14M rps) without changing anything else.

    I am not excluding any magic trick though, even at the network level, which could be a totally fine explanation.

  6. billywhizz commented on Jun 15, 2022

    @billywhizz
    Contributor

    @sebastienros @fafhrd91 @sumeetchhetri @errantmind

    i've done a little investigation here and it seems each faf request from wrk is 87 bytes and each response back is 126 bytes.

    so, if we assume for argument sake an average ethernet packet size of 8192 bytes, that would allow 64 responses per packet plus 66 bytes of protocol overhead for TCP/IP/Ethernet, giving us an overhead of ~1 byte per response for an overall average including protocol overhead of 127 bytes per response.

    if we divide 10,000,000,000 (10Gb) bits by (127 * 8 = 1016) bits we get a theoretical max throughput of 9,842,519 responses per second on a 10Gb ethernet interface.

    so, i think it is possible that the faf solution, due to it's extreme low level and focus on shaving every possible microsecond off the server side processing overhead could be significantly faster than all the other frameworks no? it does seem to skew the results on the TE charts though so maybe it should be tagged as stripped instead of realistic?
    Screenshot from 2022-06-15 21-27-31

    i also can confirm that the responses are adhering to the rules and the date field does change at least every second.

  7. billywhizz commented on Jun 16, 2022

    @billywhizz
    Contributor

    @sebastienros are my calculations above correct? as far as i understand, they would assume full duplex communication between web server and benchmark server so that would mean theoretical throughput of 10Gb up and 10Gb down simultaneously yes? if not, then i can't understand how we could even reach 7m RPS. 🤷‍♂️

  8. errantmind commented on Jun 17, 2022

    @errantmind
    Contributor

    I didn't see this right away, so sorry for the delay.

    There is no single secret that accounts for the difference in performance between faf and other projects. Each component in faf has been hand optimized to some degree.

    If anyone is extra curious they can test each component individually against what they have. The source code is a little dense but has decent separation-of-concerns.

  9. billywhizz commented on Jun 17, 2022

    @billywhizz
    Contributor

    @errantmind i will take a look. i find rust syntax so horrific to look at though. i'll see if i can put together something in plain old C that would achieve the same throughput.

    @sebastienros @nbrady-techempower can anyone confirm re. my questions/calculations above? i had thought, as sebastien asserted above, that 7m RPS was some kind of hard limit based on the hardware but it seems not. 🤷‍♂️

  10. sebastienros commented on Jun 17, 2022

    @sebastienros
    ContributorAuthor

    Sorry, haven't had time to look into it, but I had done the same calculation 3 years ago (we recorded it I think) and we confirmed the 7M. I had looked at wireshark traces too because we didn't understand why all results capped at 7M. Then we ordered new NICs (40gb/s) and magically the benchmarks became much faster. All these benchmarks that are currently at 7M reach 10M+ when using a faster card, with the same hardware (we own the same physical machines as TE), so I don't think faf is just faster because it's "more" optimized than other fast frameworks. But until proven otherwise this is what it is, and I totally understand that there are some tests to validate the results. Hope to find some time to investigate more soon.

  11. sebastienros commented on Jun 17, 2022

    @sebastienros
    ContributorAuthor

    @billywhizz

    if we assume for argument sake an average ethernet packet size of 8192 bytes

    MTU is 1500 on these NICs, including the ones we use.

  12. billywhizz commented on Jun 17, 2022

    @billywhizz
    Contributor

    @sebastienros ok, so if my quick calculation is correct that would make it a theoretical max RPS of ~9.4m.

    each packet = (11 * 126) + 66 = 1452 bytes = 11616 bits
    10bn bits / 11616 = 860881 packets
    860881 packets * 11 = 9,469,696 RPS

    assuming full duplex and that downstream link can use the full 10Gb. does that sound correct?

  13. sebastienros commented on Jun 17, 2022

    @sebastienros
    ContributorAuthor

    I took some tcp dumps and all looks fine. Compared to ULib (c++) also which used to be the fastest on our faster network.

    The important things I noted are

    • The headers Server : F vs Server: ULib, which is saving 3 bytes.
    • The packets are smaller for ULib, so it's more common to have the responses split in two packets vs. FAF
    • All pipelined requests fit in one packet of 2720B, for both. Even though the MTU is 1500. I read there are some network optimizations that make it possible.

    But something that you should re-calculate, is that the requests are 170B, so these should be the network bottleneck (if it is one):

    From the client each packet is 2720B (16 requests of 170B) plus the preamble (66B) which makes 2786B to send 16 requests.
    The NICs are full-duplex so 10Gb up AND down.
    10^9/2786 = 358937 groups of 16 requests per second
    358937 * 16 = 5,742,992 RPS

    And this is assuming there is no lost/empty packets (and there are)

  14. billywhizz commented on Jun 17, 2022

    @billywhizz
    Contributor

    @sebastienros

    thanks for getting back. that's odd - when i run locally and do a single http request the http payload is only 126 bytes. not sure where 170 bytes is coming from. thanks for confirming re. full duplex. i think my calculation is correct then if we can resolve the 126 bytes versus 170 bytes you are seeing for http payload?
    Screenshot from 2022-06-17 20-40-45

  15. 21 remaining items

  16. joanhey commented on Jul 7, 2022

    @joanhey
    Contributor
  17. billywhizz commented on Jul 9, 2022

    @billywhizz
    Contributor

    one thing i have found when testing with wrk is the number of requests it reports is literally never the actual number of requests the server received. from tests i have done is undercounting by ~3%. i'll see if i can spend some time over next week or two investigating this issue further - it's definitely a weird one!
    Screenshot from 2022-07-09 08-00-15

    this script is useful for seeing RPS across threads but it seems to undercount requests in same way, so something unusual seems to be happening inside wrk itself.

    local counter = 1
    local threads = {}
    
    --wrk.method = "PUT"
    --wrk.headers["Content-Type"] = "application/json"
    
    function setup(thread)
      thread:set("id", counter)
      table.insert(threads, thread)
      counter = counter + 1
    end
    
    response = function(status, headers, body) 
      if statuses[status] == nil then
        statuses[status] = 1
      else
        statuses[status] = statuses[status] + 1
      end
    end
    
    done = function(summary, latency, requests)
      for index, thread in ipairs(threads) do
        local statuses = thread:get("statuses")
        local id = thread:get("id")
        for key, value in pairs(statuses) do 
          io.write(string.format("Thread: %d, %s: %d\n", id, key, value))
        end
      end
      for _, p in pairs({ 50, 75, 90, 95, 99, 99.999 }) do
        n = latency:percentile(p)
        io.write(string.format("%g%%,%d\n", p, n))
      end	
    end
    
    init = function(args)
      statuses = {}
      local r = {}
      local depth = tonumber(args[1]) or 1
      for i=1,depth do
        r[i] = wrk.format()
      end
      req = table.concat(r)
    end
    
    request = function()
      return req
    end
  18. errantmind commented on Jul 17, 2022

    @errantmind
    Contributor

    General FYI: I am actively looking into this today as it is annoying not to know what is going on here. I have a few suspicions and will post an update here today/tomorrow with whatever I find.

    In the meantime I ask that FaF is excluded from this round of the official results until we have an answer here. @nbrady-techempower

  19. added a commit that references this issue on Jul 25, 2022
  20. errantmind commented on Nov 3, 2022

    @errantmind
    Contributor

    Sorry, I had some other work come up I had to prioritize.

    It appears there was a fairly niche bug after all. I patched the code and will write an explanation after the next continuous run completes.

  21. errantmind commented on Nov 6, 2022

    @errantmind
    Contributor

    I broke my build in the process of upgrading between Rust versions so I'll have to wait before seeing the updated results, but I'll go ahead and explain the bug.

    The bug affected HTTP 1.1 pipelined requests outside of local networks, in situations where the pipelined requests exceeded the network interface's MTU. In short, FaF was sending more responses than there were requests.

    On Linux, by default, loopback interfaces often use very high MTU. Because of this, the bug did not manifest over loopback which made it harder to pinpoint initially, only after I set my loopback MTU to a more standard 1500 could I reproduce it.

    As the benchmark was sending nearly double the MTU bytes as pipelined requests, the socket reads usually contained a partial request at the end of the segment (totalling 1500 bytes). FaF was not updating a pointer to a read buffer where it needed and was responding to the 9 complete pipelined requests, then responding again to the full 16 requests after reading the remaining data from the socket in a subsequent loop. Wrk is counting all these responses as a part of the results. I wrote some simple tests to ensure FaF is now behaving as expected so I'm pretty confident the issue is resolved.

  22. joanhey commented on Nov 15, 2022

    @joanhey
    Contributor

    I said it before, in this issue #6967
    But it's still a issue and not a rule.

    And again I say it with this PR #7701

    For me is NOT realistic, and also not fair play.

  23. joanhey commented on Nov 15, 2022

    @joanhey
    Contributor

    We need to add more tests.

  24. joanhey commented on Nov 15, 2022

    @joanhey
    Contributor

    All the frameworks can only check for the first chart, and not the exact route.
    Also all can use nice -20.

  25. errantmind commented on Nov 15, 2022

    @errantmind
    Contributor

    I am checking the full route, and have been for a very long time now. You appear to be looking at an older commit.

    It is pretty strange to me that you are fixated on setting process priority as this keeps popping up. It is neither unusual nor unrealistic as scheduling has an effect on performance, and this is a benchmark. Even if it wasn't a benchmark it wouldn't be unusual for any latency-sensitive application (e.g. audio, games, etc).

    Please refer to the following for the current commit and diff:

    https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Rust/faf

    https://github.com/TechEmpower/FrameworkBenchmarks/pull/7701/files

  26. volyrique commented on Dec 10, 2022

    @volyrique
    Contributor

    @sebastienros We now have 3 runs in which faf has behaved as expected (i.e. in line with the other top performers), and a detailed explanation of the issue by @errantmind, so shall we consider the matter settled?

  27. sebastienros commented on Dec 10, 2022

    @sebastienros
    ContributorAuthor

    Absolutely, we should close the issue and put faf back on the board. Another great TechEmpower story.

  28. remittor commented on Mar 24, 2023

    @remittor
    Contributor

    @sebastienros

    It's currently over 8M RPS which is above the theorical limit of the network.

    Server: HP Z6 G4 Dual Xeon Gold 5120 (TurboBoost off), Net link 10Gbps, Debian 11, Python 3.9
    framework: libreactor (builded from manual: link )

    Client: Intel 12700K (20 threads), Net link 10Gbps, Debian 11

    $ wrk -t20 -c512 -d15 -H 'Connection: keep-alive' http://10.12.0.2:8080/plaintext -s pipeline.lua -- 16
    Running 15s test @ http://10.12.0.2:8080/plaintext
      20 threads and 512 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency   540.07us  326.54us  11.18ms   66.87%
        Req/Sec   429.86k    25.02k  674.46k    80.56%
      129135108 requests in 15.10s, 16.24GB read
    Requests/sec: 8552362.62
    Transfer/sec:      1.08GB
    

    On server 28 cores loaded ~ 25%...30%
    Result: 8552362 req/sec

    $ curl -w '\n%{size_header} %{size_download}\n' http://10.12.0.2:8080/plaintext
    Hello, World!
    122 13
    

    122 + 13 = 135 bytes
    135 * 129135108 = 17433239580 bytes => (17433239580 * 8) / (1000 * 1000 * 1000) = 139.46591664 Gbit
    139.46591664 / 15.1 = 9.236 Gbps


    Bonus: Net 25Gbps

    $ wrk -t20 -c512 -d15 -H 'Connection: keep-alive' http://10.13.0.2:8080/plaintext -s pipeline.lua -- 16
    Running 15s test @ http://10.13.0.2:8080/plaintext
      20 threads and 512 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency   208.87us  167.10us  12.36ms   83.52%
        Req/Sec     1.07M    50.41k    1.53M    70.88%
      322932770 requests in 15.10s, 40.60GB read
    Requests/sec: 21387110.40
    Transfer/sec:      2.69GB
    
  29. remittor commented on Mar 24, 2023

    @remittor
    Contributor

    @joanhey

    Faf | 8,672,182 | 8,614,646.29 | 130,082,744/15 = 8,672,182.93

    And why do the TFB scripts themselves calculate the speed as much as dividing by a hardcoded constant 15?

    For example, what's the difference if we take the number of requests and time from my test:
    129135108 / 15.0 = 8609007 req/sec (FAKE result)
    129135108 / 15.1 = 8551993 req/sec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions