generics-sop
generics-sop copied to clipboard
WIP: Revive compact representation for NP/NS
This is an attempt to revive https://github.com/well-typed/generics-sop/tree/compact-representation .
I just came to repo to see if it would be possible to have a more compact representation of NS
, could a similar thing be done using
data NS (f :: k -> Type) (ts :: [k]) = NS Word Any
I’m less sure if it would have as much of a performance improvement as the rest of this PR, but it would definitely improve memory usage.
Yes, that's certainly possible. The original branch from which I was working does in fact do that.
For my current purposes however, it turns out this representation is still not quite good enough, so I'm not sure if this work will go anywhere right now.
Ah great, I found the branch and it looks like it was a little more complicated than I expected (I had started playing with an implementation of the idea this afternoon but ran into some of the issues that the original branch ran into, such a making instances for Show, Eq etc. work)
I would be really keen to see some benchmarks before and after with the original, your PR's work, the compact NS implementation, and both (though I understand if you aren't keen do the last two).
Perhaps @kosmikus did some on the original compact representation branch?
I did only do runtime benchmarking, and I wasn't too impressed. I think staging is the far superior approach for runtime performance. Compile-time is a different question though.
If the goal is that any compact-representation branch would become the default at any point, it needs thorough benchmarking though. I don't want to replace a safe implementation with a potentially unsafe one for questionable / not noticeable gain.
FWIW, I've started working on porting the rest of the old compact-representation branch.
Is there any word on progress of this PR?