Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Memory overhead of blessed hashes

by LanX (Saint)
on Feb 10, 2021 at 00:55 UTC ( [id://11128161]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Memory overhead of blessed hashes
in thread Memory overhead of blessed hashes

> I know that method lookups are cached,

I remembered hearing people talking about this. That was the only possible theory left.

> but I am quite certain (from the last time I read the documentation) that that cache is associated with the package STASH, rather than each object, since it logically applies to the class (package) and is shared between all objects of that class.

Cool, that's what I needed to know! :)

> Arrays in Perl do have considerably smaller overhead than hashes, although not a factor of 10.

I did some tests for different sizes, yes it's not that dramatic - a 50% win is a very optimistic scenario.°

> changing the internal representation to arrays and using constant to name the fields is likely to help.

Well it's not my project anyway and some of my colleagues have weird strategies when it comes to optimization.

Personally I'm thinking rather in O() categories, and 50% best case wouldn't convince me to refactor.

I'd rather give Toby's suggestion for Insight-Out-Objects a shot.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) Though I'm not too sure if I got the Powershell and Windows right, since all the spared "keys" should cause a bigger impact. Will need to dig deeper. :)

  • Comment on Re^4: Memory overhead of blessed hashes

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128161]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-25 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found