我们可以更改自己的dEFAULT_FD_BUFFER_SIZE值吗?

时间:2012-05-04 08:50:38

标签: haskell

我看过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

我们可以更改自己的dEFAULT_FD_BUFFER_SIZE值吗?

1 个答案:

答案 0 :(得分:1)

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

除此之外,你无法改变它。

base来源的快速搜索只显示了一个使用网站

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

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