Skip to content

make dropWhile fusion adaptive - #327

Merged
Shimuuar merged 2 commits into
haskell:masterfrom
gksato:adaptive-dropWhile
Aug 13, 2020
Merged

Shimuuar merged 2 commits into
haskell:masterfrom
gksato:adaptive-dropWhile

Conversation

@gksato

@gksato gksato commented Aug 2, 2020

Copy link
Copy Markdown
Contributor

Now dropWhile's implementation uses stream
only in case the stream fusion is already running.
This is expected to reduce unnecessary re-allocation.
This is an improvement of #146, which does not admit stream fusion in any case.

I've executed the tests included in the package with GHC 8.6.5 and 8.8.3.
If you wish to have other tests done, please tell me.

cf. #141
#108

Now dropWhile's implementation uses stream
only in case the stream fusion is already running.
This is expected to reduce unnecessary re-allocation.

cf. haskell#141
haskell#108
@gksato gksato mentioned this pull request Aug 2, 2020
@Shimuuar

Shimuuar commented Aug 6, 2020

Copy link
Copy Markdown
Contributor

At a glance PR seems fine but I want to recheck that it works as advertised. I'm always become very cautious when RULES are involved.

@gksato

gksato commented Aug 7, 2020

Copy link
Copy Markdown
Contributor Author

Agreed. Please tell me if I can help you in any way with rechecking.

@Shimuuar Shimuuar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally I got time to review this properly after I spent quite some time fighting with precision of incomplete gamma function.

It's good, I looked at generated core for simple examples and this function does work as advertised. I tested it with reproducer from #141 and this PR results in 10x speedup! (Note that dropWhile in example misses not)

Comment thread Data/Vector/Generic.hs Outdated
Nothing -> empty

-- If the argument to 'dropWhile' comes from a stream,
-- we need to avoid unnecessary allocation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to say that we want to avoid creating a new vector. Comment doesn't explain what is being allocated.

Also please add mention that new (New.unstream is body of unstream.

@gksato

gksato commented Aug 13, 2020

Copy link
Copy Markdown
Contributor Author

Alrighty. Adding a commit soon.

Modified the comment for the RULE "dropWhile/unstream [Vector]"
in order to make the intention of the implementation there clear.
@gksato

gksato commented Aug 13, 2020

Copy link
Copy Markdown
Contributor Author

Now I've committed and pushed a change to the comment. If you'd like a rebase, squash, etc, please tell me.

@Shimuuar
Shimuuar merged commit 472cca1 into haskell:master Aug 13, 2020
@Shimuuar

Copy link
Copy Markdown
Contributor

Thanks! I'll just squash merged PR.

lehins pushed a commit that referenced this pull request Jan 16, 2021
* make dropWhile fusion adaptive

Now dropWhile's implementation uses stream
only in case the stream fusion is already running.
This is expected to reduce unnecessary re-allocation.

cf. #141
#108

* Adaptive dropWhile Implementation: Implementation comment modified

Modified the comment for the RULE "dropWhile/unstream [Vector]"
in order to make the intention of the implementation there clear.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants