As I tried to explain, you should avoid using plain Objects to store
data if possible -- either the individual data items or the entire data
store. So don't declare myDataStore to be an Object and don't do new
Object() to put something into it.

The most efficient data store, if suitable, is an Array. If the array
has elements 0, 1, 2, ..., n-1 (i.e. isn't sparse), then it is compact
and fast. Avoid looking things up my name, as in mydataStore["mychart" +
1]. Of course, some data stores might require name lookup, in which case
you should use an Object because trying to implement your own hash table
will be slower than using Object.

As for access locks, there are none in Flash because the player isn't
multithreaded.

- Gordon


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jonathan Hirschi
Sent: Friday, January 20, 2006 7:13 PM
To: [email protected]
Subject: RE: [flexcoders] Performance question - please help!

Gordon, thanks for the response.

i guess what I was wondering was if it'd be better to
write up a class for data storage or just to use a
regular object... 

ie myDataStore:Object  and then:
 myDataStore["mychart"+1] = new Object();
then a lot more stuff and objects added... ie..
storing a ton of data...

or is it better to obfuscate this into a class

ie..
 myDataStore = new DataStore("mychart"+1);


Does it make a difference to the performance of the
application?  so for example, when using the class do
you avoid any potential access locks?  or are there no
access lock problems with either one of these?  The
problem i'm facing is that I need to be able to move a
large amount of data into the system where i could be
trying to access the same variables at the same
time... 

which brings up an at what point along the line does
variable locking take place?

so for example, if i have an extended variable
structure with sub objects and arrays, if two threads
try to update the same value, where does the locking
occur?

so for example:
  myChartObj.myarray[3].property

if two threads try to update property, does it lock
you out of myarray until the update goes through or
does it lock you out of myChartobj?  or does it only
lock property?
 
Thanks!


--- Gordon Smith <[EMAIL PROTECTED]> wrote:

> In AS3, you should declare a non-dynamic class for
> your data items
> rather than using untyped Objects. For example,
> don't use data items
> like
> 
>     { foo: 100, bar: 200 }
> 
> Instead write
> 
>     new DataItem(100, 200)
> 
> where
> 
>     class DataItem
>     {
>         function DataItem(foo:int, bar:int)
>         {
>             this.foo = foo;
>             this.bar = bar;
>         }
> 
>         var foo;
>         var bar;
>     }
> 
> A non-dynamic class like DataItem takes a lot less
> memory and you can
> access foo and bar faster on it.
> 
> A plain Object is basically a name/value dictionary
> where AS3 has to do
> a name lookup in a hash table.
> 
> By contrast, a non-dynamic class is laid out
> compactly in memory so that
> AS3 knows that foo is at offset 4 from the beginning
> of the data item in
> memory, bar is at offset 8, etc. It can then read
> and write them quickly
> without any lookup.
> 
> When you use a non-dynamic class, each int, uint,
> Boolean, and object or
> string reference will take up 4 bytes, while each
> Number will take up 8
> bytes. Each instace also has a 16-byte header for
> keeping track of what
> class it belongs to, etc. There is also some
> rounding up because the
> memory manager allocates only chunks of certain
> sizes.
> 
> - Gordon
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of JesterXL
> Sent: Friday, January 20, 2006 5:34 PM
> To: [email protected]
> Subject: Re: [flexcoders] Performance question -
> please help!
> 
> Sure; Flex 2 gets all of Flash 8's bitmap features
> with the added
> benefit of 
> a fast as nuts AVM.  As far as the data, though, not
> sure.  I've spent 3
> 
> years pushing Flash to it's limits and know where
> she breaks, but
> garbage 
> collection & tons of data, I haven't really found
> the ceiling yet in
> 8.5. 
> What I have found is "fixed in the next build", so
> it all sounds
> promising.
> 
> Flash in general has problems creating millions of
> objects because of
> the 
> overhead associated with the actual creation of
> "Object" in Flash.
> There is 
> a lot of overhead, and while it's significant for
> the hundreds, for the 
> thousands & hundreds of thousands, those bytes start
> to add up.  This is
> 
> significantly improved in 8.5.  No, I don't have
> details; basically, the
> 
> amount of overhead is significantly reduced; it was
> a big problem in
> Flash 
> hitting the "hundreds of MovieClips" limit, and now
> works great... well,
> as 
> best an alpha can be.  Besides, the way it was
> explained no sense... 
> something about byte headers, and trait objects, and
> all kinds of other 
> low-level insanity you have to be a genious to
> understand... or a Comp
> Sci 
> grad I reckon.
> 
> Max memory?  Nope; I've had Flash take up to 2 gigs
> once, it was
> awesome!
> 
> Again, haven't really pushed 8.5 yet since she isn't
> done.
> 
> As far as porting, yeah, I agree.  We've used a
> Flash 8 loaded SWF in 2 
> projects to enable file-upload, and while it works
> for the most part,
> it's 
> not eloquent, and not being eloquent ticks
> developers off.
> 
> Actually, 720,000 doesnt' sound to bad... what
> properties do these data 
> points have?  Like an ID and Name, or a long list or
> what?
> 
> As far as GC, hell no; if Adobe published how their
> GC worked, and
> changed 
> it, we'd all be f00ked.  I think Tinic's article is
> the only one that
> has 
> lasted:
>
http://www.kaourantin.net/2005/09/garbage-collection-in-flash-player-8.h
> tml
> 
> There was a comment on another article where he
> described how using 1
> member 
> variable vs. many locals was better... even though
> locals were optimized
> for 
> local registers in Flash Player 7 making functions
> faster... it's all 
> confusing.
> 
> There was an in depth article that disappeared from
> the face of Google;
> I 
> haven't seen it in 2 years, but don't know if it was
> worth reading or
> not.
> 
> Anyway, let us know about the data points; what
> their properties are, I
> can 
> run some tests when I'm done with this project.
> 
> 
> 
> ----- Original Message ----- 
> From: "Jonathan Hirschi" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Friday, January 20, 2006 5:46 PM
> Subject: Re: [flexcoders] Performance question -
> please help!
> 
> 
> So in terms of Flex 2, would it be able to possibly
> handle this amount of data effectively since it uses
> flash 8?
> 
> It sounds like you are saying that 1.5 has trouble
> displaying that amount of data because of ram usage
> problems? does that same problem exist in flex 2?
> Is there a max on how much memory flash player 7 is
> able to use effectivly?  is that max much larger in
> flash 8.5 player?
> 
> It sounds to me like it might be easier to port this
> thing to flex 2 than it would be to try and plug in
> to
> flash 8 bitmap features and draw my own graphs.
> 
> as far as data points, well, it's 200 machines * 60
> properties * 60 minutes =  720,000 data points that
> i
> need to hold in memory at any given time.  I'm also
> being asked to update the data points at a rate of
> once per minute ie 200 machines * 60 properties =
> 12,000 updated data points per minute with an
> eventual
> goal to get those updates down to once every 10
> seconds..
> 
> is that something that is doable by flex 2 even?
> They've got an app here written in mfc (c++) that
> can
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to