-
Notifications
You must be signed in to change notification settings - Fork 49
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
getindex(::Column) performance #252
Conversation
This is excellent, I love how small and targeted it is now. |
We should test with binary format and with text format, and with custom conversion functions (the What you could do is create a single row with the data of types you care about (in text), then create a temporary table and insert that row N times. You can then select the contents of the table (several times for different args to
Given that the benefits are so very huge, it could be worth just recording the memory estimate and time from a benchmark generated on this branch now and just testing that we haven't exceeded it by ~2-3x. You can add a new testset in the results section. Long term it would be good to set up a proper benchmark suite using https://juliaci.github.io/PkgBenchmark.jl/stable/. |
I'm actually not sure how to proceed with this. Could you provide an example? |
There are examples of all the pieces in the nebulous This creates a temporary table that will be destroyed when you close the connection. This particular table has one identity column (you can ignore it) and then one string column, for other types you can just add items to the column list replace conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER")
result = execute(conn, """
CREATE TEMPORARY TABLE libpqjl_test (
id bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
my_string_column varchar
);
""") This code inserts a row (you can repeat the line to insert multiple rows; they will get a different result = execute(conn, "INSERT INTO libpqjl_test (my_string_column) VALUES (\$1)", ["foo"]) or result = execute(conn, "INSERT INTO libpqjl_test (my_string_column) VALUES ('foo')") In the latter version, anything in this variable test_data in the first tuple element can be substituted for In this other test_data, we have a middle column. When you specify that type in a I think that's a good place to start, I can explain the other bits once you've made it through the above, so that we have that shared context. Happy to have a call or a pair-programming session to help you get started. But it's worth saying I don't think performance tests should prevent this MR from going in. |
Thanks for the advice @iamed2 . I've added some regression tests (wound up only using one of the two test data sets). Let me know if you think I've missed anything! |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Note: we should definitely squash + merge this one when it goes in, because I accidentally committed a bunch of larger files that we don't want in the history (just profiling-related stuff) |
Co-authored-by: Eric Davies <iamed2@gmail.com>
Thanks @iamed2 . Will merge when CI passes |
Having said that, I don't have merge right. @iamed2 pls squash + merge when you get a minute :) Thanks again for the review and helping me get this across the line! |
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 thePQValue
type to prevent the need to allocate whenresult
(which is a mutable struct) is used to construct aPQValue
.PQValue
andColumn
so that it can be statically resolved.parse_type
closure 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 :) ) :
runtests
into which I should hook? It's a rather large file, so I'm not completely sure what a good entrance point would be.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
inPQValue
.