Skip to content
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

Add generic setters to void casting values to any #276

Merged
merged 8 commits into from
Sep 20, 2024

Conversation

JAicewizard
Copy link
Contributor

Casting to any can be a significant overhead for table functions, as it usually requires an allocation.

In addition, the new functions also handle all possible castings that we support, so I think that we can also remove tryCast completely saving 200 linex, and I suspect we can even remove the setFn field, saving even more. Maybe someone can look at that to see if that sounds reasonable?

Casting to any can be a significant overhead for table functions, as it
usually requires an allocation.
@JAicewizard
Copy link
Contributor Author

Update: Removed all casting logic other than the new set interface

Copy link
Collaborator

@taniabogatsch taniabogatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JAicewizard, thanks for the PR; this is great!
I've left some nits. 😄

Did you happen to run the benchmark func BenchmarkTypes(b *testing.B) in types_test.go? I'd be curious about the improvements.

I also saw that you added code to auto-cast between some types, e.g., in setBool. I am unsure if we should add that or whether it should happen on the user side. Also because we currently only support it for some types... 🤔

vector.go Outdated Show resolved Hide resolved
vector.go Outdated Show resolved Hide resolved
vector.go Outdated Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
vector_setters.go Show resolved Hide resolved
vector_setters.go Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@taniabogatsch taniabogatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more comments and this should be ready to merge. :)

data_chunk.go Outdated Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
vector_setters.go Outdated Show resolved Hide resolved
vector_setters.go Show resolved Hide resolved
@JAicewizard
Copy link
Contributor Author

Did you happen to run the benchmark func BenchmarkTypes(b *testing.B) in types_test.go? I'd be curious about the improvements.

I did this just now, but most of that benchmark is spend making queries and not actually setting the values using the appender. But I checked using pprof and the time spend setting the values went from 11% to 8%. Not sure how reliable that is. Most of the time is spend in duckdb, so we cannot really improve that.

@taniabogatsch
Copy link
Collaborator

Alright, thanks a lot for your work on this! I'll merge it once the tests pass.

@taniabogatsch taniabogatsch merged commit 85f6b60 into marcboeker:main Sep 20, 2024
4 checks passed
@JAicewizard
Copy link
Contributor Author

I wrote some benchmarks, and they showed a 20% in time spend appending. I also uncovered some crashes however, which should be investigated. I will open a PR with the benchmark, but I don't have a fix for the crashes yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants