LibPQ.jl
LibPQ.jl copied to clipboard
[WIP] getindex performance
Starts to address #250 . Entirely fixes the bug as described in that issue (Float64s, each call to getindex allocates nothing).
The changes include:
- ~~introducing a layer of indirection (thanks @tpgillam for this suggestion) in the
PQValuetype to prevent the need to allocate whenresult(which is a mutable struct) is used to construct aPQValue.~~ - moving a lot of type information into the type of ~~
PQValueand~~Columnso that it can be statically resolved. - Replacing the
parse_typeclosure with theParseType{T}callable to force the compiler to specialise.
I need advice as to how to proceed (@iamed2 I would like to take you up on your offer in #250 :) ) :
- Have I gone about this in a sensible way -- I don't have the overview of the package's architecture that you do @iamed2, so I might be missing something obvious.
- how should I write performance tests for this? Is there a good place in
runtestsinto which I should hook? It's a rather large file, so I'm not completely sure what a good entrance point would be. - What types should I be testing for performance here? Clearly floats / ints / dates etc are good targets -- do we have a collection of examples columns instantiated somewhere in the tests that I could attach some performance tests to?
edit: interestingly, it actually looks like the indirection wasn't necessary in order to remove the allocations. It appears to be the case that everything is sorted by being slightly more assertive in the specialisations that the compiler is made / allowed to perform. Even more interestingly, it doesn't even look like we need to specialise on the typeof jl_result in PQValue.