[Kstars-devel] Binary star data loading accomplished in Branch!

James Bowlin bowlin at mindspring.com
Mon Jun 2 22:46:20 CEST 2008


On Mon June 2 2008, Akarsh Simha wrote:
> > make it go faster?  For example, are you still using explicit
> > StarObject constructors?
>
> I ran "blank" constructors (commented out all the freads and fseeks
> etc) and it came down to 3.18 microseconds per star on average. I
> don't think this should be much of an overhead, then. Or am I missing
> something?

This is good to know.

Using the explicit constructors is okay for now. But when we start to
do the dynamic loading, we will want to bypass the C++ constructors 
entirely and handle the memory management ourselves.  As I said before,
bypassing the constructors will start to mimic how we will load stars 
dynamically.  Remember, the StarObject constructor is *always* 
allocating memory.  It allocates memory for the StarObject.

> I think it will be too much of an effort to avoid the StarObject
> constructor, because we will have to allocate QStrings for name,
> name2, etc manually, and replace appropriate pointers with them
> etc. Otherwise, we will end up duplicating pointers as well, so all
> stars will end up with the same strings.

My plan was to have all named stars in the global files that only gets
loaded once.  The stars that get loaded dynamically should all be 
unnamed.  Until we make a PlainStar class and a NamedStar class as we
have discussed before then unnamed stars will contain pointers to the
translation of "star".  But the memcpy() of a template unnamed star 
should take care of copying these pointers automatically.

IMO, bypassing the C++ StarObject constructor is a key part of the
dynamic loading because it totally bypasses the need to free any memory.
I suppose it would be possible to overwrite one star at a time but that
still doesn't remove the requirement of bypassing the constructor.

If you want to put off bypassing the constructor for now, that's fine,
especially if the names would create an extra complication that we won't
have with the unnamed stars we are actually going to load dynamically.
But I don't know how to avoid bypassing the constructor when we do the
dynamic loading.  I'm open to ideas if you have suggestions.

I agree that bypassing the constructor might be tricky.  That is why
I'm pushing for tackling that problem ASAP.  If we run into difficulties
than we will have more time available to design around them.


-- 
Peace, James


More information about the Kstars-devel mailing list