Consider using RCPP_USE_UNWIND_PROTECT for improved performance
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Start by inspecting the package build configuration and how Rcpp::Function calls are used in the server callback path. Compare the existing dplyr Makevars use of RCPP_USE_UNWIND_PROTECT, then run the documented wrk hello-world benchmark with and without the flag; done means a justified default build choice with no regressions in request handling.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I was doing some casual profiling of some httpuv servers and noticed that the call stack was deeper than I expected. You can see in the flame graph below (for the "hello, world" example) that there is a tryCatch/eval stack between later::execCallbacks() and the actual call() method (anonymous here) for the server:

I eventually worked out that this tryCatch/eval setup is manually created in C++ code when evaluating an Rcpp::Function, in order to prevent longjmps. This might be well-known. However, it is also apparent from the flame graph that this particular stack seems to impose a significant amount of overhead on all requests, and I wondered if removing it could improve performance.
As it turns out, Rcpp has a not-very-well-advertised configuration option to avoid this in favour of newer C-level features of R, RCPP_USE_UNWIND_PROTECT (originally implemented by Lionel Henry, I believe). This flag is used by some existing packages, dplyr among them, so it probably has few downsides.
To illustrate the potential difference, I ran some load testing for the "hello, world" server against vanilla master:
$ wrk -d 20 -c 10 -t 2 "http://127.0.0.1:5000/"
Running 20s test @ http://127.0.0.1:5000/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.55ms 1.57ms 41.95ms 96.25%
Req/Sec 2.03k 139.92 2.39k 75.25%
80786 requests in 20.01s, 7.70MB read
Requests/sec: 4038.18
Transfer/sec: 394.35KB
And with PKG_CPPFLAGS += -DRCPP_USE_UNWIND_PROTECT:
$ wrk -d 20 -c 10 -t 2 "http://127.0.0.1:5000/"
Running 20s test @ http://127.0.0.1:5000/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.76ms 1.36ms 39.96ms 97.78%
Req/Sec 2.98k 288.29 6.39k 77.56%
118950 requests in 20.10s, 11.34MB read
Requests/sec: 5917.94
Transfer/sec: 577.92KB
As you can see, throughput is about 50% higher. The accompanying flame graph, showing the simplified stack, is below:

In light of this, I believe that you should consider building httpuv with RCPP_USE_UNWIND_PROTECT by default, if possible.
- Ngôn ngữ chính
- C
- Star
- 252
- Fork
- 87
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rstudio/httpuv
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 46/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của rstudio/httpuv
Issue tương tự
-
Status: Opened
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
FriendsofECCE/ECCE#1018 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
immortalwrt/immortalwrt#2522 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
luainkernel/lunatik#2530 ·
Maintainer thường phản hồi trong vòng 1 ngày