Boost.Align review begins today
Hi all, The review of Boost.Align by Glen Fernandes commences today, Friday, 11 April, and concludes Sunday, 20 April. Boost.Align provides: 1. Function align() to align a pointer, for implementations which do not provide C++11's std::align(). 2. Functions aligned_alloc() and aligned_free() for dynamic allocation with specified alignment. { For use in place of ::operator new() and ::operator delete(). } 3. Class template aligned_allocator as an alignment-aware allocator that also allows specifying a minimum alignment. { For use in place of std::allocator. } 4. Class template aligned_allocator_adaptor to turn any existing allocator into an alignment-aware allocator that also allows specifying a minimum alignment. { For use in place of any existing allocator type. } 5. Function is_aligned() to test the alignment of a pointer. Rationale: C++11 added the ability to specify increased alignment (over-alignment) for class types. Unfortunately, ::operator new allocation functions, new expressions, and the default allocator, std::allocator, do not support dynamic memory allocation of over-aligned data. Notes: This library also meets needs in existing Boost libraries. - Boost.Smart_Ptr has its own implementation of align(). - Boost.Interprocess and Boost.Log each have their own implementation of aligned_alloc() and aligned_free(). Source: doc: http://glenfe.github.io/align git: http://github.com/glenfe/align zip: http://github.com/glenfe/align/archive/master.zip Please always state in your review whether you think the library should be accepted as a Boost library. Additionally, please consider giving feedback on the following general topics: - What is your evaluation of the design? - What is your evaluation of the implementation? - What is your evaluation of the documentation? - What is your evaluation of the potential usefulness of the library? - Did you try to use the library? With what compiler? Did you have any problems? - How much effort did you put into your evaluation? A glance? A quick reading? In-depth study? - Are you knowledgeable about the problem domain? Ahmed Charles Review Manager
On Friday 11 April 2014 20:48:02 Ahmed Charles wrote:
Hi all,
The review of Boost.Align by Glen Fernandes commences today, Friday, 11 April, and concludes Sunday, 20 April.
- What is your evaluation of the design?
Overall design looks mostly ok with some reservations below. 1. I'm not sure why some public symbols (align(), aligned_alloc(), etc) are defined in the detail namespace. It would probably be better to move them to the boost::alignment namespace. The reason I'm mentioning this is that the detail namespace will come up in compiler errors and linkage symbols, which might be inconvenint. 2. I think, it's not a good idea to import all Boost.Align symbols into boost:: namespace. I could probably agree with importing align() and aligned_alloc()/aligned_free() but not more sohpisticated things. Boost namespace becomes more cluttered as it is. I'm open to discussion on this topic. 3. It might be a good idea to provide separate headers with forward declarations of aligned_allocator and aligned_allocator_adaptor. It's not a mandatory requirement but I think the headers would be usefult in some cases. 4. aligned_allocator_adaptor relies heavily on constructing/destroying the underlying allocator on every allocation/deallocation. This is fine in most cases, except when: (a) the allocator is not stateless and the conversion to CharAlloc actually takes time and (b) when the allocator constructor can throw (this breaks deallocate()). I'm not sure how legitimate it would be to use such an allocator with the adaptor but wouldn't it be better to just derive from CharAlloc in the first place? You don't need the original Allocator anyway. I know you followed scoped_allocator_adaptor design but I think its use case is sufficiently different.
- What is your evaluation of the implementation?
Mostly ok with the following notes:
1. is_alignment should be marked constexpr and noexcept. As well as
is_aligned.
2. I think, in many headers you're missing #include <cstddef> for std::size_t.
This at least concerns aligned_alloc*.hpp and align.hpp headers.
3. aligned_alloc_android.hpp and aligned_alloc_sunos.hpp are essentially the
same. Suggest leaving just a single aligned_alloc_memalign.hpp which can be
used on all platforms where the result of memalign() can be safely passed to
free().
4. aligned_alloc() and aligned_free() should be marked noexcept. align() could
also probably be marked, although the Standard does not define it as noexcept.
5. Empty constructors in aligned_allocator should probably be defaulted. You
can use BOOST_DEFAULTED_FUNCTION to achieve portability.
6. aligned_allocator.hpp and aligned_allocator_adaptor.hpp are missing
#include <new> for placement new and std::bad_alloc.
7. In aligned_allocator<T>::allocate(), why the hint is defined as
aligned_allocator<void>::const_pointer and not just const void*? You
unnecessarily instantiate aligned_allocator here.
8. aligned_allocator<T>::max_size() should be constexpr and noexcept.
address(), deallocate() and comparison opereators should be noexcept.
destroy() should be conditionally noexcept.
9. Suggest using BOOST_STATIC_ASSERT_MSG instead of BOOST_STATIC_ASSERT to
provide better diagnostics.
10. is_alignment and is_power_of_2 are used for the same purpose yet are named
differently. I think it'd be better to rename is_power_of_2 to something like
is_valid_alignment_static (while is_alignment could be is_valid_alignment).
There tools could be defined in a single header. Also, if constexpr is
supported is_valid_alignment_static can be implemented in terms of
is_valid_alignment.
11. In max_count_of.hpp, replace static_caststd::size_t(-1) with
~static_caststd::size_t(0).
12. In aligned_allocator_adaptor<T>::deallocate(), you attempt to
reinterpret_cast pointer to CharPtr*. This may fail, if pointer is not a raw
pointer type. Suggest to perform the cast in the more generic way, like you do
in allocate(): reinterpret_cast
- What is your evaluation of the documentation?
Rather poor: 1. Please, rewrite it in QuickBook. Not only it ensures the look and feel common to other Boost libraries, it also adds other useful features, such as Doxygen integration and importing the actual compilable code which is useful for examples. 2. It might be worthwhile to describe the differences between C11 and Boost.Align aligned_alloc() to avoid confision. Aside from aligned_free(), Boost.Align aligned_alloc() has weaker requirements on the size argument. 3. I wonder if quoting the Standard violates any copyrights. I'm not a lawyer. In any case, even from a learning user standpoint it might be better to use a simpler language in the docs. A reference to the Standard (draft) could be provided as well. 4. There is actually no documentation to review except for the reference section. I know the library is small and most basic things are easy to grasp for an educated programmer. But nevertheless, a few examples with description wouldn't harm, especially involving allocators. FWIW, aligned_allocator and aligned_allocator_adaptor are new things in C++ and should be properly documented. 5. The Synopsis section does not represent any particular header of the library. I'd rather see a separate synopsis sections for every header. In fact, Doxygen provides mostly what is needed for the reference section. 6. The reference section should be placed near the end of the documentation. The typical reading goes Introduction -> Tutorial -> Detailed description -> Reference. Of course, your docs can omit some of these parts due to the library simplicity, but the overall structure should be something like that. Also, it's easier to read if the sections are of different pages. All in all, most of the structural and aesthetical issues should be resolved by moving to QuickBook. It shouldn't be difficult given the amount of the hand-written docs. The reference could be auto-generated by Doxygen. What is left is a proper description for the components and Doxygen comments.
- What is your evaluation of the potential usefulness of the library?
Very useful. I've implemented similar functionality many times, it would be useful to have it in one place.
- Did you try to use the library? With what compiler? Did you have any problems?
I did not compile any code.
- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
A few hours reading the code and the docs.
- Are you knowledgeable about the problem domain?
I believe so.
Please always state in your review whether you think the library should be accepted as a Boost library.
Yes, I think the library should be accepted on condition that the documentation is improved. The current docs are insufficient. I have outlined many other notes and suggestions in my review but none of them render the library useless to be rejected. However, I'd like to kindly ask Glen to address these issues. Lastly, I'd like to thank Glen for this submission and Ahmed for managing the review.
AMDG On 04/12/2014 06:45 AM, Andrey Semashev wrote:
1. Please, rewrite it in QuickBook. Not only it ensures the look and feel common to other Boost libraries, it also adds other useful features, such as Doxygen integration and importing the actual compilable code which is useful for examples.
FWIW, the QuickBook look and feel primarily from boostbook.css rather than QuickBook per se. In Christ, Steven Watanabe
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: 12 April 2014 15:40 To: boost@lists.boost.org Subject: Re: [boost] Boost.Align review begins today
AMDG
On 04/12/2014 06:45 AM, Andrey Semashev wrote:
1. Please, rewrite it in QuickBook. Not only it ensures the look and feel common to other Boost libraries, it also adds other useful features, such as Doxygen integration and importing the actual compilable code which is useful for examples.
I can't comment on the code (except that it looks a sensible tidying up and extension of existing stuff in Boost). But agree about the docs - OK but not beautiful yet. But then I'm sure you are tired from grappling with the code ;-) If your library if accepted, I am willing to shift your docs into Quickbook with Doxygen format for you to get you right up the learning curve quickly. A few hours should do it, and you can then refine to your hearts content (or until you tire!). Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 01539 561830
On Sat, Apr 12, 2014 at 10:12 AM, Paul A. Bristow wrote:
If your library if accepted, I am willing to shift your docs into Quickbook with Doxygen format for you to get you right up the learning curve quickly.
A few hours should do it, and you can then refine to your hearts content (or until you tire!).
Paul
Wow, thank you Paul - while I did make a start on it already, I'm very tempted to accept -- though I shouldn't in good conscience infringe upon your time like that. Glen
On Sat, Apr 12, 2014 at 6:45 AM, Andrey Semashev wrote:
Yes, I think the library should be accepted on condition that the documentation is improved. The current docs are insufficient.
I have outlined many other notes and suggestions in my review but none of them render the library useless to be rejected. However, I'd like to kindly ask Glen to address these issues.
Again, thank you for the help, Andrey.
I've started on documentation improvements (including migration to
QuickBook) today. On Monday I'll use the Develop branch to start
addressing some of the review comments, while leaving the Master
branch untouched to not disrupt anyone else reviewing it.
Glen
On Sat, Apr 12, 2014 at 6:45 AM, Andrey Semashev
On Friday 11 April 2014 20:48:02 Ahmed Charles wrote:
Hi all,
The review of Boost.Align by Glen Fernandes commences today, Friday, 11 April, and concludes Sunday, 20 April.
- What is your evaluation of the design?
Overall design looks mostly ok with some reservations below.
1. I'm not sure why some public symbols (align(), aligned_alloc(), etc) are defined in the detail namespace. It would probably be better to move them to the boost::alignment namespace. The reason I'm mentioning this is that the detail namespace will come up in compiler errors and linkage symbols, which might be inconvenint. 2. I think, it's not a good idea to import all Boost.Align symbols into boost:: namespace. I could probably agree with importing align() and aligned_alloc()/aligned_free() but not more sohpisticated things. Boost namespace becomes more cluttered as it is. I'm open to discussion on this topic. 3. It might be a good idea to provide separate headers with forward declarations of aligned_allocator and aligned_allocator_adaptor. It's not a mandatory requirement but I think the headers would be usefult in some cases. 4. aligned_allocator_adaptor relies heavily on constructing/destroying the underlying allocator on every allocation/deallocation. This is fine in most cases, except when: (a) the allocator is not stateless and the conversion to CharAlloc actually takes time and (b) when the allocator constructor can throw (this breaks deallocate()). I'm not sure how legitimate it would be to use such an allocator with the adaptor but wouldn't it be better to just derive from CharAlloc in the first place? You don't need the original Allocator anyway. I know you followed scoped_allocator_adaptor design but I think its use case is sufficiently different.
- What is your evaluation of the implementation?
Mostly ok with the following notes:
1. is_alignment should be marked constexpr and noexcept. As well as is_aligned. 2. I think, in many headers you're missing #include <cstddef> for std::size_t. This at least concerns aligned_alloc*.hpp and align.hpp headers. 3. aligned_alloc_android.hpp and aligned_alloc_sunos.hpp are essentially the same. Suggest leaving just a single aligned_alloc_memalign.hpp which can be used on all platforms where the result of memalign() can be safely passed to free(). 4. aligned_alloc() and aligned_free() should be marked noexcept. align() could also probably be marked, although the Standard does not define it as noexcept. 5. Empty constructors in aligned_allocator should probably be defaulted. You can use BOOST_DEFAULTED_FUNCTION to achieve portability. 6. aligned_allocator.hpp and aligned_allocator_adaptor.hpp are missing #include <new> for placement new and std::bad_alloc. 7. In aligned_allocator<T>::allocate(), why the hint is defined as aligned_allocator<void>::const_pointer and not just const void*? You unnecessarily instantiate aligned_allocator here. 8. aligned_allocator<T>::max_size() should be constexpr and noexcept. address(), deallocate() and comparison opereators should be noexcept. destroy() should be conditionally noexcept. 9. Suggest using BOOST_STATIC_ASSERT_MSG instead of BOOST_STATIC_ASSERT to provide better diagnostics. 10. is_alignment and is_power_of_2 are used for the same purpose yet are named differently. I think it'd be better to rename is_power_of_2 to something like is_valid_alignment_static (while is_alignment could be is_valid_alignment). There tools could be defined in a single header. Also, if constexpr is supported is_valid_alignment_static can be implemented in terms of is_valid_alignment. 11. In max_count_of.hpp, replace static_caststd::size_t(-1) with ~static_caststd::size_t(0). 12. In aligned_allocator_adaptor<T>::deallocate(), you attempt to reinterpret_cast pointer to CharPtr*. This may fail, if pointer is not a raw pointer type. Suggest to perform the cast in the more generic way, like you do in allocate(): reinterpret_cast
(detail::addressof(*memory)). 13. Feature request: Please, provide aligned_deleter function object in a separate header. The function object should call aligned_free() to free memory and can be used with unique_ptr. This pretty much is done in one of the examples in the docs. - What is your evaluation of the documentation?
Rather poor:
1. Please, rewrite it in QuickBook. Not only it ensures the look and feel common to other Boost libraries, it also adds other useful features, such as Doxygen integration and importing the actual compilable code which is useful for examples. 2. It might be worthwhile to describe the differences between C11 and Boost.Align aligned_alloc() to avoid confision. Aside from aligned_free(), Boost.Align aligned_alloc() has weaker requirements on the size argument. 3. I wonder if quoting the Standard violates any copyrights. I'm not a lawyer. In any case, even from a learning user standpoint it might be better to use a simpler language in the docs. A reference to the Standard (draft) could be provided as well. 4. There is actually no documentation to review except for the reference section. I know the library is small and most basic things are easy to grasp for an educated programmer. But nevertheless, a few examples with description wouldn't harm, especially involving allocators. FWIW, aligned_allocator and aligned_allocator_adaptor are new things in C++ and should be properly documented. 5. The Synopsis section does not represent any particular header of the library. I'd rather see a separate synopsis sections for every header. In fact, Doxygen provides mostly what is needed for the reference section. 6. The reference section should be placed near the end of the documentation. The typical reading goes Introduction -> Tutorial -> Detailed description -> Reference. Of course, your docs can omit some of these parts due to the library simplicity, but the overall structure should be something like that. Also, it's easier to read if the sections are of different pages.
All in all, most of the structural and aesthetical issues should be resolved by moving to QuickBook. It shouldn't be difficult given the amount of the hand-written docs. The reference could be auto-generated by Doxygen. What is left is a proper description for the components and Doxygen comments.
- What is your evaluation of the potential usefulness of the library?
Very useful. I've implemented similar functionality many times, it would be useful to have it in one place.
- Did you try to use the library? With what compiler? Did you have any problems?
I did not compile any code.
- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
A few hours reading the code and the docs.
- Are you knowledgeable about the problem domain?
I believe so.
Please always state in your review whether you think the library should be accepted as a Boost library.
Yes, I think the library should be accepted on condition that the documentation is improved. The current docs are insufficient.
I have outlined many other notes and suggestions in my review but none of them render the library useless to be rejected. However, I'd like to kindly ask Glen to address these issues.
Lastly, I'd like to thank Glen for this submission and Ahmed for managing the review.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On Saturday 12 April 2014 17:45:33 you wrote:
13. Feature request: Please, provide aligned_deleter function object in a separate header. The function object should call aligned_free() to free memory and can be used with unique_ptr. This pretty much is done in one of the examples in the docs.
Actually, I should clarify this. aligned_deleter should be not quite the same as in the docs but rather: struct aligned_deleter { typedef void result_type; template< typename T > result_type operator() (T* p) const BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(p->~T())) { p->~T(); boost::aligned_free(p); } }; Note that the deleter is not a template. The point is not to duplicate the pointee type in the unique_ptr specialization.
2014-04-12 7:48 GMT+04:00 Ahmed Charles
The review of Boost.Align by Glen Fernandes commences today, Friday, 11 April, and concludes Sunday, 20 April.
Please always state in your review whether you think the library should be accepted as a Boost library.
Library must be included into the Boost, after minor improvements.
- What is your evaluation of the design?
Good.
- What is your evaluation of the implementation?
Andrey Semashev already pointed out most of the issues. I'd like to add the following: 1) Looks like include/boost/align/detail/aligned_alloc.hpp in worst case uses more memory than required // Looks like we can extract 1 from n1, // because boost::align in worst case will add // (alignment - 1) bytes. std::size_t n1 = size + alignment; 2) BOOST_NOEXCEPT is missing all around the library. This is essential for copy constructors and gives user more info about method's behavior. 3) Feature request: aligned_allocator_adaptor won't work with allocators from Boost.Interprocess. I'd love to this this resolved. This may require additional boost::alignment::align overload for pointer types used in Boost.Interprocess and a few minor fixes to aligned_allocator_adaptor. 4) There's no tests for aligned_allocator_adaptor with stateful allocators. Please add some more tests. 5) Use boost::throw_exception(e) instead of throw e. This will make Align library usable even with exceptions disabled.
- What is your evaluation of the documentation?
OK. With help of Paul A. Bristow docs will become perfect. - What is your evaluation of the potential usefulness of the library?
Useful. Was missing such functionality a few weeks ago.
- Did you try to use the library? With what compiler? Did you have any problems?
No, just looked through the sources and docs.
- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
Spend more than two hours reading the source codes and docs.
- Are you knowledgeable about the problem domain?
I do know the theory and used a self-made aligned_alloc a few times. -- Best regards, Antony Polukhin
Antony, thank you. I've updated the code in the develop branch to address much of the review feedback. Source: http://github.com/glenfe/align/tree/develop 1. Now you can include boost/align/<header>.hpp which only puts identifiers in the "boost::alignment::" namespace. If you include boost/align.hpp then you will get those identifiers in the "boost::" namespace. 2. The generic (non-platform specific) aligned_alloc implementation was changed to be more conservative in memory allocations. In addition to allocating alignment-1 extra bytes (instead of alignment extra bytes), it uses std::memcpy to write or read the original pointer (instead of rounding up alignment to alignof(void*) bytes). 3. The generic (non-platform specific) aligned_alloc implementation was changed to not be vulnerable to overflow. 4. For aligned_alloc, align, is_aligned, these are now in the "alignment::" namespace (and not in the "alignment::detail::" namespace) 5. The aligned_allocator_adaptor implementation was changed to not be vulnerable to overflow 6. Used BOOST_NOEXCEPT where appropriate. 7. Used BOOST_CONSTEXPR where appropriate. 8. Used boost::throw_exception instead of throw. 9. Added aligned_delete deleter to the library. 10. Used stateful allocator in the aligned_allocator_adaptor unit tests. ... and various other changes for the minor feedback points. Best, Glen
On Thu, Apr 17, 2014 at 10:57 PM, Glen Fernandes
2. The generic (non-platform specific) aligned_alloc implementation was changed to be more conservative in memory allocations. In addition to allocating alignment-1 extra bytes (instead of alignment extra bytes), it uses std::memcpy to write or read the original pointer (instead of rounding up alignment to alignof(void*) bytes).
I'm not sure this is a good idea. Given that pointer size is 4 or 8 bytes (with the same alignment) on modern platforms and that the native malloc alignment is also 8 or 16 (on 32 and 64-bit platforms) already, you don't save anything. No sane memory allocator will allow you to allocate 1 byte at alignment 1 for example, it'll be 8 bytes at least. OTOH, I've seen cases when the compiler was not able to optimize away memcpy. I think rounding up the alignment was the right thing to do.
On Thu, Apr 17, 2014 at 1:44 PM, Andrey Semashev wrote:
I'm not sure this is a good idea. Given that pointer size is 4 or 8 bytes (with the same alignment) on modern platforms and that the native malloc alignment is also 8 or 16 (on 32 and 64-bit platforms) already, you don't save anything. No sane memory allocator will allow you to allocate 1 byte at alignment 1 for example, it'll be 8 bytes at least. OTOH, I've seen cases when the compiler was not able to optimize away memcpy. I think rounding up the alignment was the right thing to do.
I see. Updated accordingly. (And merged to master) Glen
On Fri, Apr 11, 2014 at 08:48:02PM -0700, Ahmed Charles wrote:
The review of Boost.Align by Glen Fernandes commences today, Friday, 11 April, and concludes Sunday, 20 April. Please always state in your review whether you think the library should be accepted as a Boost library.
I believe that the Align library should be accepted into Boost without any conditional requirements from my side.
Additionally, please consider giving feedback on the following general topics:
- What is your evaluation of the design?
The aligned allocation/destruction functions are similiar in shape to the platform specific functions with similiar names. Judging by the documentation, the allocators and functions have as natural interfaces as possible, which is good.
- What is your evaluation of the implementation?
I've skimmed the implementation and no apparent madness stands out.
- What is your evaluation of the documentation?
Documentation as it currently stands needs some Boostification, but I believe that has been addressed already. I find the standardese-like reference readable.
- What is your evaluation of the potential usefulness of the library?
This library is very useful to anyone that ever has needed to deal with alignment, saving them from adapting and reinventing the facilities present in the library.
- Did you try to use the library? With what compiler? Did you have any problems?
I ran the bundled tests with a set of compilers with no additional flags, with Align implanted into a modular Boost checkout. Works perfectly: GCC 4.6.3, Intel 13.0, Intel 13.1 Compiler errors: PGI 13.10, PGI 14.3 (needed to modify Boost.Build to avoid linker failures) A lot of ambiguities like "aligned_allocator_adaptor_test.cpp", line 31: error: "allocator" is ambiguous Intel 12.0 Breaks in Boost.Config on __int128, so not really Align's fault. Runtime errors: PSC 5, may be due to site customizations of the toolchain so may be disregarded, I have to look more into it. is_aligned_test.cpp fails intermittently for sizes 128, 64, and sometimes 32. is_aligned_test.cpp(44): test 'boost::alignment::is_aligned(32, &s[0])' failed in function 'int main()' is_aligned_test.cpp(49): test 'boost::alignment::is_aligned(64, &s[0])' failed in function 'int main()' is_aligned_test.cpp(54): test 'boost::alignment::is_aligned(128, &s[0])' failed in function 'int main()' Fails 'align_test.cpp' assertions on lines 23, 25, 31, 32, 33, 40, 42; once for 64 and once for 128 bytes. Sadly SunStudio and VisualAge are out of my reach at the moment, checking out modular Boost on those filesystems would take days. I can provide logs on request.
- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
An evening skimming and reflecting on the documentation and intended semantics, a morning running the test suites on any compilers I could reach.
- Are you knowledgeable about the problem domain?
I've reinvented most facilities of this library in more or less horrible ways in the past. -- Lars Viklund | zao@acc.umu.se
On Sat, Apr 19, 2014 at 3:38 AM, Lars Viklund wrote:
I believe that the Align library should be accepted into Boost without any conditional requirements from my side.
Lars, thank you. For PGI, I should probably just avoid using the identifier 'allocator' in tests. I'll look more into PSC also. Cheers, Glen
On Fri, Apr 11, 2014 at 8:48 PM, Ahmed Charles
Hi all, Please always state in your review whether you think the library should be accepted as a Boost library.
This library should be accepted as a Boost library.
- What is your evaluation of the design?
Solid and follows existing practices.
- What is your evaluation of the implementation?
The implementation is good and clean. There is one issue in that detecting the alignment of a pointer is done using implementation defined behaviour. But since every compiler implements this the same way, I think it's acceptable.
- What is your evaluation of the documentation?
The documentation is very readable and complete.
- What is your evaluation of the potential usefulness of the library?
I see quite a few use cases for this library and that it adds some much needed functionality that has yet to make it into the standard.
- Did you try to use the library? With what compiler? Did you have any problems?
No.
- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
Spent about an hour reading the code and docs.
- Are you knowledgeable about the problem domain?
I'm quite knowledgeable about alignment in C++. I presented at C++Now about the changes to alignment in C++11 and the remaining problems we need to fix. - Michael Spencer
On 04/12/2014 05:48 AM, Ahmed Charles wrote:
Please always state in your review whether you think the library should be accepted as a Boost library.
This library should be unconditionally accepted.
- What is your evaluation of the design?
Good design. Good compliance/integration with std.
- What is your evaluation of the implementation?
Good quality. Use Boost.Predef to check for pre-defined macros.
- What is your evaluation of the documentation?
The documentation of the examples is too meager. Please add a description of the purpose of each example, so that people can assess if the example is relevant to them before they start deciphering the code.
- What is your evaluation of the potential usefulness of the library?
Alignment is a recurring task, so the library is useful.
- Did you try to use the library? With what compiler? Did you have any problems?
No.
- How much effort did you put into your evaluation? A glance? A quick reading? In-depth study?
I have spent a couple of hours in total looking at the code and the documentation.
- Are you knowledgeable about the problem domain?
Adequately.
----------------------------------------
Date: Sun, 20 Apr 2014 20:52:31 +0200 From: breese@mail1.stofanet.dk To: boost@lists.boost.org Subject: Re: [boost] Boost.Align review begins today
- What is your evaluation of the implementation?
Good quality.
Use Boost.Predef to check for pre-defined macros.
Just curious, is this a suggestion of something that should be done but isn't?
On Sun, Apr 20, 2014 at 11:52 AM, Bjorn Reese wrote:
This library should be unconditionally accepted.
Bjorn, thank you.
The documentation of the examples is too meager.
I've prepared improvements to the documentation based on your (and everyone else's) feedback that I will provide to Paul, who has generously volunteered to help create the Quickbook files for, if the library is accepted. Glen
On Fri, 11 Apr 2014 20:48:02 -0700, Ahmed Charles
Please always state in your review whether you think the library should beaccepted as a Boost library.
No. The author has unfortunately not responded to a majority of questions and concerns I had brought up. (Note: this is solely about a lack of response, and not any disagreements on the direction of library which I may have with the author.) Some of the questions and concerns were quite trivial and non-controversial, such as: 1. Documentation. 1.1) The documentation uses both C and C++ conventions in documenting function semantics, why not normalize on C++ conventions? 1.2) Why isn't "is_aligned" documented to note that a precondition on its "alignment" parameter is that it should be a power of 2? 1.3) There are overloads of aligned_allocator::construct in the header file which are not accounted for in the documentation. 1.4) The following C++03 variant is missing from the documentation: "explicit aligned_allocator_adaptor(const A& alloc)" 1.5) Why not document the reason why even though aligned_allocator_adaptor can be used with smart pointers it will only expose raw pointers? 2. Design 2.1) "aligned_allocator_adaptor::base_allocator()" reads more intuitively than "aligned_allocator_adaptor::allocator()". The latter forces me ask "which allocator?". 3. Implementation 3.1) Why not reuse boost::static_unsigned_max in max_align? 3.2) Why not the more readable "boost::integer_traitsstd::size_t::const_max" instead of the less readable "~static_caststd::size_t(0)"? 3.3) is_alignment and is_alignment_const duplicate logic, can't they be merged into the same header and share that logic via a macro? 3.4) When not capturing the return values of functions, they should be explicitly disgarded by casting the function call to void so as to avoid compiler warnings. (This pertains to calls to detail::align.) 3.5) The variable "value" is a universal reference in "void aligned_allocator::construct(U* memory, U&& value)" and should not be moved, rather it should be forwarded. 3.6) aligned_allocator_adaptor::allocate overloads share a lot of functionality, why can't that functionality be factored out into a common function? 3.7) There are some functions that have three or four 1 and 2 letter variable names. I find this unprofessional. These variables can easily be given descriptive names. My biggest concern is item 3.5, unless I'm wrong, that's a silent and dangerous bug waiting to happen. I'm not going to bring up any radical ideas I put forward, but I will bring up the issue I had with aligned_allocator_adaptor deriving from its adapted-to-type. For reasons noted earlier I think this is a mistake, and the feedback from the author that the standard scoped_allocator_adaptor does a similar thing still does not justify this design decision IMO.
What is your evaluation of the design?
I don't have any real issues with it except for what I have stated previously in this message.
What is your evaluation of the implementation?
Overall it does what it set out to do. But as noted previously in this message, there are a plethora of 1 and 2 letter variables names in some functions that can easily be replaced by more descriptive names, there is code duplication where there doesn't conceptually need to be any, and I think there is a dangerous bug lurking in the code.
What is your evaluation of the documentation?
As noted in previous messages I think it can be better formatted and structured. As noted in previously in this message I think there are omissions and think it should be normalized on C++ documentation conventions.
What is your evaluation of the potential usefulness of the library?
I never personally had a use for its functionality, therefore I don't feel qualified to give an answer.
Did you try to use the library? With what compiler? Did you have any problems?
No.
How much effort did you put into your evaluation? A glance? A quick reading?In-depth study?
An in-depth study of the implementation and documentation. I wanted to but did not get around to reviewing the accompanying tests. Though, one thing I wanted to point out is that there should be a smart pointer test for aligned_allocator_adaptor since it does claim to work with smart pointer allocators.
Are you knowledgeable about the problem domain?
I know just enough to review the library.
On Sunday 20 April 2014 21:46:34 Mostafa wrote:
3. Implementation 3.1) Why not reuse boost::static_unsigned_max in max_align? 3.2) Why not the more readable "boost::integer_traitsstd::size_t::const_max" instead of the less readable "~static_caststd::size_t(0)"?
Since that was my suggestion, I'll comment on that. I'm aware of Boost.Integer but still suggested the "~static_caststd::size_t(0)" variant to avoid the dependency and integer_traits template instantiation cost. integer_traits.hpp header is considerably heavier to include than the max_count_of.hpp. I believe static_unsigned_max is not used in max_align.hpp for the same reasons. IMO the current code in Boost.Align is quite readable as it is and using Boost.Integer primitive wouldn't improve readability too much to justify the costs.
On Sun, 20 Apr 2014 22:52:31 -0700, Andrey Semashev
On Sunday 20 April 2014 21:46:34 Mostafa wrote:
3. Implementation 3.1) Why not reuse boost::static_unsigned_max in max_align? 3.2) Why not the more readable "boost::integer_traitsstd::size_t::const_max" instead of the less readable "~static_caststd::size_t(0)"?
Since that was my suggestion, I'll comment on that. I'm aware of Boost.Integer but still suggested the "~static_caststd::size_t(0)" variant to avoid the dependency and integer_traits template instantiation cost. integer_traits.hpp header is considerably heavier to include than the max_count_of.hpp. I believe static_unsigned_max is not used in max_align.hpp for the same reasons.
IMO the current code in Boost.Align is quite readable as it is and using Boost.Integer primitive wouldn't improve readability too much to justify the costs.
Fair enough. Then that should be documented in the code. It's the first question that anyone familiar with Boost will ask when reviewing the code, and will help prevent future maintainers from "simplifying" it. (IMO, reinventing the wheel should require a good reason and that reason should be documented. Else some people will ask why and other people will be tempted to refactor code to use the existing wheel.)
Hi Mostafa, My apologies for the lack of response; I was anticipating a conclusion to your review (in the form of the response to those five questions and a vote), not realizing that you were awaiting a reply from me first. As always, thank you for providing feedback. On Sun, Apr 20, 2014 at 9:46 PM, Mostafa wrote:
1. Documentation.
All the feedback about documentation seems reasonable, and I will address it when the documentation is rewritten.
2.1) "aligned_allocator_adaptor::base_allocator()" reads more intuitively than "aligned_allocator_adaptor::allocator()". The latter forces me ask "which allocator?".
Just a preference for the identifiers "allocator" or "inner_allocator" there, but the latter may lead people to think about the scoped_allocator_adaptor interpretation of inner/outer. I'll consider renaming it to "base_allocator".
3.1) Why not reuse boost::static_unsigned_max in max_align? 3.2) Why not the more readable "boost::integer_traitsstd::size_t::const_max" instead of the less readable "~static_caststd::size_t(0)"?
Both were to avoid a dependency on Boost.Integer for what are trivial detail types. The library design has preferred minimizing those dependencies in general (e.g. it depends on boost::addressof only if a conforming std::addressof is not available).
3.3) is_alignment and is_alignment_const duplicate logic, can't they be merged into the same header and share that logic via a macro?
Not entirely happy with the idea of using a macro to reduce that duplication (at least not for these trivial detail helpers).
3.4) When not capturing the return values of functions, they should be explicitly disgarded by casting the function call to void so as to avoid compiler warnings. (This pertains to calls to detail::align.)
While I haven't used that in the other Boost library I've contributed to (nor seen it used much in other Boost code), I'm not opposed to it.
3.5) The variable "value" is a universal reference in "void aligned_allocator::construct(U* memory, U&& value)" and should not be moved, rather it should be forwarded.
The construct overloads were changed (a few hours ago).
3.6) aligned_allocator_adaptor::allocate overloads share a lot of functionality, why can't that functionality be factored out into a common function?
Sure; this is something I think I can look into doing. Glen
On Sun, 20 Apr 2014 23:09:42 -0700, Glen Fernandes
Hi Mostafa,
My apologies for the lack of response; I was anticipating a conclusion to your review (in the form of the response to those five questions and a vote), not realizing that you were awaiting a reply from me first. As always, thank you for providing feedback.
[snip] No problem. I find all your replies to be reasonable. The only point which wasn't addressed was item 3.7. It may seem trivial, but clearly and correctly named variables not only explicitly express the author's intent (making the code easier to maintain), they also make it a lot easier to read and understand. Nonetheless I do not see this as an obstruction to reviewing my review.
----------------------------------------
To: boost@lists.boost.org From: mostafa_working_away@yahoo.com Date: Sun, 20 Apr 2014 21:46:34 -0700 Subject: Re: [boost] Boost.Align review begins today
On Fri, 11 Apr 2014 20:48:02 -0700, Ahmed Charles
wrote: (Ahmed, a piece of advice, the review period doesn't end until the end of the review date for all time zones.)
Sorry for believing it was GMT/UTC based.
Please always state in your review whether you think the library should beaccepted as a Boost library.
No. The author has unfortunately not responded to a majority of questions and concerns I had brought up.
Thanks for your review. I can send out an update with any additional conditions we can agree on, since the result is still conditional acceptance even with your vote, if you would like. Unfortunately, your initial review didn't clearly state a vote, so it wasn't included in the initial summary.
(Note: this is solely about a lack of response, and not any disagreements on the direction of library which I may have with the author.)
I believe the spirit of the review process is to mostly review the code and not the author.
Some of the questions and concerns were quite trivial and non-controversial, such as:
1. Documentation. 1.1) The documentation uses both C and C++ conventions in documenting function semantics, why not normalize on C++ conventions? 1.2) Why isn't "is_aligned" documented to note that a precondition on its "alignment" parameter is that it should be a power of 2? 1.3) There are overloads of aligned_allocator::construct in the header file which are not accounted for in the documentation. 1.4) The following C++03 variant is missing from the documentation: "explicit aligned_allocator_adaptor(const A& alloc)" 1.5) Why not document the reason why even though aligned_allocator_adaptor can be used with smart pointers it will only expose raw pointers?
These points seem reasonable to address with the work that will happen on the documentation.
2. Design 2.1) "aligned_allocator_adaptor::base_allocator()" reads more intuitively than "aligned_allocator_adaptor::allocator()". The latter forces me ask "which allocator?".
I'd agree with this suggestion.
3. Implementation 3.1) Why not reuse boost::static_unsigned_max in max_align? 3.2) Why not the more readable "boost::integer_traitsstd::size_t::const_max" instead of the less readable "~static_caststd::size_t(0)"?
I think I agree with the sentiment that these are simple enough use cases that additional dependencies aren't required. Though, it seems that there is already a dependency on Boost.Integer, so that makes me more on the fence.
3.3) is_alignment and is_alignment_const duplicate logic, can't they be merged into the same header and share that logic via a macro? 3.4) When not capturing the return values of functions, they should be explicitly disgarded by casting the function call to void so as to avoid compiler warnings. (This pertains to calls to detail::align.) 3.5) The variable "value" is a universal reference in "void aligned_allocator::construct(U* memory, U&& value)" and should not be moved, rather it should be forwarded.
I talked to Glen about this and proposed a solution that doesn't have this issue.
3.6) aligned_allocator_adaptor::allocate overloads share a lot of functionality, why can't that functionality be factored out into a common function? 3.7) There are some functions that have three or four 1 and 2 letter variable names. I find this unprofessional. These variables can easily be given descriptive names.
My biggest concern is item 3.5, unless I'm wrong, that's a silent and dangerous bug waiting to happen.
I'm not going to bring up any radical ideas I put forward, but I will bring up the issue I had with aligned_allocator_adaptor deriving from its adapted-to-type. For reasons noted earlier I think this is a mistake, and the feedback from the author that the standard scoped_allocator_adaptor does a similar thing still does not justify this design decision IMO.
What is your evaluation of the design?
I don't have any real issues with it except for what I have stated previously in this message.
What is your evaluation of the implementation?
Overall it does what it set out to do. But as noted previously in this message, there are a plethora of 1 and 2 letter variables names in some functions that can easily be replaced by more descriptive names, there is code duplication where there doesn't conceptually need to be any, and I think there is a dangerous bug lurking in the code.
What is your evaluation of the documentation?
As noted in previous messages I think it can be better formatted and structured. As noted in previously in this message I think there are omissions and think it should be normalized on C++ documentation conventions.
What is your evaluation of the potential usefulness of the library?
I never personally had a use for its functionality, therefore I don't feel qualified to give an answer.
Did you try to use the library? With what compiler? Did you have any problems?
No.
How much effort did you put into your evaluation? A glance? A quick reading?In-depth study?
An in-depth study of the implementation and documentation. I wanted to but did not get around to reviewing the accompanying tests. Though, one thing I wanted to point out is that there should be a smart pointer test for aligned_allocator_adaptor since it does claim to work with smart pointer allocators.
Are you knowledgeable about the problem domain?
I know just enough to review the library.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
On Sun, 20 Apr 2014 23:15:02 -0700, Ahmed Charles
----------------------------------------
To: boost@lists.boost.org From: mostafa_working_away@yahoo.com Date: Sun, 20 Apr 2014 21:46:34 -0700 Subject: Re: [boost] Boost.Align review begins today
On Fri, 11 Apr 2014 20:48:02 -0700, Ahmed Charles
wrote: (Ahmed, a piece of advice, the review period doesn't end until the end of the review date for all time zones.)
Sorry for believing it was GMT/UTC based.
Please always state in your review whether you think the library should beaccepted as a Boost library.
No. The author has unfortunately not responded to a majority of questions and concerns I had brought up.
Thanks for your review. I can send out an update with any additional conditions we can agree on, since the result is still conditional acceptance even with your vote, if you would like. Unfortunately, your initial review didn't clearly state a vote, so it wasn't included in the initial summary.
(Note: this is solely about a lack of response, and not any disagreements on the direction of library which I may have with the author.)
I believe the spirit of the review process is to mostly review the code and not the author.
My intention was to simply state the fact that without sufficient answers to requested information my vote would have to default to a "no".
On Sun, 20 Apr 2014 21:46:34 -0700, Mostafa
On Fri, 11 Apr 2014 20:48:02 -0700, Ahmed Charles
wrote: (Ahmed, a piece of advice, the review period doesn't end until the end of the review date for all time zones.)
Please always state in your review whether you think the library should beaccepted as a Boost library.
No. The author has unfortunately not responded to a majority of questions and concerns I had brought up.
(Note: this is solely about a lack of response, and not any disagreements on the direction of library which I may have with the author.)
[snip] Based upon further feedback from the author I change my vote to a conditional yes. The conditions being what issues the author decided to address and what steps he agreed to take here: http://article.gmane.org/gmane.comp.lib.boost.devel/250396 Mostafa
participants (10)
-
Ahmed Charles
-
Andrey Semashev
-
Antony Polukhin
-
Bjorn Reese
-
Glen Fernandes
-
Lars Viklund
-
Michael Spencer
-
Mostafa
-
Paul A. Bristow
-
Steven Watanabe