Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #105886
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: va_start without the first argument? |
| Date | 2017-03-12 21:04 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <oa49f0$79d$1@dont-email.me> (permalink) |
| References | (6 earlier) <oa1gud$79a$1@dont-email.me> <oa3g4n$egd$1@dont-email.me> <oa3mfq$3m6$1@dont-email.me> <oa3vea$39f$1@dont-email.me> <oa42ej$dms$1@dont-email.me> |
On 12/03/17 19:04, BartC wrote: > On 12/03/2017 17:13, David Brown wrote: >> On 12/03/17 15:40, BartC wrote: > >>> I've done this and was hoping to use the same approach for compiling C >>> (for x64). But it won't work because there is now no distinction between >>> C functions which are compiled here, and C functions compiled elsewhere >>> by another compiler. >> >> Sure there is - if your compiler is the one compiling a function, and >> you know that all uses of the function are through code that you >> compile, then you can do what you want. This is usually the case for >> static functions (unless you take their address and pass it outside the >> current translation unit). > > Yeah, maybe. But when 99% of calls could be your own call convention, > then it would be worth doing (and with the 1% using the ABI, the > efficiency of those wouldn't matter). But if it's only static functions, > and only those you can be sure can't be called by any other means ... > > Even then, sometimes you want to take the address of a static function. > Then when you call via a pointer, it's not going to be easy to determine > if an arbitrary pointer points to a static function, or a global one, or > can be either during the course of the program. For example, you pass a > function pointer to a function; that function won't know its provenance. > > Of course an implementation can choose to generate two copies of static > functions, one of which is used only for direct internal calls. But this > is way past the point where it would just be easier to use the official > ABI. This is all a matter of quality of implementation - /you/ choose. Using more efficient calling conventions for local calls (static calls whose address is not taken) should be relatively easy. Dealing with other calls is going to be a lot harder - you will likely need some sort of whole program optimisation or link-time code generation. > >>> (Not that this ABI makes things that much faster, if at all. If I take >>> my current project and compile with gcc -O0, then the 32-bit version is >>> 8% faster than the 64-bit, despite the latter passing parameters in >>> registers for most functions.) >>> >> >> Speed comparisons without optimisation are /always/ pointless. > > No, it makes it easier to compare how long things take to execute > (rather than how long it takes /not/ to execute them as often happens > with gcc). Yes, speed comparisons without optimisation are /always/ pointless. You can't compare the speed of two cars if you insist that they both stay in first gear - even if they are two models from the same manufacturer. > > Anyway, if I use -O3 for both, then the 32-bit version is 12% faster! > Despite having fewer and narrower registers. And there you have an interesting comparison. This is Windows, I take it? Different programs will see different gains or loses in speed here. You will want to test quite a few different programs to get more general results. > > >> And there are a variety of things that can affect the difference in >> speed between 32-bit and 64-bit versions (even when you have allowed the >> compiler to generate decent code by using at least -O1). Pointers in >> 64-bit mode are 64-bit wide - that means more cache is needed, meaning >> more cache misses, and more memory bandwidth is needed. For some >> applications, the difference here can be significant. And in Windows, >> the aforementioned idiotic requirement of allocating stack space for the >> arguments passed in registers means wasted time and wasted cache space >> on every function call in 64-bit mode. > > The pointer one I know about (I think it cost me 5% loss of performance > when I switched an old x64 compiler from 32- to 64-bit pointers). > > But how much would allocating those 32 bytes of stack cost? Bear in mind > that probably nothing will be written to them. Leaf functions are often quite short, and often would not need a stack frame at all if it were not for this extra allocation. So you have extra instructions to modify the stack pointer and restore it afterwards, perhaps also with a frame pointer there somewhere. > > (It'll reduce cache capacity to a certain extent, but only as far as the > maximum call-nesting depth, which usually isn't very much. If the > maximum level is 30 calls deep, then we're talking 1KB in total.) > It all adds up. I expect it is not a particularly big cost, but it is a pointless one.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-10 11:57 -0800
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-10 12:04 -0800
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-10 12:32 -0800
Re: va_start without the first argument? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-03-10 15:51 -0500
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-10 14:36 -0800
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-10 14:53 -0800
Re: va_start without the first argument? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-10 17:14 -0600
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-10 15:37 -0800
Re: va_start without the first argument? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-10 23:12 -0600
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 10:29 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 11:31 -0700
Re: va_start without the first argument? scott@slp53.sl.home (Scott Lurndal) - 2017-03-13 18:40 +0000
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 12:31 -0700
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-11 19:53 +0100
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-11 19:05 +0000
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-11 11:56 -0800
Re: va_start without the first argument? antispam@math.uni.wroc.pl - 2017-03-12 05:41 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-12 13:52 +0100
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-12 14:40 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-12 18:13 +0100
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-12 18:04 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-12 21:04 +0100
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-12 21:02 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-12 22:40 +0100
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-12 15:51 -0700
Re: va_start without the first argument? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-03-12 16:52 -0700
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-13 00:56 +0100
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-13 09:17 -0700
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-13 17:54 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-13 22:12 +0100
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-13 22:48 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-14 13:46 +0100
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-14 13:37 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-14 15:24 +0100
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-14 08:25 -0700
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-14 17:02 +0100
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-14 09:45 -0700
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-14 09:15 -0700
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-14 10:02 -0700
Re: va_start without the first argument? jt@toerring.de (Jens Thoms Toerring) - 2017-03-14 20:32 +0000
Re: va_start without the first argument? raltbos@xs4all.nl (Richard Bos) - 2017-03-14 07:44 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-14 13:38 +0100
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-14 08:57 -0700
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-13 11:21 -0700
Re: va_start without the first argument? scott@slp53.sl.home (Scott Lurndal) - 2017-03-13 18:33 +0000
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-13 22:08 +0100
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-13 15:23 -0700
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-14 13:58 +0100
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-14 09:18 -0700
Re: va_start without the first argument? scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 16:52 +0000
Re: va_start without the first argument? Keith Thompson <kst-u@mib.org> - 2017-03-14 11:34 -0700
Re: va_start without the first argument? scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 18:54 +0000
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-14 13:30 -0700
Re: va_start without the first argument? Ike Naar <ike@iceland.freeshell.org> - 2017-03-15 21:55 +0000
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-15 15:16 -0700
Re: va_start without the first argument? Philip Lantz <prl@canterey.us> - 2017-03-23 21:04 -0700
Re: va_start without the first argument? David Brown <david.brown@hesbynett.no> - 2017-03-14 21:48 +0100
Re: va_start without the first argument? scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 14:01 +0000
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-14 07:42 -0700
Re: va_start without the first argument? scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 12:38 +0000
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-13 01:11 +0100
Re: va_start without the first argument? Ian Collins <ian-news@hotmail.com> - 2017-03-13 15:43 +1300
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-13 10:36 +0000
Re: va_start without the first argument? Ian Collins <ian-news@hotmail.com> - 2017-03-14 07:33 +1300
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-13 19:00 +0000
Re: va_start without the first argument? Ian Collins <ian-news@hotmail.com> - 2017-03-14 08:05 +1300
Re: va_start without the first argument? BartC <bc@freeuk.com> - 2017-03-13 23:10 +0000
Re: va_start without the first argument? Ian Collins <ian-news@hotmail.com> - 2017-03-14 17:38 +1300
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-14 05:48 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 12:12 -0700
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-12 19:39 +0100
Re: va_start without the first argument? jt@toerring.de (Jens Thoms Toerring) - 2017-03-10 20:49 +0000
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-10 14:41 -0800
Re: va_start without the first argument? John Bode <jfbode1029@gmail.com> - 2017-03-10 16:05 -0800
Re: va_start without the first argument? jacob navia <jacob@jacob.remcomp.fr> - 2017-03-11 21:47 +0100
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-11 13:07 -0800
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-11 22:24 +0100
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 05:44 -0700
Re: va_start without the first argument? Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-13 08:59 -0400
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 06:17 -0700
Re: va_start without the first argument? Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-13 13:27 -0400
Re: va_start without the first argument? Jerry Stuckle <jstucklex@attglobal.net> - 2017-03-13 13:30 -0400
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 11:00 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 10:34 -0700
Re: va_start without the first argument? antispam@math.uni.wroc.pl - 2017-03-12 06:00 +0000
Re: va_start without the first argument? gordonb.gas5o@burditt.org (Gordon Burditt) - 2017-03-17 09:46 -0500
Re: va_start without the first argument? supercat@casperkitty.com - 2017-03-17 09:07 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 05:39 -0700
Re: va_start without the first argument? John Bode <jfbode1029@gmail.com> - 2017-03-13 11:40 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 12:01 -0700
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-13 23:17 +0100
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 16:15 -0700
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-14 00:26 +0100
Re: va_start without the first argument? kikiins@gmail.com - 2017-03-13 16:51 -0700
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-14 01:12 +0100
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 18:24 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-13 18:57 -0700
Re: va_start without the first argument? raltbos@xs4all.nl (Richard Bos) - 2017-03-14 07:59 +0000
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-14 06:45 -0700
Re: va_start without the first argument? Robert Wessel <robertwessel2@yahoo.com> - 2017-03-13 18:20 -0500
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-14 00:31 +0100
Re: va_start without the first argument? raltbos@xs4all.nl (Richard Bos) - 2017-03-13 16:51 +0000
Re: va_start without the first argument? jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-11 19:29 +0100
Re: va_start without the first argument? Siri Cruise <chine.bleu@yahoo.com> - 2017-03-11 12:12 -0800
Re: va_start without the first argument? luser droog <luser.droog@gmail.com> - 2017-03-13 05:37 -0700
Re: va_start without the first argument? luser droog <luser.droog@gmail.com> - 2017-03-15 11:45 -0700
Re: va_start without the first argument? Thiago Adams <thiago.adams@gmail.com> - 2017-03-15 13:39 -0700
csiph-web