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


Groups > comp.lang.forth > #52286

Re: 1 /STRING vs SNIP

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: 1 /STRING vs SNIP
Date 2016-10-29 10:17 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2016Oct29.121701@mips.complang.tuwien.ac.at> (permalink)
References (3 earlier) <2016Oct27.114220@mips.complang.tuwien.ac.at> <5812fe2f.243659084@news.eternal-september.org> <f909012d-bdb9-40ee-856a-ab30f60ed83e@googlegroups.com> <2016Oct28.185046@mips.complang.tuwien.ac.at> <e4bc4f21-83b9-48a8-9a8b-be6d83c20f22@googlegroups.com>

Show all headers | View raw


Chris Curl <ccurl609@gmail.com> writes:
>On Friday, October 28, 2016 at 1:09:47 PM UTC-4, Anton Ertl wrote:
>> I have now done a benchmark: ten copies of the "1 /STRING" code, but
>> with different memory locations for the second stack items to avoid
>> the dependence-through-memory slowdown that would probably swamp all
>> other effects.  Here are two copies:
>> 
>> VFX-like             SF-like
>> movq (%rdi), %rax    addq $1, 0(%rdi)
>> addq $1, %rax        subq $1, %rsi   
>> movq %rax, (%rdi)    addq $1, 8(%rdi)
>> subq $1, %rsi        subq $1, %rsi   
>> movq 8(%rdi), %rax
>> addq $1, %rax
>> movq %rax, 8(%rdi)
>> subq $1, %rsi
>> 
>> 100M iterations of these ten copies take the following number of cycles:

Now including Skylake:

VFX-like    SF-like
1537853028  1167890963 Phenom II X2 560
1105969806  1021509951 Core i7 4690K (Haswell)
1102112502  1010674749 Core i7 6700K (Skylake)

>> So the SwiftForth-like code is faster than the VFX-like code on both
>> the Phenom II and the Haswell.
...
>Sure, the numbers are smaller for the SF-like version, but those numbers 
>are so big that they don't tell me a clear story. Can you put the results 
>into something a human can wrap his head around, as in "the difference 
>results in the VFX version taking <X> seconds|minutes|hours longer to 
>execute on a data size of <Y>"?

It depends on how /STRING is used in the application.  An application
that calls 1 /STRING 1e12 times in a way that is similar (wrt
dependences and resource consumption) to the microbenchmark will run
22s faster on a Core i7-6700K in turbo mode (4.2GHz) and 112s faster
on the Phenom II X2 560 (3.3GHz) with the SF-like variant than with
the VFX-like variant.  I doubt that is really very informative, though.

Another way to look at it is, that if you ignore this kind of
difference everywhere else, your programs will run slower by a factor
of 1.08 (Haswell) ... 1.32 (Phenom II) than if you always go for the
faster code.

>If it is only a second or two for 100 MILLION iterations, then ... sure it 
>is faster, but the difference PER CYCLE is so small that the difference will 
>never be noticed in practice.

It's more like 0.01s on Phenom II and less on the Intel chips.
However, if you have a 1 /STRING in an inner loop (as can easily
happen), you can easily get more than 100M executions in a program,
and you can get a noticable (Phenom II) or at least measurable
difference even in an application.

>At the end of the day though, knowing which is faster IS valuable, because 
>it never hurts to do things as efficiently as possible.

Sometimes it has it's cost, but knowing which is faster by how much
let's you make an informed decision on whether the speedup is worth
the cost.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2016: http://www.euroforth.org/ef16/

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


Thread

1 /STRING vs SNIP foxaudioresearch@gmail.com - 2016-10-18 19:31 -0700
  Re: 1 /STRING vs SNIP Ron Aaron <rambamist@gmail.com> - 2016-10-19 07:24 +0300
  Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-19 07:52 +0000
    Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-19 16:58 -0700
      Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-21 16:01 +1000
        Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-21 00:51 -0700
          Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-21 00:57 -0700
        Re: 1 /STRING vs SNIP trans <transfire@gmail.com> - 2016-10-21 05:20 -0700
          Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-22 00:25 +1000
            Re: 1 /STRING vs SNIP trans <transfire@gmail.com> - 2016-10-21 09:13 -0700
              Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-21 16:24 +0000
                Re: 1 /STRING vs SNIP albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-21 20:06 +0200
                Re: 1 /STRING vs SNIP trans <transfire@gmail.com> - 2016-10-21 14:19 -0700
                Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-22 13:46 +1000
                Re: 1 /STRING vs SNIP stephen@mpeforth.com (Stephen Pelc) - 2016-10-22 11:34 +0000
                Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-22 13:49 +0000
                Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-24 11:15 +1000
                Re: 1 /STRING vs SNIP albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-24 03:01 +0200
                Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-24 13:29 +1000
                Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-24 11:15 +0000
                Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-24 19:44 -0700
                Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-29 11:17 +1000
                Re: 1 /STRING vs SNIP Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-10-29 04:09 -0500
                Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-29 16:44 +0000
                Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-29 17:11 -0700
                Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-31 19:11 +1100
                Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-31 08:47 +0000
      Re: 1 /STRING vs SNIP trans <transfire@gmail.com> - 2016-10-21 03:49 -0700
        Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-22 20:02 -0700
        Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-22 20:13 -0700
          Re: 1 /STRING vs SNIP trans <transfire@gmail.com> - 2016-10-22 21:09 -0700
            Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-23 18:36 -0700
          Re: 1 /STRING vs SNIP alex <alex@rivadpm.com> - 2016-10-27 14:07 +0100
            Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-27 19:12 -0700
              Re: 1 /STRING vs SNIP alex <alex@rivadpm.com> - 2016-10-28 19:39 +0100
                Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-28 20:26 -0700
    Re: 1 /STRING vs SNIP foxaudioresearch@gmail.com - 2016-10-26 19:52 -0700
      Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-27 09:42 +0000
        Re: 1 /STRING vs SNIP foxaudioresearch@gmail.com - 2016-10-27 06:46 -0700
        Re: 1 /STRING vs SNIP stephen@mpeforth.com (Stephen Pelc) - 2016-10-28 07:31 +0000
          Re: 1 /STRING vs SNIP jim <anon@example.com> - 2016-10-28 11:33 +0100
          Re: 1 /STRING vs SNIP jasmijn Bonting <tessa.bonting@gmail.com> - 2016-10-28 04:09 -0700
            Re: 1 /STRING vs SNIP stephen@mpeforth.com (Stephen Pelc) - 2016-10-28 12:41 +0000
            Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-28 16:50 +0000
              Re: 1 /STRING vs SNIP Chris Curl <ccurl609@gmail.com> - 2016-10-28 10:59 -0700
                Re: 1 /STRING vs SNIP anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-10-29 10:17 +0000
  Re: 1 /STRING vs SNIP "HAA" <someone@microsoft.com> - 2016-10-19 20:19 +1000
    Re: 1 /STRING vs SNIP foxaudioresearch@gmail.com - 2016-10-19 05:12 -0700
  1 /STRING vs SNIP trans <transfire@gmail.com> - 2016-10-21 04:07 -0700
    Re: 1 /STRING vs SNIP albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-21 15:50 +0200
    Re: 1 /STRING vs SNIP hughaguilar96@gmail.com - 2016-10-25 16:38 -0700
      Re: 1 /STRING vs SNIP "David N. Williams" <williams@umich.edu> - 2016-10-26 10:50 -0400
        Re: 1 /STRING vs SNIP "David N. Williams" <williams@umich.edu> - 2016-10-26 10:53 -0400
        Re: 1 /STRING vs SNIP albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-10-26 17:33 +0200
          Re: 1 /STRING vs SNIP "David N. Williams" <williams@umich.edu> - 2016-10-27 10:16 -0400
            Re: 1 /STRING vs SNIP Doug Hoffman <glidedog@gmail.com> - 2016-10-27 17:01 -0400
          Re: 1 /STRING vs SNIP Coos Haak <htrofhc@gmail.com> - 2016-10-27 17:00 +0200
  Re: 1 /STRING vs SNIP Hans Bezemer <the.beez.speaks@gmail.com> - 2016-10-22 12:25 +0200

csiph-web