[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4.2 New assorted suggestions
- From: Francisco Olarte <folarte@...>
- Date: Mon, 16 Nov 2020 12:59:52 +0100
Ranier:
On Mon, Nov 16, 2020 at 12:15 PM Ranier Vilela <ranier.vf@gmail.com> wrote:
> Em seg., 16 de nov. de 2020 às 07:04, Andre Leiradella <andre@leiradella.com> escreveu:
>> I suggest you thoroughly test your changes and benchmark them before
>> suggesting changes to the Lua source code, some won't give you any
>> performance gains (and are likely even slower).
> I do not agree.
> If you disagree, you could run benchmarks and prove me wrong.
As an observer, I would normally expect the burden of the proof to the
one suggesting changes.
Anyway, what I was going to send. Are you aware that many of these
micro optimizations are cargo cult from a bygone age of simpler
compilers?
I mean, I just use stock debian, which does not have the more cutting
edge optmizations, and even then if I compile:
>>>>
#include <string.h>
int main(int ac, char **av) {
/* I'm not going to run it but need to avoid getting all optimized
to a constant. */
int a = strcmp(av[1],"method");
int b = strncmp(av[2],"method", sizeof("method"));
return a+b;
}
<<<<
using a plain gcc -S -O3 i get:
>>>>
.file "kk.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "method"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
movq %rsi, %r8
leaq .LC0(%rip), %rdx
movq 8(%rsi), %rsi
movl $7, %ecx
movq %rdx, %rdi
repz cmpsb
movq 16(%r8), %rsi
movq %rdx, %rdi
movl $7, %ecx
seta %al
sbbb $0, %al
repz cmpsb
movsbl %al, %eax
seta %dl
sbbb $0, %dl
movsbl %dl, %edx
addl %edx, %eax
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Debian 8.3.0-6) 8.3.0"
.section .note.GNU-stack,"",@progbits
<<<<
Which seems to indicate that when comparing to constant strings every
function behaves similarly.
Francisco Olarte.