목차
Why Windows-PHP team used Profile Guided Optimization (PGO)?
What are the 'key steps' performed by the Windows PHP team for PGO'izing Windows PHP binaries?    
What were the 'key challenges' faced by the Windows PHP team while PGO'izing Windows PHP binaries?
What are the performance gains received by the Windows PHP team by PGO'izing their binaries?
Wrap up" >Wrap up
php教程 php手册 Speed up Windows PHP Performance using Profile Gui

Speed up Windows PHP Performance using Profile Gui

Jun 06, 2016 pm 08:09 PM
performance php speed windows

To introduce myself I am Ankit Asthana and I am the program manager for the backend C++ compiler. In my last two blogs I provided an introduction to what Profile Guided Optimization (PGO) is all about and a case study which illustrates how

To introduce myself I am Ankit Asthana and I am the program manager for the backend C++ compiler. In my last two blogs I provided an introduction to what Profile Guided Optimization (PGO) is all about and a case study which illustrates how PGO is used to make SAP NetWeaver faster.  In this blog I would like to present the story about how PGO is used make official Windows PHP binaries faster. Stephen Zarkos (Program Manager for Windows PHP) has been kind enough for providing the content for this blog.

 After reading this blog you folks should be able to further understand and use this case study to introduce PGO for your applications. In addition to this, for experienced PHP users, this blog post should serve as an optimization opportunity to further optimize Windows PHP performance for their specific workloads. So let's get started!

As most of you probably already know PHP is a server side scripting language designed for web development but also used as a general purpose programming language. PHP is heavily used today and it powers millions of websites and webservers. In addition to this PHP is also used to power a plethora of open source content management system (CMS) such as Joomla, WordPress and Drupal.

The effort to PGO'ize the Windows PHP binaries was led by Microsoft Open Source Technology (OSTC) group. OSTC's primary goal is to work with open-source communities to help their software interoperate with or run better on Windows Server and Windows Azure. To be precise, this is not the only group at Microsoft that works with open source but amazingly these days is only one of many. A few examples of projects this group works on are PHP on Windows, Openstack with Hyper-V, CoApp (coapp.org) and the Linux Integration Services for Hyper-V and Azure.     

Why Windows-PHP team used Profile Guided Optimization (PGO)?

Over the past several years, Microsoft and its partners have worked diligently with the PHP community to improve the experience PHP developers and users have on Windows Server and Windows Azure. As a result newer versions of PHP (i.e. PHP 5.4) for Windows include dramatic improvements that come from a deep collaboration between the PHP Core Maintainers and Microsoft. One factor attributing to a faster Windows PHP 5.4 and 5.5 is Profile Guided Optimization (PGO). The overall goal with this collaboration is to improve PHP on Windows and enable Windows specific capabilities in a way that provides PHP users the same (or better, if possible) capabilities that they see on other platforms.

After having tested the water with using PGO for Windows PHP 5.3, the team was finally able to incorporate PGO for Windows PHP 5.4. Performance is a primary goal for the Windows PHP team which served as the key reason behind PGO'izing the PHP binaries on Windows. PGO provided an important opportunity to optimize the performance of the PHP interpreter without changing any functional behavior. 

What are the 'key steps' performed by the Windows PHP team for PGO'izing Windows PHP binaries?    

Revisiting my previous blogs, there are essentially three steps required in PGO'izing an application (Instrument, Train and Optimize). Remember the 'Instrument' and 'Optimize' steps require an 'LTCG:PGINSTRUMENT' and 'LTCG:PGOPTIMIZE' build respectively (for more information please take a look at my last blog post).

The steps to PGO'ize Windows PHP binaries are essentially in-line with PGO'izing any generic application and are as follows:

  • Creating an Instrumented build of Windows PHP binaries (i.e. the Instrumentation Phase)

    For those of you who would like to get some firsthand experience in doing this, creating an instrumented version of the Windows PHP binaries requires user to pass the additional '--enable-pgi' parameter to the PHP configure script. After running the configure script just rebuild with 'nmake snap'. For more detailed instructions on how to set this up take a look at this blog post.
     
  • Collecting Training Data (i.e. the Train Phase)

    This step can be as simple as setting up PHP with IIS or Apache with your PHP application and then accessing the application via a web-browser. A good training session should exercise workflows that your users will hit most often. The Windows PHP team currently trains by having a number of PHP applications preconfigured, for both IIS and Apache (on Windows) and then exercising these applications via requesting specific pages (usually several times for the most used pages) in order to get wide coverage. As of today, the Windows PHP team trains with every snapshot and release build of PHP binaries.

    Snapshot builds can happen multiple times a day (depending on the number of commits on that particular day).  Every snapshot for PHP 5.4, 5.5 and the Master branch is automated where the build automation goes through the process of creating the instrumented binary, setting up IIS and Apache, running through a series of applications to produce the training data, copying those back to the PHP build directory and then finally rebuilding the optimized PHP.

    The end result of the training phase is the "*.pgc" files which are essentially training data files that contain all the information required by the 'Optimize phase'. You need to copy these files back into your PHP build directory for the next phase of the build.
     
  • Building optimized Windows PHP binaries (i.e. the Optimize Phase)

    A user can build an optimized version of PHP binaries following the simple steps listed below:
    a. Copy the *.pgc files back to your PHP build directory
    b. Run the command "nmake --clean-pgo" to clean your build directory (but not the .pgc files)
    c. Re-run the configure script, but remove the "--enable-pgi" parameter and instead add the "--with-pgo" parameter
    d. Run "nmake" and then "nmake snap" to build the final optimized PHP

This entire process can take several hours, depending upon the speed of your build machine. For best results (i.e higher build throughput and maximum PGO performance gains), use Visual Studio 2012 RTM. 

What were the 'key challenges' faced by the Windows PHP team while PGO'izing Windows PHP binaries?

The work for PGO'izing PHP began as a proof of concept exercise. The Windows PHP team did some work several years ago to test PGO and see how they can leverage it for PHP. This exercise was useful in finding the following few key challenges which the team addressed when enabling PGO for PHP 5.4:

  • How to train the PHP binaries: At first it was difficult for the Windows PHP team to understand how best to train the PHP Windows binaries. In particular, 'what training scenarios to run?', 'how long to train for?' and 'what kind of applications to train with?'
     
  • Absorbing longer build times: To save man hours, every part of the 'Windows PHP PGO build process was automated. Adding PGO to the build process was a fairly easy exercise, but the main challenge here was to deal with the additional build times required. Given the Windows PHP has various builds (thread-safe, non-thread, and now x86 & x64 for PHP 5.5) to absorb the additional build times they needed to add more/faster build systems, and improve their build automation to support concurrent builds.
     
  • Additional quality assurance required: Validating the effectiveness of your PGO training scenario is essential and plays a major part in obtaining maximum performance gains. Good testing is still the key to the success of PGO in PHP.  At the time PHP 5.4 was released the Windows PHP team had pretty good test automation and hence were able to identify issues where using PGO changed the behavior of PHP.  These issues observed were then mitigated by the use of #pragma statements.

What are the performance gains received by the Windows PHP team by PGO'izing their binaries?

For testing PHP performance, applications such as Drupal, Mediawiki, Wordpress and Joomla are deployed on IIS and Apache webservers. These applications are then stressed using load agents and various metrics such as transactions per second (TPS) are recorded and reported. To better demonstrate the performance improvements we can see with PGO, the 'TPS' for these applications with/without PGO'ized PHP binaries is listed in the table below:           

             

                               Table 1: Performance gain for applications leveraging PGO'ized Windows PHP 5.5

As you can see some of these results are pretty impressive! A detailed summary of these results which includes some of the gritty details used to generate these results can be found here.

Wrap up

Although Profile Guided Optimization (PGO) is a complex technology, I hope this blog provides you further evidence on the usefulness of PGO and does a fair job in explaining how the Windows PHP team PGO'ized the Windows PHP binaries. In my future blogs I will go over how PGO works under the hood to provide the performance gains enjoyed by a plethora of products out there.

So stay tuned! Additionally, if you would like us to blog about some other PGO-related scenarios or are just curios and have a few more questions about PGO please feel free to reach out to me. I will do my best to answer them.

Speed up Windows PHP Performance using Profile Gui
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

JWT (JSON Web Tokens) 및 PHP API의 사용 사례를 설명하십시오. JWT (JSON Web Tokens) 및 PHP API의 사용 사례를 설명하십시오. Apr 05, 2025 am 12:04 AM

JWT는 주로 신분증 인증 및 정보 교환을 위해 당사자간에 정보를 안전하게 전송하는 데 사용되는 JSON을 기반으로 한 개방형 표준입니다. 1. JWT는 헤더, 페이로드 및 서명의 세 부분으로 구성됩니다. 2. JWT의 작업 원칙에는 세 가지 단계가 포함됩니다. JWT 생성, JWT 확인 및 Parsing Payload. 3. PHP에서 인증에 JWT를 사용하면 JWT를 생성하고 확인할 수 있으며 사용자 역할 및 권한 정보가 고급 사용에 포함될 수 있습니다. 4. 일반적인 오류에는 서명 검증 실패, 토큰 만료 및 대형 페이로드가 포함됩니다. 디버깅 기술에는 디버깅 도구 및 로깅 사용이 포함됩니다. 5. 성능 최적화 및 모범 사례에는 적절한 시그니처 알고리즘 사용, 타당성 기간 설정 합리적,

매치 표현식 (PHP 8)과 스위치와 어떻게 다른지 설명하십시오. 매치 표현식 (PHP 8)과 스위치와 어떻게 다른지 설명하십시오. Apr 06, 2025 am 12:03 AM

PHP8에서 매치 표현식은 표현식의 값에 따라 다른 결과를 반환하는 새로운 제어 구조입니다. 1) 스위치 명령문과 유사하지만 실행 명령문 블록 대신 값을 반환합니다. 2) 경기 표현식은 엄격하게 비교되어 (===) 보안을 향상시킵니다. 3) 스위치 명세서에서 가능한 파손을 피하고 코드의 단순성과 가독성을 향상시킵니다.

Windows 7에 MySQL을 설치할 수 있습니까? Windows 7에 MySQL을 설치할 수 있습니까? Apr 08, 2025 pm 03:21 PM

예, MySQL은 Windows 7에 설치 될 수 있으며 Microsoft는 Windows 7 지원을 중단했지만 MySQL은 여전히 ​​호환됩니다. 그러나 설치 프로세스 중에 다음 지점이 표시되어야합니다. Windows 용 MySQL 설치 프로그램을 다운로드하십시오. MySQL의 적절한 버전 (커뮤니티 또는 기업)을 선택하십시오. 설치 프로세스 중에 적절한 설치 디렉토리 및 문자를 선택하십시오. 루트 사용자 비밀번호를 설정하고 올바르게 유지하십시오. 테스트를 위해 데이터베이스에 연결하십시오. Windows 7의 호환성 및 보안 문제에 주목하고 지원되는 운영 체제로 업그레이드하는 것이 좋습니다.

CSRF (Cross-Site Request Grospory) 란 무엇이며 PHP에서 CSRF 보호를 어떻게 구현합니까? CSRF (Cross-Site Request Grospory) 란 무엇이며 PHP에서 CSRF 보호를 어떻게 구현합니까? Apr 07, 2025 am 12:02 AM

PHP에서는 예측할 수없는 토큰을 사용하여 CSRF 공격을 효과적으로 방지 할 수 있습니다. 특정 방법은 다음과 같습니다. 1. 형태로 CSRF 토큰을 생성하고 포함시킨다. 2. 요청을 처리 할 때 토큰의 유효성을 확인하십시오.

클래스가 확장되지 않거나 방법이 PHP에서 무시되지 않도록하려면 어떻게해야합니까? (최종 키워드) 클래스가 확장되지 않거나 방법이 PHP에서 무시되지 않도록하려면 어떻게해야합니까? (최종 키워드) Apr 08, 2025 am 12:03 AM

PHP에서 최종 키워드는 클래스가 상속되고 메소드가 덮어 쓰는 것을 방지하는 데 사용됩니다. 1) 클래스를 최종적으로 표시 할 때는 수업을 상속받을 수 없습니다. 2) 메소드를 최종으로 표시 할 때는 메소드를 서브 클래스로 다시 작성할 수 없습니다. 최종 키워드를 사용하면 코드의 안정성과 보안이 보장됩니다.

PS의 로딩 속도 속도를 높이는 방법? PS의 로딩 속도 속도를 높이는 방법? Apr 06, 2025 pm 06:27 PM

느린 Photoshop 스타트 업 문제를 해결하려면 다음을 포함한 다중 프론트 접근 방식이 필요합니다. 하드웨어 업그레이드 (메모리, 솔리드 스테이트 드라이브, CPU); 구식 또는 양립 할 수없는 플러그인 제거; 정기적으로 시스템 쓰레기 및 과도한 배경 프로그램 청소; 주의를 기울여 관련없는 프로그램 폐쇄; 시작하는 동안 많은 파일을 열지 않도록합니다.

php에서 엄격한 유형을 설명하십시오 (strict_types = 1);). php에서 엄격한 유형을 설명하십시오 (strict_types = 1);). Apr 07, 2025 am 12:05 AM

php의 엄격한 유형은 declare (strict_types = 1)를 추가하여 활성화됩니다. 파일 상단에서. 1) 함정 유형 변환을 방지하기 위해 함수 매개 변수 및 리턴 값의 검사 유형 검사를 강요합니다. 2) 엄격한 유형을 사용하면 코드의 신뢰성과 예측 가능성을 향상시키고 버그를 줄이며 유지 관리 및 가독성을 향상시킬 수 있습니다.

See all articles