# 2023q1 Homework7 (ktcp) contributed by < `PlusThousand0107` > ## 開發環境 ```shell $ gcc --version gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz CPU family: 6 Model: 158 Thread(s) per core: 2 Core(s) per socket: 6 Socket(s): 1 Stepping: 10 CPU max MHz: 4100.0000 CPU min MHz: 800.0000 BogoMIPS: 4399.99 ``` ## CMWQ [CMWQ](https://www.kernel.org/doc/html/v4.10/core-api/workqueue.html) 是 Workqueue 的一種重新實作,常用於需要異步執行的情況下,不過相較於 Workqueue , CMWQ 著重在於以下幾個方面 1. 保持原始 Workqueue API 的兼容性 2. 能自動調整 worker pool 和 level of concurrency ,所以使用者在使用 API 時可以不需知道實作細節 3. 所有的 Workqueue 會共享 per-CPU unified worker pools ,提供靈活的 level of concurrency ,避免過多的資源浪費 ## 壓力測試與比較 於本機對 seHTTPd 和 cserv 進行壓力測試 #### ab `ab -n 100000 -c 500 -k http://127.0.0.1:8081/` | | Requests per second | Time per request (mean, across all concurrent requests)| | -------- | -------- | -------- | | seHTTPd | 11118.94 #/sec | 0.090 ms | | cserv | 21028.50 #/sec | 0.048 ms | #### htstress `./htstress -n 100000 -c 500 127.0.0.1:8081/` | | requests/sec | total time | | -------- | -------- | -------- | | seHTTPd | 23557.609 #/sec | 4.245 s | | cserv | 25272.884 #/sec | 3.957 s | #### httperf `httperf --server 127.0.0.1 --port 8081 --num-conn 500 --num-call 200 --http-version 1.0` | | requests/sec | connection rate | | -------- | -------- | -------- | | cserv | 21856.5 #/sec | 10928.2 conn/s |