CommunicationHandle pipes block every thread in the non-threaded RTS on Windows
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
- 57/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend
Hướng nghiên cứu
Start in createCommunicationPipe, where the issue says Windows builds always use rawHANDLEToHandle; compare its runtime selection with createProcess and createPipe. Reproduce the delay with the supplied non-threaded program on Windows, then check the result with the default I/O manager and +RTS --io-manager=native. Done means the default non-threaded RTS lets threadDelay return before the child writes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
GHC defines __IO_MANAGER_WINIO__ for every Windows build, so createCommunicationPipe always gives the
parent a native Handle made by rawHANDLEToHandle, even when the program runs with the default I/O
manager. The comment there says this is fine without WinIO at runtime. That holds with -threaded. In
the non-threaded RTS, though, reading from that Handle is a blocking ReadFile on a synchronous
HANDLE. That RTS runs every Haskell thread on one OS thread, so they all stop until data arrives. An fd
Handle does not have this problem, because in the non-threaded RTS its reads go through asyncRead#
and only the reading thread waits.
Here the child writes after 3s. On Linux, and on Windows with +RTS --io-manager=native, the
threadDelay returns after about 1s. On Windows with the default I/O manager it returns only after the
child has written:
-- ghc NonThreadedRepro.hs (without -threaded)
import Control.Concurrent
import qualified Data.ByteString as B
import GHC.Clock (getMonotonicTime)
import System.Environment
import System.IO
import System.Process
import System.Process.CommunicationHandle
main :: IO ()
main = getArgs >>= \args -> case args of
["child", ch] -> do
h <- openCommunicationHandleWrite (read ch)
threadDelay 3000000
B.hPut h (B.pack [120])
hClose h
_ -> do
(weRead, theyWrite) <- createWeReadTheyWritePipe
self <- getExecutablePath
ph <- spawnProcess self ["child", show theyWrite]
closeCommunicationHandle theyWrite
t0 <- getMonotonicTime
_ <- forkIO (B.hGetSome weRead 1 >>= print)
yield
threadDelay 1000000
t1 <- getMonotonicTime
putStrLn ("threadDelay 1000000 returned after " ++ show (t1 - t0) ++ "s")
_ <- waitForProcess ph
return ()
createProcess and createPipe already pick an fd Handle or a native one at runtime with <!>. Doing
the same in createCommunicationPipe should fix this:
ourHandle <- ((\fd -> rawFdToHandle fd ourMode) =<< openHANDLE ourHANDLE)
<!> rawHANDLEToHandle ourHANDLE ourMode
Worked around this by swapping in an fd Handle here.
- Ngôn ngữ chính
- Haskell
- Star
- 91
- Fork
- 93
- 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
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 haskell/process
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
HAVE_PIPE2 at compile time but not at runtime causes segfault on macOSCó thể đã có người làm @alt-romes đã nhận 3 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
posix_spawn falls back to fork() when create_group = True due to HAVE_DECL_ macro mismatchCó thể đã có người làm @lei-jia-xing đã nhận 11 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
FreeBSD 15.1 and lower have a linker bug that affects processCó thể đã có người làm @luite đã nhận 43 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Tất cả issue của haskell/process
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
haskell/bytestring#730 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
seal-harness/seal-harness#399 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
add previously overlooked rulesĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
fmidue/codeworld-tasks#124 ·
-
allow haskell-src-exts-1.24Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
reflex-frp/reflex#563 ·