0

我看过http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/GHC-IO-FD.html。那里说:

-- We used to use System.Posix.Internals.dEFAULT_BUFFER_SIZE, which is
-- taken from the value of BUFSIZ on the current platform.  This value
-- varies too much though: it is 512 on Windows, 1024 on OS X and 8192
-- on Linux.  So let's just use a decent size on every platform:
dEFAULT_FD_BUFFER_SIZE :: Int
dEFAULT_FD_BUFFER_SIZE = 8096

我们可以为自己更改 dFAULT_FD_BUFFER_SIZE 值吗?

4

1 回答 1

1

您可以在源代码中更改它并使用新大小编译 GHC。这可能会影响性能(它肯定会影响极端值),否则您可能不会注意到。

除此之外,您无法更改它。

快速搜索基地来源仅显示一个使用站点,

instance BufferedIO FD where
  newBuffer _dev state = newByteBuffer dEFAULT_FD_BUFFER_SIZE state
  fillReadBuffer    fd buf = readBuf' fd buf
  fillReadBuffer0   fd buf = readBufNonBlocking fd buf
  flushWriteBuffer  fd buf = writeBuf' fd buf
  flushWriteBuffer0 fd buf = writeBufNonBlocking fd buf

所以没有地方可以在编译后插入不同的值。

于 2012-05-04T10:42:47.947 回答