If you can't read please download the document
Upload
er-galvao-abbott
View
962
Download
0
Embed Size (px)
Citation preview
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
Otimizando a Execuo de Cfigo-Fonte PHP
www.galvao.eti.br
Otimizando a Execuode Cdigo-Fonte
Quem?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Er Galvo Abbott o Presidente da ABRAPHP AssociaoBrasileira de Profissionais PHP, Diretor da PHP Conference Brasil, o principal evento de PHP da Amrica Latina e fundador do PHPBR, Grupo de Usurios com mais de 1.200 associados.
Trabalha h mais de 19 anos desenvolvendo sistemas e aplicaes com interface web, sendo 14 anos com PHP e 6 anos com Zend Framework. Trabalhou com diversas empresas de grande porte, tanto nacionais como internacionais.
Palestra em eventos e ministra cursos em diversas instituies,bem como in company.
Site: http://www.galvao.eti.br/Twitter: @galvao
Slides e Documentos: http://slideshare.net/ergalvao
https://speakerdeck.com/galvao
Fork me @ http://github.com/galvao
Otimizando a Execuo de Cfigo-Fonte PHP
Objetivo
Esta palestra tem por objetivo demonstrar tcnicas de programao PHP que minimizamcustos de performance, bem como analisar detalhes relativos a performance de aplicaesdesenvolvidas com a linguagem.
Sero apresentados os seguintes tpicos:
Detectando o uso de recursos consumidos pela aplicao Profiling xdebug/KCachegrind xhprof/xhgui Configuraes do PHP relacionadas a performance Opes de cdigo-fonte: h diferenas relevantes entre formas de cdigo? Concluses
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
Profiling
xdebug/KCachegrind
ConfiabilidadeExtensa DocumentaoIntruso mnima / inexistente
xhprof/xhgui
FacebookGUI WebMaior controle via PHP
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
GUI Nativa (Compatibilidade)
Dependncias (MongoDB)Documentao (Extenso, Way Back)Maior intruso no cdigo-fonteDocumentao Confusa (xhgui)
X
HowTo xdebug/KCacheGrind
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
Painis a esquerda: Flat Profile
Painis a direita: Quais funes chamaram/foram chamadas pela funo
HowTo xdebug/KCacheGrind Flat Profile
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
Tempo gasto na funo (sem filhas)
Quantas vezes a funo foi chamada
HowTo xdebug/KCacheGrind Callee Map
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
Representao visual do peso das funes/mtodos executados.
HowTo xdebug/KCacheGrind Callee Map
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
Tempo e quantidade de chamados da funo selecionada
Dicas - Atualize o PHP!
PHP 5.2 5.3*
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
* Ref.: Documentao Consideraes de Performance Garbage Collector
Otimizando a Execuo de Cfigo-Fonte PHP
Melhorias em requisies FastCGI Melhorias no Gerenciamento de Memria Melhoria no tempo de inicializao/encerramento Uso de CPU aproximadamente 15% menor Uso de memria aproximadamente 20% menor Latncia em requisio resposta melhorada em aproximadamente 14% Melhoria geral de performance de 10-15%
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
* Ref.: Rasmus Lerdorf PHP Frameworks Day 2013
PHP 5.3 5.4*
Otimizando a Execuo de Cfigo-Fonte PHP
Dicas - Atualize o PHP!
opcode Cache nativo Pilha de chamada pr-alocada pelo compilador Execuo melhorada de chamadas aninhadas
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
* Ref.: Rasmus Lerdorf PHP Conference Argentina
PHP 5.4 5.5*
Otimizando a Execuo de Cfigo-Fonte PHP
Dicas - Atualize o PHP!
Dicas Boas prticas
Use um Autoloader
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Sesses no DB
Output BufferingEvitar Getters & Setters simplesEvitar cpias de variveisEvitar queries SQL dentro de loopsEvitar execues desnecessrias de funes dentro de loops
Otimizando a Execuo de Cfigo-Fonte PHP
Boas prticas
Dicas - Configuraes
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
realpath_cache_size Afeta operaes com arquivosSe h muitas operaes de arquivos, aumente
realpath_cache_ttl Durao do cache de realpathSe arquivos raramente mudam, aumente
(< 5.4) register_long_arrays Se os arrays HTTP_*_VARS devem ser utilizadosDesative
register_argc_argv Para execuo de scripts de terminalDesative
include_path Path para incluso de arquivosMantenha o mais curto possvel
Otimizando a Execuo de Cfigo-Fonte PHP
Configuraes
Concluses
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP
Concluses
Profiling (xdebug); Boas Prticas; Tunning (PHP)
Ferramentas especficas que agregam
(Memcached, Gearman, etc...)
/ Ferramentas alternativas que substituem (Hack, HHVM, Phalcon/Zephyr, NginX)
Alteraes especficas de cdigo-fonte*
* Sobre opes de cdigo-fonte: http://phpbench.com/
Otimizando a Execuo de Cfigo-Fonte PHP
Obrigado!
? Dvidas? Crticas? Elogios?!
CC Attribution-ShareAlike 3.0 Unported License by Er Galvo Abbott - 2/23/14 - /
www.galvao.eti.br
Otimizando a Execuo de Cfigo-Fonte PHP