Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: PL_strtab/SHAREKEYS and copy-on-write leak

by dave_the_m (Monsignor)
on Jul 20, 2018 at 21:59 UTC ( #1218968=note: print w/replies, xml ) Need Help??


in reply to PL_strtab/SHAREKEYS and copy-on-write leak

NODEFAULT_SHAREKEYS as a build option is undocumented, untested, and has probably suffered much bitrot over the years.

Note that if you disable the shared key hash, then every object will use its own storage for every hash key. For example if a process creates 1000 objects, each being a hash with the same fixed set of keys (but differing values of course), then that process will store 1000 copies of each key.

I doubt that you can safely and reliably shrink PL_strtab via XS.

Dave.

  • Comment on Re: PL_strtab/SHAREKEYS and copy-on-write leak

Replies are listed 'Best First'.
Re^2: PL_strtab/SHAREKEYS and copy-on-write leak
by eserte (Deacon) on Aug 16, 2018 at 13:44 UTC
    Note that if you disable the shared key hash, then every object will use its own storage for every hash key. For example if a process creates 1000 objects, each being a hash with the same fixed set of keys (but differing values of course), then that process will store 1000 copies of each key.

    But on the other hand, using shareable keys on data hashes where sharing is unlikely gives you overhead. If Devel::Size is correct then sharing a key adds 24 bytes.

    Maybe it would be nice if it was possible to decide per-hash whether to share keys or not. Or even nicer, if perl objects wouldn't be based on hashes, then key sharing wouldn't be necessary at all.

      The plan at some point is to introduce hash vtables. This will allow hashes to have varying implementations, which then opens up such possibilities.

      Dave.

Re^2: PL_strtab/SHAREKEYS and copy-on-write leak
by sezal (Novice) on Jul 30, 2018 at 08:19 UTC
    Dave,

    Attempt to disable DEFAULT_SHAREKEYS was no more then just attempt to proof my assumptions regrading PL_strtab. I understand its not a good idea for production.

    I also not sure shrinking of PL_strtab (even it it's possible) will help. Perl may not release memory to OS, thus copy-on-write will occur.

    From what I see in sv.c and util.c Perl doesn't provide any API to dynamically enable/disable DEFAULT_SHAREKEYS for new hashes. :(

    Thank you.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2019-05-21 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (129 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!