Optimizing with gcc

My notes while reading Optimizing applications with gcc & glibc by Ulrich Drepper.
  • __extension__ to mark intentional use of GNU extension.
  • poor mans 'lambda' (({ }))
  • predicate to determine if parameter value is constant at runtime: __builtin_constant_p()
  • mark pure functions with __attribute__((__const__))
  • mark functions which never return with __attribute__((__noreturn__))
  • __stdcall__ attribute on x86 makes callee correct the stack at ret, in Unix convention the caller corrects the stack
  • mempcpy returns a pointer just after the last copied byte.
  • calloc knows if memory is already full of 0's -> faster than malloc & memset
  • int_least16_t, int_fast16_t when actual variable size is uninteresting, speed is
  • replace stlen and + with strchr(s,'\0') or rawmemchr()
  • gcc computed gotos and jump tables: && for the address of a label
  • -pg and -profile : gprof and sprof

Comments

Popular posts from this blog

iMovie event library on a network drive, NAS

Proxmox PCIe passthrough on HP gen8 - failed to set iommu for container

Backup and restore observium