-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many functions in D.B.Lazy lack INLINE(ABLE) annotations #335
Comments
Do such functions benefit from inlining? Could this improvement be measured? |
@Bodigrim I have made a benchmark here: https://gist.github.com/noughtmare/f2478b9ea7a466d33b3f0185dc51f0dd. That indicates that inlining can play a pretty big role (3x performance improvement) with the EDIT: Now that I look at the strict versions more closely, I think that they are shorter, so it makes more sense to mark them with |
Care to take a look at Core as well? I'd like to understand what exactly contributes to x3 speed up. |
As I understand it |
I have looked a bit at it and it seems that the inline version compiles the dropWhile predicate to a fast unboxed inline case expression, while the version that is not inlined needs to box every character and pass it to a separate predicate function. |
Ah, I see. This is probably because of Lines 959 to 968 in 8c631df
Could you try the similar set of rules for lazy |
So the inline version does not actually take advantage of those rules. Here is the relevant part of the core dump of the inline version: $wgo4_sciy ww_sciw w_scit
= case >=# ww_sciw dt2_d9O8 of {
__DEFAULT ->
case readWord8OffAddr# (plusAddr# dt_d9O6 ww_sciw) 0# w_scit of
{ (# ipv_a9Rj, ipv1_a9Rk #) ->
case chr# (word2Int# ipv1_a9Rk) of {
__DEFAULT -> jump $wgo4_sciy (+# ww_sciw 1#) ipv_a9Rj;
' '# -> jump $w$j_scir ipv_a9Rj ww_sciw
}
};
1# -> jump exit_X1m w_scit You see that it reads off a byte and then directly compares it to the space character, but it does not use one of those rewrite rules. Here is the uninlined version: $wgo4_schD ww_schB w_schy
= case >=# ww_schB dt2_d9O5 of {
__DEFAULT ->
case readWord8OffAddr# (plusAddr# dt_d9O3 ww_schB) 0# w_schy of
{ (# ipv_a9Rj, ipv1_a9Rk #) ->
case f_a8ll (C# (chr# (word2Int# ipv1_a9Rk))) of {
False -> jump $w$j_schw ipv_a9Rj ww_schB;
True -> jump $wgo4_schD (+# ww_schB 1#) ipv_a9Rj
}
};
1# -> jump exit_X1p w_schy You can see that it reads off a byte and then passes it to the |
OK, then I suggest we do both, bringing lazy version in line with the strict one: mark |
Ideally both strict and lazy |
Yes, and I also found out that the But anyway the added |
In particular the substring functions:
bytestring/Data/ByteString/Lazy.hs
Lines 676 to 755 in 684047c
But there might also be other functions that can benefit.
The text was updated successfully, but these errors were encountered: