List Info

Thread: PADTMP hash pessimisation




PADTMP hash pessimisation
user name
2007-09-19 13:03:32
I've often been wondering whether there would be space or
speed gains from
making all internal constants shared hash key scalars
(And maybe also having all common number constants be
references to the same
IV)

Anyway, right now, string constants used by hash keys should
be shared hash
key scalars. (It's an optimisation in the peep hole
optimiser, rather than in
the tokeniser)

Without threads:

$ gdb --args ./perl -e '$h++'
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it under
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as
"i386-marcel-freebsd"...
(gdb) b Perl_hv_fetch_ent
Breakpoint 1 at 0x80c84b6: file hv.c, line 407.
(gdb) r
Starting program: /home/nick/p4perl/perl/perl -e $h++

Breakpoint 1, Perl_hv_fetch_ent (hv=0x829d2c0,
keysv=0x829d290, lval=1,
    hash=3392050242) at hv.c:407
407         return hv_fetch_common(hv, keysv, NULL, 0, 0,
(gdb) call Perl_sv_dump(keysv)
SV = PV(0x82880d0) at 0x829d290
  REFCNT = 1
  FLAGS = (POK,FAKE,READONLY,pPOK)
  PV = 0x829bbb4 "a"
  CUR = 1
  LEN = 0
(gdb) p hash
$1 = 3392050242


Yes, they are. The precomputed hash value is used, and the
hash lookups will
do pointer comparisons rather than memcmp()s.


With threads:

$ gdb6 --args ./perl -e '$h++'
GNU gdb 20040810 [GDB v6.x for FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it under
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show
warranty" for details.
This GDB was configured as
"i386-portbld-freebsd5.3"...
(gdb) b Perl_hv_fetch_ent
Breakpoint 1 at 0x80d3afa: file hv.c, line 407.
(gdb) r
Starting program: /export/home/nwc10/p4perl/perl/perl -e
$h++

Breakpoint 1, Perl_hv_fetch_ent (my_perl=0x82bf000,
hv=0x82da2bc,
    keysv=0x82da29c, lval=1, hash=0) at hv.c:407
407         return hv_fetch_common(hv, keysv, NULL, 0, 0,
(gdb) call Perl_sv_dump(my_perl, keysv)
SV = PV(0x82c1054) at 0x82da29c
  REFCNT = 1
  FLAGS = (PADTMP,POK,READONLY,pPOK)
  PV = 0x82b554c "a"
  CUR = 1
  LEN = 4
(gdb) p hash
$1 = 0



Erk. No they are not.

Does anyone know why they are not? Or how easy this might be
to fix.

Nicholas Clark

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )