Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #55635

Re: Any ideas on faster TLS ?

From Bernd Paysan <bernd@net2o.de>
Newsgroups comp.lang.forth
Subject Re: Any ideas on faster TLS ?
Date 2017-03-11 19:58 +0000
Organization A noiseless patient Spider
Message-ID <oa1kt5$u80$1@dont-email.me> (permalink)
References (3 earlier) <yPCdnc9TmsTLrynFnZ2dnUU7-TWdnZ2d@supernews.com> <o91bst$vj5$1@dont-email.me> <FeydncNQp7DG2ynFnZ2dnUU7-N-dnZ2d@supernews.com> <87k28aiy64.fsf@nightsong.com> <gOSdnbJlSYNY1yjFnZ2dnUU7-QPNnZ2d@supernews.com>

Show all headers | View raw


Am Tue, 28 Feb 2017 04:02:45 -0600 schrieb Andrew Haley:

> Paul Rubin <no.email@nospam.invalid> wrote:
>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>> Are we looking at the cost of an L1 cache miss, or something greater?
>> 
>> If FS is being reloaded every time, that is quite expensive, or used to
>> be.
> 
> FS is not being reloaded every time.  It's loaded at a context switch.
> 
> I don't think that segment overrides are particularly expensive, so the
> thread-local load costs little more than any other load.  It is,
> however, in a different region of memory, so it's possible that the load
> is causing a TLB miss, which would be expensive.  But normally TLS
> accesses are on the order of a few nanoseconds.

When I made Gforth multi-threaded, I first just changed those global 
variables to __thread variables, and in Linux, I could not measure a 
significant speed difference. This is especially important for the 
debugging engine, which saves the IP in every primitive so that 
exceptions know where the problem happened.

Some Windows user then complained that the debugging Gforth engine was 
incredibly slow on Windows (about a factor 100 slower than before), and 
it turned out that per-thread on Windows is really expensive.

Solution: Have a structure of all those per-thread pointers and let the C 
compiler figure out to put this structure pointer into a register... The 
C library wrappers also got changed to pass the stack pointers as 
arguments and return values, to avoid the expensive per-thread access on 
Windows.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
http://bernd-paysan.de/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Any ideas on faster TLS ? Ron Aaron <rambamist@gmail.com> - 2017-02-27 07:30 +0200
  Re: Any ideas on faster TLS ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-02-27 04:01 -0600
    Re: Any ideas on faster TLS ? Ron Aaron <rambamist@gmail.com> - 2017-02-27 13:19 +0200
      Re: Any ideas on faster TLS ? Alex <alex@rivadpm.com> - 2017-02-27 12:56 +0000
        Re: Any ideas on faster TLS ? Ron Aaron <rambamist@gmail.com> - 2017-02-27 15:10 +0200
        Re: Any ideas on faster TLS ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-02-27 17:08 +0100
      Re: Any ideas on faster TLS ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-02-27 08:06 -0600
        Re: Any ideas on faster TLS ? Ron Aaron <rambamist@gmail.com> - 2017-02-27 16:10 +0200
          Re: Any ideas on faster TLS ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-02-27 09:31 -0600
            Re: Any ideas on faster TLS ? Ron Aaron <rambamist@gmail.com> - 2017-02-28 07:05 +0200
            Re: Any ideas on faster TLS ? Paul Rubin <no.email@nospam.invalid> - 2017-02-27 23:15 -0800
              Re: Any ideas on faster TLS ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-02-28 04:02 -0600
                Re: Any ideas on faster TLS ? Bernd Paysan <bernd@net2o.de> - 2017-03-11 19:58 +0000
      Re: Any ideas on faster TLS ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-01 12:36 +0000
        Re: Any ideas on faster TLS ? Ron Aaron <rambamist@gmail.com> - 2017-03-01 15:11 +0200
          Re: Any ideas on faster TLS ? Alex <alex@rivadpm.com> - 2017-03-03 01:18 +0000
            Re: Any ideas on faster TLS ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-03 12:55 +0000
              Re: Any ideas on faster TLS ? Alex <alex@rivadpm.com> - 2017-03-03 14:59 +0000
                Re: Any ideas on faster TLS ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-03 16:15 +0000
          Optimizing (was: Any ideas on faster TLS ?) Ron Aaron <rambamist@gmail.com> - 2017-03-17 13:14 +0200
  Re: Any ideas on faster TLS ? rickman <gnuarm@gmail.com> - 2017-02-28 01:13 -0500
    Re: Any ideas on faster TLS ? Paul Rubin <no.email@nospam.invalid> - 2017-02-27 22:48 -0800
      Re: Any ideas on faster TLS ? rickman <gnuarm@gmail.com> - 2017-02-28 03:50 -0500

csiph-web