-
Notifications
You must be signed in to change notification settings - Fork 248
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
Iterator performance #770
Comments
I have not compared performance, but perhaps the See the test for how to use the Stream API, such as |
Food for thought. Originally the IIRC I added it so that a function like Perhaps we could break the inheritance relationships between It could be a bit of an undertaking though. And technically it would be a breaking change. We're in the run-up to 8.0, so it's the perfect time for that really. |
I don't think you need to make it "safer" than normal STL iterators. An iterator into |
Indeed. The catch though is that That wasn't a great design choice, but it avoided an overwhelming amount of extra work and duplicated code. I'll have to see whether I can break those inheritance relationships. It looks like a serious amount of work, since the C++ iterator API is pretty broad. It may also break some client code out there. |
I've been looking into this, and I'm digging up other complications:
So I'm still struggling with this. We may end up with a different division of labour between classes. |
Yet another complication is that it's not immediately clear when to return a lightweight iterator and when to return a full I'm not actually sure that's a big problem for iterators, because you don't actually need to copy them very often, so long as you iterate sensibly and pass references where appropriate. Really it's random access with |
I'm forming some answers to the questions. For example, I'm now leaning towards making all iteration and indexing return iterators, not Unfortunately all the work I did on this is on the laptop that broke today, so I'm kind of stuck for now. :-( One fun little side quest was to replace most code in the |
Will it break backward compatibility? |
Well yes, of course - the change you asked for breaks compatibility. |
I've got my laptop back, but unfortunately there was no chance to make a backup. There was a lot of incomplete work on these iterators on there. :-( |
There has been no activity on this ticket. Consider closing it. |
There has been no activity on this ticket. Consider closing it. |
I think this might be a good thing to put on the list for libpqxx 8.0, and combine it with at least the preparation for #846. |
It's been ages. But I've had some more time to think about it, and I think in libpqxx 8.0 we can go for a much stronger separation between The When I experimented with this, I found that it didn't affect a lot of test code. Which I hope is a good sign. And... C++ compilers have advanced "analyzers" now which help find bugs that this might cause. |
There has been no activity on this ticket. Consider closing it. |
Still hoping to address this in 8.0. (It's a pretty radical change, in some ways, so can't do it in a minor release.) |
I've started work on lipqxx 8.0, and hopefully I'll be able to rewrite iterators as a part of that. |
In C++ iterators are presumed to be lightweight objects and are therefore commonly passed by value.
However, the internal implementation of pqxx iterators makes them not so lightweight:
pqxx::const_row_iterator
inherits frompqxx::field
.pqxx::field
holds apqxx::result
by valuepqxx::result
holds 2std::shared_ptr
s.The problem is that an
std::shared_ptr
has to increment/decrement its counter atomically, which has a performance hit.A quick test showed that passing an object that included two
std::shared_ptr
s by value was about 15 times slower than passing it by reference in a debug build, and 50 times slower in a release build.Can something be done to make copying iterators faster?
The text was updated successfully, but these errors were encountered: