[opensource-dev] Review Request: STORM-864: As as developer, I would like an object oriented wrapper to make safe use of memory pools easier

Aleric Inglewood Aleric.Inglewood at gmail.com
Sat Jan 29 07:30:26 PST 2011



> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > doc/contributions.txt, lines 64-89
> > <http://codereview.secondlife.com/r/99/diff/1/?file=481#file481line64>
> >
> >     This sorting of contribution entries is not related the issue at hand and should thus happen in a separate commit, if at all. Current policy is to not re-sort existing entries at all, to not mislead Oz' metric gathering tools.
> >     
> >     See Oz' comment on https://codereview.secondlife.com/r/78/ and his clarification in this thread:
> >     https://lists.secondlife.com/pipermail/opensource-dev/2011-January/thread.html#5329
> >     
> >     I guess this policy might change again once the tools have been made more robust. Please postpone re-sorting jira entries until then.

In the meantime Oz announced that he improved his script so this shouldn't be an issue anymore.
Also, you and me are working on https://github.com/AlericInglewood/contribmerge which will
address this issue once and for all ;) (which was actually triggered by this comment).


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llaprpool.h, line 72
> > <http://codereview.secondlife.com/r/99/diff/1/?file=491#file491line72>
> >
> >     I think this comment line is noteworthy enough to show it on doxygen, too. Maybe even within an \attention or \warning .

I was under the impression that,

//! Short comment
//
// Still part of doxygen comment.

But you are right, this is not the case.
I will change top level (doxygen) comments to

/** Short comment
 *
 * Still part of doxygen comment.
 */

where I didn't already, which appears to
be a frequently used format in the viewer
code, and for inline multi-line comments,

/// This is a comment
/// of two lines or so.

As seems to be the other choice of
doxygen format used in the viewer code
elsewhere.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llaprpool.h, line 90
> > <http://codereview.secondlife.com/r/99/diff/1/?file=491#file491line90>
> >
> >     Parameters and their behavior can be documented in doxygen with \param .
> >     
> >     See http://www.doxygen.nl/commands.html#cmdparam

Yes I know... but this isn't really a general comment about the meaning of the parameter, but about the meaning of the default parameter (which looks rather strange). I decided not to write a full-blown doxygen API for this class, since that is done nowhere. Most code doesn't have any documentation, let alone doxygen documentation, and the rest of this class doesn't describe each parameter either. On top of that, the choice of variable names is rather self-explanatory...)


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llaprpool.h, line 111
> > <http://codereview.secondlife.com/r/99/diff/1/?file=491#file491line111>
> >
> >     This could be made a doxygen comment.

Done.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llaprpool.h, lines 186-188
> > <http://codereview.secondlife.com/r/99/diff/1/?file=491#file491line186>
> >
> >     This should probably be a doxygen comment.

I deliberately didn't make that a doxygen comment because, although it has to be public, it's shouldn't be used elsewhere in the code (except where I already do): it has therefore no importance for anyone to know it exists, or what it does.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llaprpool.h, lines 208-216
> > <http://codereview.secondlife.com/r/99/diff/1/?file=491#file491line208>
> >
> >     Why include only the first line in doxygen?

Fixed. Now using /** ... */.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llscopedvolatileaprpool.h, lines 40-42
> > <http://codereview.secondlife.com/r/99/diff/1/?file=498#file498line40>
> >
> >     The first "it's" should be "its".

Fixed.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llscopedvolatileaprpool.h, line 44
> > <http://codereview.secondlife.com/r/99/diff/1/?file=498#file498line44>
> >
> >     Consider exposing this comment via doxygen.

Included with the comment above.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llscopedvolatileaprpool.h, line 54
> > <http://codereview.secondlife.com/r/99/diff/1/?file=498#file498line54>
> >
> >     Another candidate for a \warning or \attention ?

Okay, added @attention (I prefer the use of @).


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llthread.h, line 163
> > <http://codereview.secondlife.com/r/99/diff/1/?file=499#file499line163>
> >
> >     Another candidate for doxygen. \return could be used.

This whole file has no doxygen documentation at all. I don't think it is warranted as part of this patch to change that. This is just an API comment thus, using normal C++ comments.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llthread.h, lines 209-211
> > <http://codereview.secondlife.com/r/99/diff/1/?file=499#file499line209>
> >
> >     It looks like the #if MUTEX_DEBUG is almost redundant here. I think it will only have an effect when RELEASE_SHOW_ASSERT is set or SHOW_ASSERT has been manually set. Are you sure you want to suppress this specific assertion in these cases?

Either way... This assert would be so seriously wrong that I'm assuming it is never triggered and hence a waste of cpu.
I removed the #if MUTEX_DEBUG ... (because of your comment) because that is not really related to this assert: it doesn't really mean "debug mutexes", it means "test if some mutexes are used recursively. Note that this code is normally never used: Linden Lab's libapr is compiled with APR_HAS_THREADS, and a developer should use a libapr library compiled like that too, anyway.


> On Jan. 18, 2011, 4:30 a.m., Boroondas Gupte wrote:
> > indra/llcommon/llthread.cpp, line 289
> > <http://codereview.secondlife.com/r/99/diff/1/?file=500#file500line289>
> >
> >     Worth inlining?

I don't think so. First of all, it's only used for the debug version of a viewer where performance (at THIS level) is not an issue, secondly, it has to be available everywhere so inlining would require main_thread_id to be global and exported from libcommon (instead) and libapr headers to be included for every .cpp file (not sure, but I don't think they are currently).


- Aleric


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://codereview.secondlife.com/r/99/#review180
-----------------------------------------------------------


On Jan. 17, 2011, 7:03 p.m., Aleric Inglewood wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://codereview.secondlife.com/r/99/
> -----------------------------------------------------------
> 
> (Updated Jan. 17, 2011, 7:03 p.m.)
> 
> 
> Review request for Viewer.
> 
> 
> Summary
> -------
> 
> Please see http://jira.secondlife.com/browse/STORM-864
> 
> I made a mercurial repository available for testing here:
> 
> hg clone https://bitbucket.org/aleric/viewer-development-storm-864
> 
> From the commit message:
> 
> Introduces a LLThreadLocalData class that can be
> accessed through the static LLThread::tldata().
> Currently this object contains two (public) thread-local
> objects: a LLAPRRootPool and a LLVolatileAPRPool.
> 
> The first is the general memory pool used by this thread
> (and this thread alone), while the second is intended
> for short lived memory allocations (needed for APR).
> The advantages of not mixing those two is that the latter
> is used most frequently, and as a result of it's nature
> can be destroyed and reconstructed on a "regular" basis.
> 
> This patch adds LLAPRPool (completely replacing the old one),
> which is a wrapper around apr_pool_t* and has complete
> thread-safity checking.
> 
> Whenever an apr call requires memory for some resource,
> a memory pool in the form of an LLAPRPool object can
> be created with the same life-time as this resource;
> assuring clean up of the memory no sooner, but also
> not much later than the life-time of the resource
> that needs the memory.
> 
> Many, many function calls and constructors had the
> pool parameter simply removed (it is no longer the
> concern of the developer, if you don't write code
> that actually does an libapr call then you are no
> longer bothered with memory pools at all).
> 
> However, I kept the notion of short-lived and
> long-lived allocations alive (see my remark in
> the jira here: https://jira.secondlife.com/browse/STORM-864?focusedCommentId=235356&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-235356
> which requires that the LLAPRFile API needs
> to allow the user to specify how long they
> think a file will stay open. By choosing
> 'short_lived' as default for the constructor
> that immediately opens a file, the number of
> instances where this needs to be specified is
> drastically reduced however (obviously, any
> automatic LLAPRFile is short lived).
> 
> 
> This addresses bug STORM-864.
>     http://jira.secondlife.com/browse/STORM-864
> 
> 
> Diffs
> -----
> 
>   doc/contributions.txt 422f636c3343 
>   indra/llaudio/llaudioengine_fmod.cpp 422f636c3343 
>   indra/llaudio/llvorbisencode.cpp 422f636c3343 
>   indra/llcharacter/llbvhloader.cpp 422f636c3343 
>   indra/llcharacter/llkeyframemotionparam.cpp 422f636c3343 
>   indra/llcharacter/llstatemachine.cpp 422f636c3343 
>   indra/llcommon/CMakeLists.txt 422f636c3343 
>   indra/llcommon/llapp.cpp 422f636c3343 
>   indra/llcommon/llapr.h 422f636c3343 
>   indra/llcommon/llapr.cpp 422f636c3343 
>   indra/llcommon/llaprpool.h PRE-CREATION 
>   indra/llcommon/llaprpool.cpp PRE-CREATION 
>   indra/llcommon/llcommon.h 422f636c3343 
>   indra/llcommon/llcommon.cpp 422f636c3343 
>   indra/llcommon/llerror.h 422f636c3343 
>   indra/llcommon/llerror.cpp 422f636c3343 
>   indra/llcommon/llfixedbuffer.cpp 422f636c3343 
>   indra/llcommon/llscopedvolatileaprpool.h PRE-CREATION 
>   indra/llcommon/llthread.h 422f636c3343 
>   indra/llcommon/llthread.cpp 422f636c3343 
>   indra/llcommon/llthreadsafequeue.h 422f636c3343 
>   indra/llcommon/llthreadsafequeue.cpp 422f636c3343 
>   indra/llcommon/llworkerthread.h 422f636c3343 
>   indra/llcommon/llworkerthread.cpp 422f636c3343 
>   indra/llcrashlogger/llcrashlogger.cpp 422f636c3343 
>   indra/llimage/llimage.cpp 422f636c3343 
>   indra/llimage/llimagedimensionsinfo.cpp 422f636c3343 
>   indra/llimage/llimagej2c.cpp 422f636c3343 
>   indra/llimage/llimageworker.h 422f636c3343 
>   indra/llimage/llimageworker.cpp 422f636c3343 
>   indra/llmath/llvolumemgr.cpp 422f636c3343 
>   indra/llmessage/llares.cpp 422f636c3343 
>   indra/llmessage/llcurl.cpp 422f636c3343 
>   indra/llmessage/lliohttpserver.h 422f636c3343 
>   indra/llmessage/lliohttpserver.cpp 422f636c3343 
>   indra/llmessage/lliosocket.h 422f636c3343 
>   indra/llmessage/lliosocket.cpp 422f636c3343 
>   indra/llmessage/llmail.h 422f636c3343 
>   indra/llmessage/llmail.cpp 422f636c3343 
>   indra/llmessage/llpumpio.h 422f636c3343 
>   indra/llmessage/llpumpio.cpp 422f636c3343 
>   indra/llmessage/llurlrequest.cpp 422f636c3343 
>   indra/llmessage/message.cpp 422f636c3343 
>   indra/llmessage/tests/networkio.h 422f636c3343 
>   indra/llplugin/llplugininstance.h 422f636c3343 
>   indra/llplugin/llplugininstance.cpp 422f636c3343 
>   indra/llplugin/llpluginmessagepipe.cpp 422f636c3343 
>   indra/llplugin/llpluginprocesschild.cpp 422f636c3343 
>   indra/llplugin/llpluginprocessparent.h 422f636c3343 
>   indra/llplugin/llpluginprocessparent.cpp 422f636c3343 
>   indra/llplugin/llpluginsharedmemory.h 422f636c3343 
>   indra/llplugin/llpluginsharedmemory.cpp 422f636c3343 
>   indra/llplugin/slplugin/slplugin.cpp 422f636c3343 
>   indra/llvfs/lllfsthread.cpp 422f636c3343 
>   indra/llvfs/llvfs.cpp 422f636c3343 
>   indra/media_plugins/gstreamer010/llmediaimplgstreamer.h 422f636c3343 
>   indra/media_plugins/gstreamer010/llmediaimplgstreamer_syms.cpp 422f636c3343 
>   indra/media_plugins/webkit/linux_volume_catcher.cpp 422f636c3343 
>   indra/newview/llappviewer.h 422f636c3343 
>   indra/newview/llappviewer.cpp 422f636c3343 
>   indra/newview/llappviewerlinux.cpp 422f636c3343 
>   indra/newview/llappviewerlinux_api_dbus.cpp 422f636c3343 
>   indra/newview/llappviewermacosx.cpp 422f636c3343 
>   indra/newview/llfloateranimpreview.cpp 422f636c3343 
>   indra/newview/llmainlooprepeater.cpp 422f636c3343 
>   indra/newview/lltexturecache.h 422f636c3343 
>   indra/newview/lltexturecache.cpp 422f636c3343 
>   indra/newview/lltexturefetch.cpp 422f636c3343 
>   indra/newview/llviewermenufile.cpp 422f636c3343 
>   indra/newview/llvoavatar.cpp 422f636c3343 
>   indra/newview/llvocache.h 422f636c3343 
>   indra/newview/llvocache.cpp 422f636c3343 
>   indra/newview/llvoicevivox.cpp 422f636c3343 
>   indra/newview/llwatchdog.cpp 422f636c3343 
>   indra/newview/tests/llworldmap_test.cpp 422f636c3343 
>   indra/test/lltemplatemessagebuilder_tut.cpp 422f636c3343 
>   indra/test/message_tut.cpp 422f636c3343 
>   indra/test/test.cpp 422f636c3343 
>   indra/test_apps/llplugintest/llmediaplugintest.cpp 422f636c3343 
>   indra/viewer_components/updater/llupdateinstaller.cpp 422f636c3343 
> 
> Diff: http://codereview.secondlife.com/r/99/diff
> 
> 
> Testing
> -------
> 
> Compiles and viewer functions normally.
> 
> The new classes (LLAPRPool, LLThreadLocalData) and the LLAPRFile changes have been tested a lot more extensive, since they have been used as-is for months in imprudence and before that in my own viewer (since April). However, the patch contains changes to code elsewhere (to adapt it to the new API) that is rather new in this source tree. Note that changes with regard to LLAPRFile already have been in Snowglobe since version 1.1 (with some minor changes) including the method used to make thread-local data available.
> 
> 
> Thanks,
> 
> Aleric
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.secondlife.com/pipermail/opensource-dev/attachments/20110129/2e8c867a/attachment-0001.htm 


More information about the opensource-dev mailing list