
Alexander Nasonov wrote:
Amerio wrote:
Hello, After compiling libboost_thread-gcc-mt.so on debian/gcc-2.95.4, this so weights 195kB, while libpthread weights only 100kB. Why such a huge difference ? Isn't boost::thread meant to be as lightweight as possible ?
Try building it with Boost.Build v2 (bjam --v2 gcc release). It's only 64K because read_write_mutex.o (223K in release) is excluded from link. I don't know whether it's intentional or an oversight.
I'm afraid it's an oversight -- that's a recently added feature. I'm surprised that it adds so much to the size though, let me try here. Without read_write_mutex the size of gcc/release/shared build is 46K. With read_write_mutex the size is 136K. Wow, that's a difference! When I comment out explicit template instantiations in that source file, the library is becomes 76K. The comment says explicit instantination are needed to detect syntax errors in templates but those instantination bloat the library. BTW, I'm not sure read_write_mutex should be a template, either. Maybe, we need class polymorphic_mutex; and template<class Mutex> class concrete_polymorphic_mutex : public polymorphic_mutex { }; and read_write_mutex_impl must be implemented in terms of polymorphic_mutex? - Volodya

After compiling libboost_thread-gcc-mt.so on debian/gcc-2.95.4, this so weights 195kB [...] Without read_write_mutex the size of gcc/release/shared build is 46K. With read_write_mutex the size is 136K.
Wow, that's a difference!
When I comment out explicit template instantiations in that source file, the library is becomes 76K. The comment says explicit instantination are needed to detect syntax errors in templates but those instantination bloat the library.
Would there be any problem if I comment out the explicit instantations in this file for production code ? Are they in there *only* for syntax checking ??? In this case, what about commiting a new rev in the cvs without this ? Note : In my case, 100kB wasted is large enough to be an issue (running low on free space, embedded system)

Amerio wrote:
After compiling libboost_thread-gcc-mt.so on debian/gcc-2.95.4, this so weights 195kB [...] Without read_write_mutex the size of gcc/release/shared build is 46K. With read_write_mutex the size is 136K.
Wow, that's a difference!
When I comment out explicit template instantiations in that source file, the library is becomes 76K. The comment says explicit instantination are needed to detect syntax errors in templates but those instantination bloat the library.
Would there be any problem if I comment out the explicit instantations in this file for production code ? Are they in there only for syntax checking ???
I think that's the case. Adding #ifndef NDEBUG might be a reasonable solution. Note that if you use all of mutex types, you'll still get the code size penalty, but most likely you won't use all of them.
In this case, what about commiting a new rev in the cvs without this ?
That's up to Boost.Thread maintainers.
Note : In my case, 100kB wasted is large enough to be an issue (running low on free space, embedded system)
I understand. - Volodya

Amerio wrote:
After compiling libboost_thread-gcc-mt.so on debian/gcc-2.95.4, this so weights 195kB [...] Without read_write_mutex the size of gcc/release/shared build is 46K. With read_write_mutex the size is 136K.
Wow, that's a difference!
When I comment out explicit template instantiations in that source file, the library is becomes 76K. The comment says explicit instantination are needed to detect syntax errors in templates but those instantination bloat the library.
Would there be any problem if I comment out the explicit instantations in this file for production code ? Are they in there *only* for syntax checking ???
I think that's the case. Adding #ifndef NDEBUG might be a reasonable solution. Note that if you use all of mutex types, you'll still get the code size penalty, but most likely you won't use all of them.
In this case, what about commiting a new rev in the cvs without this ?
That's up to Boost.Thread maintainers.
Note : In my case, 100kB wasted is large enough to be an issue (running low on free space, embedded system)
I understand. - Volodya

Vladimir Prus wrote:
Would there be any problem if I comment out the explicit instantations in this file for production code ? Are they in there *only* for syntax checking ???
I think that's the case.
Correct.
Adding #ifndef NDEBUG might be a reasonable solution. Note that if you use all of mutex types, you'll still get the code size penalty, but most likely you won't use all of them.
In this case, what about commiting a new rev in the cvs without this ?
That's up to Boost.Thread maintainers.
Done. Mike
participants (3)
-
Amerio
-
Michael Glassford
-
Vladimir Prus