Skip to content

The Bundle datatype seemingly doesn't need the field sVector #269

Description

@gksato

In the module Data.Vector.Fusion.Bundle.Monadic, the datatype Bundle m v a has the field sVector :: Maybe (v a), whose value is currently used by no consumer, apparently (by which I mean I didn't find any usage when I scanned through the code). I am just curious how come it's there. For what (practical or historical) reason does the field exist? Is it even OK to make a pull request in favor of its removal?

Activity

  1. changed the title [-]`Bundle` seemingly doesn't need the field `sVector`[/-] [+]The Bundle datatype seemingly doesn't need the field sVector[/+] on Jan 26, 2020
  2. cartazio commented on Jan 26, 2020

    @cartazio
    Contributor
  3. gksato commented on Jan 26, 2020

    @gksato
    ContributorAuthor

    At least one generator does generate Just v: Data.Vector.Fusion.Bundle.Monadic.fromVector (and hence so do Data.Vector.Generic.stream and Data.Vector.Fusion.Bundle.fromVector). Also, Data.Vector.Fusion.Bundle.Monadic.trans preserves the value of the field. If I've read through and searched within the code correctly, they are the only functions that can give Bundle having Just in sVector.

  4. gksato commented on Jan 26, 2020

    @gksato
    ContributorAuthor

    Oops. There's Data.Vector.Generic.stream', of course! ;)

  5. cartazio commented on Jan 30, 2020

    @cartazio
    Contributor

    all good :)

  6. gksato commented on Jan 31, 2020

    @gksato
    ContributorAuthor

    I don't understand why this has got closed. Could you explain why? My point is that someone assigns it, but nobody uses it. Maybe for use from other package?

  7. cartazio commented on Jan 31, 2020

    @cartazio
    Contributor
  8. gksato commented on Jan 31, 2020

    @gksato
    ContributorAuthor

    My point is: some agents (Generic.stream, Generic.stream', Bundle.Monadic.fromVector and Bundle.fromVector) give a value to it, other (Bundle.Monadic.trans and Bundle.lift) leave the value in it as it is, but if I eye-grepped right, nobody takes a value out of it.

  9. cartazio commented on Jan 31, 2020

    @cartazio
    Contributor
  10. gksato commented on Jan 31, 2020

    @gksato
    ContributorAuthor

    There are some options I can think of:
    1: We could add some consumption: unstreaming operation, slicing operation, and indexing may take the vector out of sVector. There may or may not be performance penalty. I'm pretty doubtful there will be performance benefit. (I say "doubtful"; I didn't test.)
    2: We could entirely remove sVector. May get a slight performance benefit?
    3: Leave it as it is. I don't say this is a very good choice. However it's not an utterly bad option, if you think of Data.Vector.Fusion as non-internal. In fact, I found this issue when I was writing Stream Fusion code outside of vector.
    4: I am wrong. My eye-grep is buggy and there's an usage I didn't find, or the field is some mysterious magic getting the whole thing blazing fast ;)

  11. lehins commented on Jan 17, 2021

    @lehins
    Contributor

    The whole reason why Bundle was created is to utilize SIMD instructions. It is described in this paper: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/haskell-beats-C.pdf
    At some point, I think, there was a fork of vector that worked with some fork of GHC that was actually able to utilize CPU vectorization, but currently this is not the case and I believe sVector isn't used for anything constructive

    So, what do we do about it?

    • We could put effort into removing it, but I highly doubt that we get any performance benefit out of it, maybe only compilation times will improve. It is important to realize, however, that there is a huge danger of introducing new bugs in undertaking like this.
    • We could leave it as is and wait until ghc acquires native SIMD support, and try to finish what the research in the paper has started

    I am leaning towards the latter.

    CC @Shimuuar This is my opinion on this issue, since it came up in the release plan.

    Linking #251 as related ticket on the subject.

  12. gksato commented on Jan 17, 2021

    @gksato
    ContributorAuthor

    @lehins Oh, as an author of this issue, let me mention #330! (Sorry I'm so lazy).

  13. lehins commented on Jan 17, 2021

    @lehins
    Contributor

    Oh, yeah, I forgot that we found a use for sVector 😉

    So, let's keep this issue open, but without any rush of removing sVector and Bundle restructure, who knows what other uses we can find for it.

  14. Bodigrim commented on Jan 17, 2021

    @Bodigrim
    Contributor

    Let's keep sVector then.

  15. cartazio commented on Jan 17, 2021

    @cartazio
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions