Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: IPC::Sharable ... curious ipcs -a results

by andyok (Novice)
on May 27, 2021 at 18:49 UTC ( [id://11133157]=note: print w/replies, xml ) Need Help??


in reply to IPC::Sharable ... curious ipcs -a results

...and the point of your completely irrelevant post is, what?

This is my first foray into IPC::Shareable ... and I wanted to be sure that my script was using system-resources (shared-memory) in a reasonable way.

The %Sess hash could grow to have perhaps 100 entries .... and if each entries causes another 64Kbyte shared-memory segment to be created, that would probably be not a good idea.

I couldn't understand why semaphores were being created and why, even though the hash was quite small, so many 64Kbyte segments were being created.

It is now clear that I need to be a bit more sophisticated in what I store in the shared-memory segment ...

... especially if %Sess could have many many entries

For example, perhaps it might be better to convert the hash to a string (using Data::Dumper) and it is the string that is stored in the shared-memory segment.

Thank you for the explanation.

Replies are listed 'Best First'.
Re^2: IPC::Sharable ... curious ipcs -a results
by jo37 (Deacon) on May 27, 2021 at 19:09 UTC

    Mind the threading in the replies.

    ...and the point of your completely irrelevant post is, what?

    was not a reply to your original post, but to some anonymous noise.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
      was not a reply to your original post, but to some anonymous noise.

      Absolutely correct! I was definitely not responding to you with that statement, andyok!

Re^2: IPC::Sharable ... curious ipcs -a results
by stevieb (Canon) on May 27, 2021 at 20:32 UTC
    For example, perhaps it might be better to convert the hash to a string (using Data::Dumper) and it is the string that is stored in the shared-memory segment.

    Personally, I use JSON to store my data. I like the ease of it, and its especially good because it's cross platform and stores well in files if you want to dump the data for future program runs. Here's a non-complete example:

    use warnings; use strict; use JSON; my $shared_memory_variable = ...; # Create shared mem with IPC::Sharea +ble my $data = { a => 1, b => [ 1, 2, 3 ], c => { z => 99, y => 98, x => { m => 'hello, world!' }, }, }; # Create JSON string and store it in the shared memory allocation $shared_memory_variable = encode_json $data; # Restore the shared memory JSON to a Perl data structure my $perl = decode_json $shared_memory_variable;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-19 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found