One bit of history that might be pertinent is that very early h-store prototypes (that became VoltDB 1.0) used boost shared pointers and their ilk extensively. The judgement at the time was that it might have been overboard for the core performance code in VoltDB. A deep purge was made and there was measurable improvements. Boost shared pointers are not generally slow, and the near-total purge may have been an overcorrection.
But we've also gotten a little more careful about how we allocate memory since those early days. The number of allocations in fast paths is pretty small. I like the idea behind changes like this. I suspect we'd accept a patch that made such changes, with the assumption that it didn't have a measurable affect on performance.
Note that for measurement for things like this, we typically use the TPC-C-like benchmark we have, as it stresses the C++ code much more than our other benchmarks. It would be nice to have some C++ only micro benchmarks that exercised core loops, but we have a history of TPC-C numbers on common hardware. The results of daily performance runs aren't public, which is too bad (but also a bit of work).
-John
Hi,You can use boost pointers for RAII and still leak the internal pointer for fast lookups e.g. get more cake and still have some.
ArielOn Wed, Mar 14, 2012 at 11:17 PM, John Hugg <jh...@voltdb.com> wrote:
I think what you've written is sensible. Thoughts:
One bit of history that might be pertinent is that very early h-store prototypes (that became VoltDB 1.0) used boost shared pointers and their ilk extensively. The judgement at the time was that it might have been overboard for the core performance code in VoltDB. A deep purge was made and there was measurable improvements. Boost shared pointers are not generally slow, and the near-total purge may have been an overcorrection.
But we've also gotten a little more careful about how we allocate memory since those early days. The number of allocations in fast paths is pretty small. I like the idea behind changes like this. I suspect we'd accept a patch that made such changes, with the assumption that it didn't have a measurable affect on performance.
Mike
These are valid defects and become more significant as we use more
adhoc SQL. Perhaps we haven't been strict enough here as this is an
initialization path and a failed plan fragment would usually terminate
DB startup in most use cases.
Thanks for the code review -- we'd love a patch or we can file a
defect to make a pass through these p_init functions and fix these
error path leaks.
Ryan.
A minor point: I believe that the original ' = ' syntax for initialization is equivalent to the changed syntax using '(...), and I, for one, find ' = ' more natural for smart pointers. That is, I prefer
boost::scoped_array<std::string> column_names = new std::string[column_count]);
to
boost::scoped_array<std::string> column_names(new std::string[column_count]));
for use with (smart) pointers, primitives, enums, and "value" classes.
I lean towards the '(...)' syntax for more involved classes whose single initializer represents only part of its state.
I'm on the fence when it comes to which form to use for copy constructors for such classes.
Thanks for the clarification on copy vs. value initialization -- as you say, the compilers are good at making them a wash. So much that I have come to think of them as equivalent for practical purposes.
The VoltDB coding standards are now documented on the developer wiki https://github.com/VoltDB/voltdb/wiki/Code-conventions-%26-licensing
They're pretty easy to live with. Other standards may be added as we reach consensus about them -- most likely in the form of guidelines/direction/preferences rather than new "Hard Rules".
Your feedback on this or other developer wiki pages is welcome. The wiki is in its early days and is still very much a work in progress.