Skip to content

Performance test: select() vs poll()

EC2 Default User edited this page May 23, 2019 · 6 revisions

Purpose

Determine the performance difference between two file descriptors monitoring methods: select() vs poll().

Specs

Machine: AWS EC2 t2.micro (1 vCPU ‒ Intel Xeon, 1 GB RAM), Amazon Linux AMI 2018.03

Silgy version: 4.1

There were two Silgy apps:

  1. Server: Silgy Hello World as it was (with default FD_MON_POLL), and with FD_MON_SELECT set, started by ec2-user
  2. Client: perf with 10 silgy_svc processes, started by root

There were 2 tests, both with freshly started server:

  1. FD_MON_POLL version queried by 100 batches @ 1000 requests each, 3 series

  2. FD_MON_SELECT version queried by 100 batches @ 1000 requests each, 3 series

Results

  • FD_MON_POLL

    • from the client's point of view:

      Average = 0.19 ms

      24161 per second
      19196 per second
      19987 per second

    • server's point of view:

      --------------------------------------------------
      Memory: 4 760 kB (4.65 MB / 0.00 GB)
      --------------------------------------------------
      
                  req: 300000
              average: 0.100 ms
      connections HWM: 10
      
  • FD_MON_SELECT

    • from the client's point of view:

      Average = 0.19 ms

      17441 per second
      18956 per second
      18166 per second

    • server's point of view:

      --------------------------------------------------
      Memory: 4 804 kB (4.69 MB / 0.00 GB)
      --------------------------------------------------
      
                  req: 300000
              average: average: 0.124 ms
      connections HWM: 10
      

Conclusion

As expected, poll() allows slightly better performance, as it does not require building FD_SET, nor resetting timeout before each call, as select() does. The difference however is not a huge one, below 10%.

Clone this wiki locally