ObjectStore interface and std::list
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
I missed out on the context leading up to the discussion about queue_transactions and the use of raw vs. smart pointers, but I'm curious whether the use of std::list in the ObjectStore interface has come up as well. That's another source of allocations that could be avoided.
A naive approach could just replace the list with vector, which could at least reduce the number of allocations to one if you reserve() space for all of your elements up front.
An interface based on iterators could also help, by allowing the caller to put an array on the stack and pass that in. Iterators are tricky because the generic form requires templates, and template functions can't be virtual. But if we require the elements to be sequential in memory (i.e. raw array, std::array<Transaction*> or std::vector<Transaction*>), the interface could take (Transaction** begin, Transaction** end) without requiring templates. This interface can also be made compatible with unique_ptrs.
Casey
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Template functions can be virtual in c++11 and can avoid the VTL. I'm using them in https://github.com/ceph/ceph/pull/6781 .
- ----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1
Quoted 20 lines · Casey Bodley
Hi,
I missed out on the context leading up to the discussion about
queue_transactionsand the use of raw vs. smart pointers, but I'm curious whether the use ofstd::listin the ObjectStore interface has come up as well. That's another source of allocations that could be avoided.A naive approach could just replace the list with vector, which could at least reduce the number of allocations to one if you
reserve()space for all of your elements up front.An interface based on iterators could also help, by allowing the caller to put an array on the stack and pass that in. Iterators are tricky because the generic form requires templates, and template functions can't be virtual. But if we require the elements to be sequential in memory (i.e. raw array,
std::arrayorstd::vector), the
interface could take (Transaction** begin, Transaction** end) without requiring templates. This interface can also be made compatible withunique_ptrs.
Quoted 5 lines
Casey
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-----BEGIN PGP SIGNATURE-----
Version: Mailvelope v1.3.0
Comment: https://www.mailvelope.com
wsFcBAEBCAAQBQJWYIp9CRDmVDuy+mK58QAAKVEP/jFe1Vv/1ZJbz30FCM6a DB85aIvbnw2qjNHBbFeaJSAd2oJyVxC1bqfVKTxcms0pnQPYL8/GcAzUImrt n986VgBJAIeaH0qRSGYcITS4rlSikUcSUcPAdjL6Fv9yPleGLCqmCEIWUj/q jKTndoEb4E20I6XHJpG2dAXdxk/knMJJGwHtS7KdsgR2nDos5evjncGrE8I7 nvSO/4zshuQPoglOC86SP17tviQUew3e/a9cZ6jPy6Adz0u3XeV+eKyhf2SB 3hm2sfRVOPT6rdfRvjBBLR7QFz7kJxedyWB2y5c4j2x7GtdWgiZn2YePuNti yRPad+Jq04DpXX0IUFY9+FXQeOIdEQq40bhfvVOgus04xHXgcjUdyR0AYh0M YfXoqvBg7L5C68duPP2wjn2w58CLCDqCp+4JQVVRZ9au8YQK4vt53BefuFnH QX2XePnXNnlkqjgXmq9TqQafETodZYi0VQ110ADGQA/TsPGEqzUn2mudUjM7 ixbJdbcwUd4JHwb55zK5xxBaat9EBj+5pI9Xfjz4Fg8+ZcgKRkWG7EsFVlTn bcZb8TV9/3FSrGFbV4UqTf5IT1/wVuWeG/AKOs540yNFr9My/DtKlNxx+/8O VhSliJ2qbymw0/JpsTacGMqWjYH5bADfYiCmBcyPm8EHYXOnfxNmpC9FYkpO 4LUj
=9kKf
-----END PGP SIGNATURE-----
----- Original Message -----
Quoted 5 lines
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256Template functions can be virtual in c++11 and can avoid the VTL. I'm using them in https://github.com/ceph/ceph/pull/6781 .Hi Robert,
Hi Robert,
Virtual functions are allowed in a templated class, but templated member functions are a separate case. My suggestion to use iterators would require the function itself to be templated on the iterator type. This isn't allowed, because the virtual function table would have to contain an entry for every template instantiation of that function.
Casey
Quoted 56 lines
- ----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1Quoted 20 lines · Casey Bodley
Hi,
I missed out on the context leading up to the discussion about
queue_transactionsand the use of raw vs. smart pointers, but I'm curious whether the use ofstd::listin the ObjectStore interface has come up as well. That's another source of allocations that could be avoided.A naive approach could just replace the list with vector, which could at least reduce the number of allocations to one if you
reserve()space for all of your elements up front.An interface based on iterators could also help, by allowing the caller to put an array on the stack and pass that in. Iterators are tricky because the generic form requires templates, and template functions can't be virtual. But if we require the elements to be sequential in memory (i.e. raw array,
std::arrayorstd::vector), the
interface could take (Transaction** begin, Transaction** end) without requiring templates. This interface can also be made compatible withunique_ptrs.Quoted 5 lines
Casey
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html-----BEGIN PGP SIGNATURE-----
Version: Mailvelope v1.3.0
Comment: https://www.mailvelope.comwsFcBAEBCAAQBQJWYIp9CRDmVDuy+mK58QAAKVEP/jFe1Vv/1ZJbz30FCM6a DB85aIvbnw2qjNHBbFeaJSAd2oJyVxC1bqfVKTxcms0pnQPYL8/GcAzUImrt n986VgBJAIeaH0qRSGYcITS4rlSikUcSUcPAdjL6Fv9yPleGLCqmCEIWUj/q jKTndoEb4E20I6XHJpG2dAXdxk/knMJJGwHtS7KdsgR2nDos5evjncGrE8I7 nvSO/4zshuQPoglOC86SP17tviQUew3e/a9cZ6jPy6Adz0u3XeV+eKyhf2SB 3hm2sfRVOPT6rdfRvjBBLR7QFz7kJxedyWB2y5c4j2x7GtdWgiZn2YePuNti yRPad+Jq04DpXX0IUFY9+FXQeOIdEQq40bhfvVOgus04xHXgcjUdyR0AYh0M YfXoqvBg7L5C68duPP2wjn2w58CLCDqCp+4JQVVRZ9au8YQK4vt53BefuFnH QX2XePnXNnlkqjgXmq9TqQafETodZYi0VQ110ADGQA/TsPGEqzUn2mudUjM7 ixbJdbcwUd4JHwb55zK5xxBaat9EBj+5pI9Xfjz4Fg8+ZcgKRkWG7EsFVlTn bcZb8TV9/3FSrGFbV4UqTf5IT1/wVuWeG/AKOs540yNFr9My/DtKlNxx+/8O VhSliJ2qbymw0/JpsTacGMqWjYH5bADfYiCmBcyPm8EHYXOnfxNmpC9FYkpO 4LUj
=9kKf
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html