toLazyByteStringWith :: AllocationStrategy -> L.LazyByteString -> Builder -> L.LazyByteString
Heavy inlining. Execute a Builder with custom execution parameters.
This function is inlined despite its heavy code-size to allow fusing with
the allocation strategy. For example, the default Builder execution
function toLazyByteString is defined as follows.
{-\# NOINLINE toLazyByteString \#-}
toLazyByteString =
toLazyByteStringWith ('safeStrategy' 'L.smallChunkSize' 'L.defaultChunkSize') L.Empty
where L.Empty is the zero-length LazyByteString.
In most cases, the parameters used by toLazyByteString give good
performance. A sub-performing case of toLazyByteString is executing short
(<128 bytes) Builders. In this case, the allocation overhead for the first
4kb buffer and the trimming cost dominate the cost of executing the
Builder. You can avoid this problem using
toLazyByteStringWith (safeStrategy 128 smallChunkSize) L.EmptyThis reduces the allocation and trimming overhead, as all generated
LazyByteStrings fit into the first buffer and there is no trimming
required, if more than 64 bytes and less than 128 bytes are written.
AllocationStrategyBuffer allocation strategy to use
L.LazyByteStringLazyByteStringto use as the tail of the generated lazyLazyByteStringBuilderBuilderto executeL.LazyByteStringResulting
LazyByteString