[ANNOUNCE] MT string optimization, please try

Nathan Myers ncm-nospam@cantrip.org
Mon Apr 7 20:45:00 GMT 2003


I have posted a patch that should produce substantial performance
improvements, most especially in statically-linked multi-threaded
systems that make heavy use of std::string.

  http://gcc.gnu.org/ml/libstdc++/2003-04/msg00039.html

It should also improve performance in other applications, possibly
including even uniprocessor applications.

Please test and report results.  

Here is the draft changelog.  (Thanks to Paolo for the ping.)

Nathan Myers
ncm-nospam@cantrip.org

2003-04-07  Nathan C. Myers <ncm-nospam@cantrip.org>

        * include/bits/basic_string.{h,tcc}:
        - Avoid multi-processor bus contention on increment/decrement-and-
	test of the reference count in the empty-string object, by comparing 
        addresses first, and never touching the reference count of the empty-
        string object.  
        - Move static member _S_empty_rep_storage into basic_string<>::_Rep 
        for use by its members; but move _Rep data members into a base 
        class _Rep_base, to work around a compiler sizeof() bug.  
        - Change empty-string contructors to use _M_refdata() in place
        of _M_refcopy(), since they no longer must increment its refcount.
        - Check for the empty string in _M_destroy and in _M_leak_hard, and 
        return immediately.  The former might be unnecessary.  The latter 
        prevents begin() and end() from cloning it unnecessarily.  
        - In _M_mutate, check for the empty string and treat it as shared.
        This is necessary here because _M_mutate is sometimes called with
        all-zero arguments; in all other uses of _M_is_shared, the test comes
        out right anyhow.
        - Coincidentally, move some basic_string<> overloaded members assign, 
        append, insert, replace out of line because they are too big to 
        reasonably be inline.
        - Fix some minor indentation errors and one spelling error.
        - (Note, more improvement is possible by marking the char and wchar_t 
	instantiations of _S_empty_rep_storage as private to libstdc++.so.)



More information about the Libstdc++ mailing list