This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Dri-devel] Re: OpenGL and the LinuxThreads pthread_descr structure


Jakub Jelinek wrote:
> 
> Hi!
> 
> What percentage of applications use different dispatch
> tables among its threads? How often do dispatch table changes
> occur? If both of these are fairly low, computing a dispatch table
> in an awx section at dispatch table switch time might be fastest
> (ie. prepare something like:
> .section dispatch, "awx"
>   .align 8
> .globl glFoobar
> glFooBar:
>   jmp something
>   nop; nop; nop
> 
> and <something> would be changed whenever a dispatch table switch happens
> for all dispatch table members).
> 
> BTW: Last time I looked at libGL (in March), these were things which I
> came over:
> 1) libGL should IMHO use a version script (at least an anonymous one
>    if you want to avoid assigning a specific GL_x.y symbol version to it),
>    that way you get rid of thousands of expensive run-time relocations

Where can I get info on this?

> 2) last time I looked, libGL.so was linked unconditionally against
>    libpthread. This is punnishing all non-threaded apps, weak undefined
>    symbols work very well

This is because we currently use the standard way of getting thread-local-data
and detecting multi-thread situations.  I'm not sure how Gareth is able to
detect threaded vs. non-threaded situations without making any calls into the
pthreads library, but once you know which one you're in, with his trick, you
don't need to make any more.

Currently we do something like this in MakeCurrent:

void
_glapi_check_multithread(void)
{
#if defined(THREADS)
   if (!ThreadSafe) {
      static unsigned long knownID;
      static GLboolean firstCall = GL_TRUE;
      if (firstCall) {
         knownID = _glthread_GetID();
         firstCall = GL_FALSE;
      }
      else if (knownID != _glthread_GetID()) {
         ThreadSafe = GL_TRUE;
      }
   }
   if (ThreadSafe) {
      /* make sure that this thread's dispatch pointer isn't null */
      if (!_glapi_get_dispatch()) {
         _glapi_set_dispatch(NULL);
      }
   }
#endif
}

where _glthread_GetID() is really pthread_self().

How do you detect threading without making these calls to libpthreads.so?




> 3) I don't think building without -fpic is a good idea, 1) together with
>    other tricks might speed things up while avoiding DT_TEXTREL
>    overhead

The thing that really bites with -fpic is the bs you have to go through to get
access to static symbols (forgive my loose terminology) like static variables
or other functions you want to call.  Gareth's trick means that two very
important variables avoid this, but it's still going to be necessary to call
other functions often enough...

> There were some other things, but I don't remember it very well. If I find
> time I'll build libGL again and check the disassembly.

As someone who 1) is concerned about libGL performance and 2) doesn't know
much about relocation/fpic/pthreads/etc, I'd love to hear anything you've got
on this.

Keith


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]