Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weakrefs could use ptr_tables to avoid the current linear implementation #7938

Open
p5pRT opened this issue May 31, 2005 · 5 comments
Open
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter distro-freebsd type-core Wishlist

Comments

@p5pRT
Copy link

p5pRT commented May 31, 2005

Migrated from rt.perl.org#36050 (status was 'open')

Searchable as RT36050$

@p5pRT
Copy link
Author

p5pRT commented May 31, 2005

From @nwc10

Created by @nwc10

Currently the weakref implementation uses AVs and a linear search.
It should be possible to re-implenent it to use the ptr_table hashes used
by the ithreads cloning code. This should make the backref lookup O(1)
rather than O(n)

Perl Info

Flags:
    category=core
    severity=wishlist

Site configuration information for perl v5.9.3:

Configured by nick at Fri May 27 21:32:46 BST 2005.

Summary of my perl5 (revision 5 version 9 subversion 3 patch 24610) configuration:
  Platform:
    osname=freebsd, osvers=5.3-release-p2, archname=i386-freebsd
    uname='freebsd saigo.etla.org 5.3-release-p2 freebsd 5.3-release-p2 #1: wed dec 15 21:05:13 gmt 2004 root@saigo.etla.org:usrobjusrsrcsyssaigo i386 '
    config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list=  -Dinc_version_list_init=0 -Uuselongdouble -Uuse64bitint -Uusethreads -Dinstallman1dir=none -Dinstallman3dir=none -Dprefix=~/Sandpit/blead-pentagram24610 -Doptimize=-O2 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -mpreferred-stack-boundary=4 -minline-all-stringops -de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache gcc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
    optimize='-O2 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -mpreferred-stack-boundary=4 -minline-all-stringops',
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='3.4.2 [FreeBSD] 20040728', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Wl,-E  -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil -lc
    perllibs=-lm -lcrypt -lutil -lc
weakrefs could use ptr_tables to avoid the current linear implementation
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.9.3:
    /home/nick/Sandpit/blead-pentagram24610/lib/perl5/5.9.3/i386-freebsd
    /home/nick/Sandpit/blead-pentagram24610/lib/perl5/5.9.3
    /home/nick/Sandpit/blead-pentagram24610/lib/perl5/site_perl/5.9.3/i386-freebsd
    /home/nick/Sandpit/blead-pentagram24610/lib/perl5/site_perl/5.9.3
    /home/nick/Sandpit/blead-pentagram24610/lib/perl5/site_perl
    .


Environment for perl v5.9.3:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/nick/bin:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash

@p5pRT
Copy link
Author

p5pRT commented May 31, 2005

From @demerphq

On 31 May 2005 14​:11​:03 -0000, via RT Nicholas Clark
<perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Nicholas Clark
# Please include the string​: [perl #36050]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=36050 >

This is a bug report for perl from nick@​ccl4.org,
generated with the help of perlbug 1.35 running under perl v5.9.3.

-----------------------------------------------------------------
[Please enter your report here]

Currently the weakref implementation uses AVs and a linear search.
It should be possible to re-implenent it to use the ptr_table hashes used
by the ithreads cloning code. This should make the backref lookup O(1)
rather than O(n)

If this is changed please make it possible ensure it is still possible
to inspect and work with the content. For instance the latest version
of Data​::Dump​::Streamer uses the following code to ensure that weakref
structures are correctly dumped​:

  MAGIC *mg = NULL;
  if( SvMAGICAL(sv)
  && (mg = mg_find(sv, PERL_MAGIC_backref) )
  ){
  AV *av = (AV *)mg->mg_obj;
  RETVAL += av_len(av)+1;
  }

Incidentally with code like this in Storable the issue discussed some
time back of what items need to be tracked for possible multiple
instances becomes quite simple. If the SvREFCOUNT+WeakRefCount>1 then
the item must be tracked as it potentially occurs twice in the data
structure being dumped.

yves
ps​: if anybody on p5p cares, DDS can dump closures properly now. (with
a few modest caveats).
--
perl -Mre=debug -e "/just|another|perl|hacker/"

@p5pRT
Copy link
Author

p5pRT commented May 31, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 31, 2005

From @nwc10

On Tue, May 31, 2005 at 04​:20​:40PM +0200, demerphq wrote​:

On 31 May 2005 14​:11​:03 -0000, via RT Nicholas Clark
<perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Nicholas Clark
# Please include the string​: [perl #36050]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=36050 >

This is a bug report for perl from nick@​ccl4.org,
generated with the help of perlbug 1.35 running under perl v5.9.3.

-----------------------------------------------------------------
[Please enter your report here]

Currently the weakref implementation uses AVs and a linear search.
It should be possible to re-implenent it to use the ptr_table hashes used
by the ithreads cloning code. This should make the backref lookup O(1)
rather than O(n)

If this is changed please make it possible ensure it is still possible
to inspect and work with the content. For instance the latest version

Sure. Also, I can't see this sort of change being suitable for maint, given
that there's more than one module on CPAN that expects the current weak
reference implementation.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented May 31, 2005

From @demerphq

On 5/31/05, Nicholas Clark <nick@​ccl4.org> wrote​:

On Tue, May 31, 2005 at 04​:20​:40PM +0200, demerphq wrote​:

On 31 May 2005 14​:11​:03 -0000, via RT Nicholas Clark
<perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Nicholas Clark
# Please include the string​: [perl #36050]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=36050 >

This is a bug report for perl from nick@​ccl4.org,
generated with the help of perlbug 1.35 running under perl v5.9.3.

-----------------------------------------------------------------
[Please enter your report here]

Currently the weakref implementation uses AVs and a linear search.
It should be possible to re-implenent it to use the ptr_table hashes used
by the ithreads cloning code. This should make the backref lookup O(1)
rather than O(n)

If this is changed please make it possible ensure it is still possible
to inspect and work with the content. For instance the latest version

Sure. Also, I can't see this sort of change being suitable for maint, given
that there's more than one module on CPAN that expects the current weak
reference implementation.

Cool, i look forward to yet another internals special case :-)

Cheers,
yves

--
perl -Mre=debug -e "/just|another|perl|hacker/"

@toddr toddr added the Closable? We might be able to close this ticket, but we need to check with the reporter label Feb 4, 2020
@xenu xenu removed the affects-5.9 label Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closable? We might be able to close this ticket, but we need to check with the reporter distro-freebsd type-core Wishlist
Projects
None yet
Development

No branches or pull requests

3 participants