Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^6: Threads and fork and CLONE, oh my!

by demerphq (Chancellor)
on Nov 15, 2005 at 14:49 UTC ( #508626=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Threads and fork and CLONE, oh my!
in thread Threads and fork and CLONE, oh my!

Even more efficient would be to write a custom hash loading routine in XS that a) extracts the refaddr automatically, and b) uses the binary representation of the address as the key for the hash lookup/storage. Currently when you use $hash{0+$self}=$foo you are doing itoa() on the address, then using the resulting string for the hash key. If the addresses binary representation was used as the key they keys would be fixed length, and would not require the itoa() step, and would be much faster. I imagine this would about 4-8 lines of XS code and would be drammatically faster than using $hash{0+$self}. Ie I can imagine an API like:

ref_key_store(%hash,$ref,$value); my $val=ref_key_fetch(%hash,$ref);
---
$world=~s/war/peace/g


Comment on Re^6: Threads and fork and CLONE, oh my!
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2014-09-30 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (366 votes), past polls