haskell / haskell/deepseq

Inefficient derived instance

Open
#29 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
45
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Please see http://stackoverflow.com/questions/41884350/performance-difference-with-unpacking?noredirect=1#comment70951584_41884350

I have 2 datatypes for 4x4 matrix of Float:
1) Matrix made of four four-element vectors of Float
2) Matrix of 16 elements of Float

I suppose they have to be identical, but derived core code for NFData instance turns out to be different:

1) 4 vectors of 4 elems:

```
-- RHS size: {terms: 5, types: 18, coercions: 0}
$fNFDataMatrix4x4f_$s$dmrnf :: Matrix4x4f -> ()
$fNFDataMatrix4x4f_$s$dmrnf =
\ (eta_X8zo :: Matrix4x4f) ->
case eta_X8zo
of _
{ Matrix4x4f dt_d8x5 dt1_d8x6 dt2_d8x7 dt3_d8x8 dt4_d8x9 dt5_d8xa
dt6_d8xb dt7_d8xc dt8_d8xd dt9_d8xe dt10_d8xf dt11_d8xg dt12_d8xh
dt13_d8xi dt14_d8xj dt15_d8xk ->
()
}
```

2) Matrix of 16 elems:

```
-- RHS size: {terms: 70, types: 954, coercions: 0}
$fNFDataMatrix4x4f_$s$dmrnf :: Matrix4x4f -> ()
$fNFDataMatrix4x4f_$s$dmrnf =
\ (eta_a8Bf :: Matrix4x4f) ->
case eta_a8Bf
of _
{ Matrix4x4f ww1_s8VG ww2_s8VH ww3_s8VI ww4_s8VJ ww5_s8VK ww6_s8VL
ww7_s8VM ww8_s8VN ww9_s8VO ww10_s8VP ww11_s8VQ ww12_s8VR ww13_s8VS
ww14_s8VT ww15_s8VU ww16_s8VV ->
case $w$cfrom
ww1_s8VG
ww2_s8VH
ww3_s8VI
ww4_s8VJ
ww5_s8VK
ww6_s8VL
ww7_s8VM
ww8_s8VN
ww9_s8VO
ww10_s8VP
ww11_s8VQ
ww12_s8VR
ww13_s8VS
ww14_s8VT
ww15_s8VU
ww16_s8VV
of _ { (# ww18_s8Yp, ww19_s8Yq #) ->
case ww18_s8Yp of _ { :*: ww21_s8W3 ww22_s8Wj ->
case ww21_s8W3 of _ { :*: ww24_s8W6 ww25_s8Wc ->
case ww24_s8W6 of _ { :*: ww27_s8W9 ww28_s8Wa ->
case ww25_s8Wc of _ { :*: ww30_s8Wf ww31_s8Wg ->
case ww22_s8Wj of _ { :*: ww33_s8Wm ww34_s8Ws ->
case ww33_s8Wm of _ { :*: ww36_s8Wp ww37_s8Wq ->
case ww34_s8Ws of _ { :*: ww39_s8Wv ww40_s8Ww ->
case ww27_s8W9 of _ { __DEFAULT ->
case ww28_s8Wa of _ { __DEFAULT ->
case ww30_s8Wf of _ { __DEFAULT ->
case ww31_s8Wg of _ { __DEFAULT ->
case ww36_s8Wp of _ { __DEFAULT ->
case ww37_s8Wq of _ { __DEFAULT ->
case ww39_s8Wv of _ { __DEFAULT ->
case ww40_s8Ww of _ { __DEFAULT -> $fNFDataMatrix4x4f3 ww19_s8Yq }
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no repository files or tests. Start with the linked Stack Overflow discussion and compare the generated NFData core for the two Matrix4x4f layouts. Done means determining why the derived instances differ and documenting or resolving the inefficient behavior, with evidence from a reproducible comparison.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.