GithubHelp home page GithubHelp logo

Comments (6)

clyring avatar clyring commented on July 1, 2024 1
  • toStrict does not incur any copying unless the LazyByteString has more than one chunk, which should never happen in your use case. The overhead you observe is probably the cost of allocating the intermediate LazyByteString's spine, i.e. the Chunk object itself.
  • Solution 1 doesn't make much sense to me. I'd expect in most cases where an upper bound on the size of a Builder's output is available, that upper bound is small enough that it makes sense to provide a BoundedPrim () for the same.
  • Solution 2: From my perspective as a maintainer, Data.ByteString.Builder.Prim.Internal does something very sensible and is very stable. The little "may not be exposed at all in future releases" warning at the top should probably just be deleted, and the module treated as first-class public API like Data.ByteString.Internal.
    • (The warning in Data.ByteString.Builder.Internal is a bit less misplaced; there are several internals-breaking changes to the design of non-Prim Builders that could be explored in the future... with a major version bump, of course.)
  • Solution 3's idea is fine by me, though I'd expect both fixedPrimToStrictByteString and boundedPrimToStrictByteString.

from bytestring.

lykahb avatar lykahb commented on July 1, 2024

If you decide on a solution, I can implement and and submit it.

from bytestring.

lykahb avatar lykahb commented on July 1, 2024

Thanks for digging into the the performance of the the particular code. After looking at the Builder internals I agree that 1 wouldn't work out.

What do you think about doing both 2 and 3?

A value of Ptr Word8 -> IO () is nice for composition. And 3 has a straightforward signature and solves the tradeoff between extra allocation and toStrict conversion on one side, and importing two internal modules on the other side.

from bytestring.

clyring avatar clyring commented on July 1, 2024

My main complaint with solution 2 is that I don't think it solves a real problem. If you have need of it, feel free to import runF from Data.ByteString.Builder.Prim.Internal, which I think is a good home for this function. The bytestring maintainers take stability seriously for every exposed module, regardless of whether "Internal" happens to appear in its name.

from bytestring.

lykahb avatar lykahb commented on July 1, 2024

This makes sense. I'm going to use the internal modules. It would be nice to remove the disclaimer, as you suggested. It gives a different impression about stability than you described.

Would you be open to a PR that implements 3?

from bytestring.

clyring avatar clyring commented on July 1, 2024

Fire away!

from bytestring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.