A way to stop GC wasting CPU time on long-lived objects (GC generations or something else)
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
PHP's GC is currently unsuited to long-running applications because of the lack of GC generations.
Any application which has long-lived objects with many descendents (such as PocketMine-MP's Server) will currently experience significant performance hits from GC runs due to the expense of repeatedly scanning complex dependencies of these objects.
I haven't dived deep into this problem, but I did verify that just the Server alone winding up in the GC root buffer in PocketMine-MP (which it should never do, being an object that stays alive for almost the entire process) costs 1.7 ms of GC time on a 12700k. An average GC run in PM during normal operation costs somewhere in the ballpark of 15ms, despite creating almost zero cycles.
This is a massive performance impact to PM on account of its update cycle taking place every 50 ms, so a 15ms GC pause is serious business.
Runtimes like .NET and Java have GC generations to avoid this problem, which avoid frequently scanning complex long-lived objects.
I understand that the benefit to PHP is relatively small, given that the primary use case is to serve short-lived web requests, but implementing generations in GC would positively affect performance of long-lived applications.
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.
Hướng nghiên cứu
Bắt đầu với ví dụ PocketMine-MP src/Server.php được liên kết để hiểu đồ thị đối tượng tồn tại lâu dài và chi phí GC đã được báo cáo. Sau đó, tìm phần triển khai GC của PHP và các bài kiểm thử liên quan, tái hiện việc quét lặp lại được mô tả ở đây, và xác định hoàn thành là khi có một phương pháp đã được kiểm thử giúp giảm công việc đối với các đối tượng tồn tại lâu dài mà vẫn bảo toàn việc thu gom chu kỳ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php
- Lĩnh vực
- performance
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100