This document provides an overview of OPCache, PHP's opcode cache. It begins with introductions to PHP, how PHP works by parsing, compiling and executing code, and the need for an opcode cache. It then discusses what opcodes are and how OPCache works by caching compiled opcodes in shared memory to improve performance by avoiding recompilation. The document outlines various OPCache configuration settings and optimizations like interned strings. It provides examples of opcodes generated from PHP code and discusses tuning OPCache for best performance.
Create your own PHP extension, step by step - phpDay 2012 VeronaPatrick Allaert
Ever been interested by contributing to the PHP core team?
In this workshop you will not only learn how (easy it is) to create your own PHP extension from scratch but you will also strengthen your knowledge of PHP by disecting its internals.
After this workshop, you will be able to create an extension on your own, whether it is to optimize the most CPU intensive parts of your code, to create new bindings to C libraries or just to leverage your PHP knowledge.
And what if PHP was a web framework for the C developer?
This workshop requires a bit of C knowledge and preferably a *nix system.
PHP may seem to be a very easy language but many of don't know how PHP works. We will discuss the less known facts about PHP and we will also cover some common type of software design patterns used with PHP
From ReactPHP to Facebook Hack's Async implementation and many more, asynchronous programming has been a 'hot' topic lately. But how well does async programming support work in PHP and what can you actually use it for in your projects ? Let's look at some real-world use cases and how they leverage the power of async to do things you didn't know PHP could do.
With PHP 5.4 out and many production environments still running 5.2 (or older), it's time to paint a clear picture on why everyone should move to 5.3 and 5.4 and how to get code ready for the latest version of PHP. In this talk, we'll migrate an old piece of code using some standard and some very non-standard tools and techniques.
Create your own PHP extension, step by step - phpDay 2012 VeronaPatrick Allaert
Ever been interested by contributing to the PHP core team?
In this workshop you will not only learn how (easy it is) to create your own PHP extension from scratch but you will also strengthen your knowledge of PHP by disecting its internals.
After this workshop, you will be able to create an extension on your own, whether it is to optimize the most CPU intensive parts of your code, to create new bindings to C libraries or just to leverage your PHP knowledge.
And what if PHP was a web framework for the C developer?
This workshop requires a bit of C knowledge and preferably a *nix system.
PHP may seem to be a very easy language but many of don't know how PHP works. We will discuss the less known facts about PHP and we will also cover some common type of software design patterns used with PHP
From ReactPHP to Facebook Hack's Async implementation and many more, asynchronous programming has been a 'hot' topic lately. But how well does async programming support work in PHP and what can you actually use it for in your projects ? Let's look at some real-world use cases and how they leverage the power of async to do things you didn't know PHP could do.
With PHP 5.4 out and many production environments still running 5.2 (or older), it's time to paint a clear picture on why everyone should move to 5.3 and 5.4 and how to get code ready for the latest version of PHP. In this talk, we'll migrate an old piece of code using some standard and some very non-standard tools and techniques.
Today's high-traffic web sites must implement performance-boosting measures that reduce data processing and reduce load on the database, while increasing the speed of content delivery. One such method is the use of a cache to temporarily store whole pages, database recordsets, large objects, and sessions. While many caching mechanisms exist, memcached provides one of the fastest and easiest-to-use caching servers. Coupling memcached with the alternative PHP cache (APC) can greatly improve performance by reducing data processing time. In this talk, Ben Ramsey covers memcached and the pecl/memcached and pecl/apc extensions for PHP, exploring caching strategies, a variety of configuration options to fine-tune your caching solution, and discusses when it may be appropriate to use memcached vs. APC to cache objects or data.
Brief History of PHP
PHP (PHP: Hypertext Preprocessor) was created by Rasmus Lerdorf in 1994. It was initially developed for HTTP usage logging and server-side form generation in Unix.
PHP 2 (1995) transformed the language into a Server-side embedded scripting language. Added database support, file uploads, variables, arrays, recursive functions, conditionals, iteration, regular expressions, etc.
PHP 3 (1998) added support for ODBC data sources, multiple platform support, email protocols (SNMP,IMAP), and new parser written by Zeev Suraski and Andi Gutmans .
PHP 4 (2000) became an independent component of the web server for added efficiency. The parser was renamed the Zend Engine. Many security features were added.
PHP 5 (2004) adds Zend Engine II with object oriented programming, robust XML support using the libxml2 library, SOAP extension for interoperability with Web Services, SQLite has been bundled with PHP
What is PHP Used For?
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages
PHP can interact with MySQL databases
What is PHP?
PHP == ‘Hypertext Preprocessor’
Open-source, server-side scripting language
Used to generate dynamic web-pages
PHP scripts reside between reserved PHP tags
This allows the programmer to embed PHP scripts within HTML pages
What is PHP (cont’d)
Interpreted language, scripts are parsed at run-time rather than compiled beforehand
Executed on the server-side
Source-code not visible by client
‘View Source’ in browsers does not display the PHP code
Various built-in functions allow for fast development
Compatible with many popular databases
What does PHP code look like?
Structurally similar to C/C++
Supports procedural and object-oriented paradigm (to some degree)
All PHP statements end with a semi-colon
Each PHP script must be enclosed in the reserved PHP tag
Comments in PHP
Standard C, C++, and shell comment symbols
Variables in PHP
PHP variables must begin with a “$” sign
Case-sensitive ($Foo != $foo != $fOo)
Global and locally-scoped variables
Global variables can be used anywhere
Local variables restricted to a function or class
Certain variable names reserved by PHP
Form variables ($_POST, $_GET)
Server variables ($_SERVER)
Etc.
Variable usage
Arithmetic Operations
$a - $b // subtraction
$a * $b // multiplication
$a / $b // division
$a += 5 // $a = $a+5 Also works for *= and /=
Concatenation
Use a period to join strings into one.
If ... Else...
If (condition)
{
Statements;
}
Else
{
Statement;
}
While Loops
While (condition)
{
Statements;
}
Date Display
$datedisplay=date(“yyyy/m/d”);
Print $datedisplay;
# If the date is April 1st, 2009
# It would display as 2009/4/1
Month, Day & Date Format Symbols
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...anshkhurana01
php-mysql classes in navi-mumbai,php-mysql course-provider-in-navi-mumbai,best php-mysql class in navi-mumbai
B2/6/2 Vashi ,Navi Mumbai, Contact:09892900103/9892900173 enquiry@vibrantgroup.co.in
Apache est le serveur Web le plus utilisé sur la planète. Né en 1995, Apache HTTPD est aujourd'hui massivement utilisé pour supporter des applications PHP.
Cependant, peu de développeurs connaissent vraiment cette machine aussi complexe que robuste qui supporte leur langage fétiche : PHP.
Il n'est pas rare de voir des codes PHP exécutant des actions qu'Apache sait gérer en une seule ligne, de manière beaucoup plus efficace.
Nous parlerons donc généralités, HTTP, Cache, Proxing et nous passerons en revue les différentes manière de coupler Apache à PHP (mod_php, CGI et FCGI, mais aussi mpm_peruser, mpm_itk, suexec, suphp).
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
2. Hello everybody
Julien PAULI
Programming in PHP since ~20y (~1999-2000)
Programming in C for PHP Internals
PHP 5.5 and 5.6 Release Manager
Working at SensioLabs in Paris
http://www.phpinternalsbook.com co-author
@julienpauli - http://jpauli.tech - jpauli@php.net
3. What we'll cover together
Reminder on how PHP works
Introduction to OPCodes
The need of an OPCode cache
OPCache in deep
OPCache configuration settings
4. What is PHP ?
PHP
Programming language
"Scripting language"
No *manual* compilation needed
Fire and forget
Automatic memory management
Facultative strong typing. Type juggler
Provides OOP features
Highly dynamic, highly extensible
5. How does PHP work ?
Parsing
(Lexer + parser)
Compiling
Executing
opcodes
PHP code
AST nodes
Result
6. Zend Virtual Machine
Parsing
(Lexer + parser)
Compiling
Executing
"VirtualMachine"
Its purpose is to provide a platform-
independent programming
environment that abstracts away
details of the underlying hardware or
operating system, and allows a
program to execute in the same way
on any platform (Wikipedia)
7. The PHP way
Compile, execute, forget - Compile, execute, forget -
Compile, execute, forget - Compile, execute, forget -
Compile, execute, forget - Compile, execute, forget -
Compile, execute, forget - Compile, execute, forget …
By default (by design), PHP discards all the code it just
executed
Request n+1 knows nothing about request n
8. The PHP Way
If your pages get hit several times without changing (most
likely)
→ compile the same scripts several times
→ it still produces the same OPCodes
Parsing
(Lexer + parser)
Compiling
9. Compiling VS Executing
Compile, then execute
Which one is the longest ?
Depends on your scripts
Compile
Execute
Execute
Compile
11. Understanding compil. / exec.
Classes usually require much more compile time than exec
time
include / require / eval() = compile + execute
autoload = compile + execute
.. deffered at execution
Compile Execute
include/require ?
eval() ?
autoload ?
B
N
Y
E
13. Save at first run
Compiling
Executing
opcodes
AST nodes
Caching
opcodesShared
Memory
opcodes
save
time
File
System
OR
14. Load (same script) after
OPCode cache
Executing
opcodes
PHP code
opcodes
load
Shared
Memory
File
System
OR
15. Optimize
Why not optimize the OPCode array ?
opcodes
Optimizing
opcodes
opcodes
Caching
Compiling
save
Executing
opcodes
Shared
Memory
File
System
OR
17. OPCode
In computer science, an opcode (operation code) is the
portion of a machine language instruction that specifies the
operation to be performed. (Wikipedia)
Opcodes can also be found in so called byte codes and
other representations intended for a software interpreter
rather than a hardware device. (Wikipedia)
21. Example of OPCode
<?php
const DEF = "default";
if (isset($argv[1])) {
$b = (array)$argv[1];
} else {
$b = DEF;
}
var_dump($b);
Execution
Compilation
The more code to parse, the longer the compilation phase
The more OPCodes generated, the longer the execution
Depends on OPCodes, some are long to run, some are very fast
DECLARE_CONST
ISSET_ISEMPTY_DIM_OBJ
JMPZ
FETCH_DIM_R
CAST
ASSIGN
JMP
FETCH_CONSTANT
ASSIGN
INIT_FCALL
SEND_VAR
DO_ICALL
RETURN
22. Optimize execution
Some OPCodes are heavier than
others
OPCodes may be run several
times (in fact, yes they do)
The optimizer can play a role
Optimizing
Caching
Compiling
Executing
23. OPCache
"OPCache" is PHP OPCode cache
It is both a cache, and an optimizer
It is bundled by defaut with PHP
But it may not be activated by default
24. Optimizer
Tries to simplify/optimize the OPCodes so that there are
less of them and they are more efficient
Works on code branches (if, switch, try …)
Optimize constant expressions - Look for dead code / code reuse
25. Try the optimizer
php
-dzend_extension=opcache
-dopcache.enable_cli=1
-dopcache.opt_debug_level=0x30000
-dopcache.optimization_level=0x7FFFFFFF
/tmp/php.php
26. Optimizer impact
The optimizer is very heavy, and burns tons of CPU cycles
At compilation
But compilation only happens once, as opcodes will be
cached
So they'd better be cached optimized, than raw
The very first run of a big application should pay a big perf
penalty
Prime your caches
Use OPCache file-based cache
27. Interned strings optimized
In computer science, string interning is a method of storing
only one copy of each distinct string value, which must be
immutable. Interning strings makes some string processing
tasks more time- or space-efficient at the cost of requiring
more time when the string is created or interned. The
distinct values are stored in a string intern pool
Wikipedia
28. Interned strings concept
Anytime a static string occurs in compiler, memorize it,
and reuse its pointer when needed.
OPCache optimizes them even more
class foo
{
public function bar($a = "foo")
{
}
}
$foo = new foo;
$foo->bar("foo");
29. No Interned strings
class foo
{
public function bar($a = "foo")
{
}
}
$foo = new foo;
$foo->bar("foo");
foo bar a foo foo foo foo bar foo
memory
31. OPCache & interned strings
OPCache interns strings from all PHP processes of the same
PHP pool
Nice memory savings on big pools
interned string mem interned string mem interned string mem
interned string mem
36. OPCache settings
memory_consumption
Size of Shared Memory
Don't forget to increase according to your needs
Buy more RAM, NEVER have a cache full, have margin
max_accelerated_files (=2000)
Max number of KEYS to be stored
KEYS are paths to files : ./foo.php, ../foo.php, etc...
One file usually is ~= 2 to 3 KEYS
Aligned at next prime number
Slots are preallocated : don't give too high number
Monitor
38. OPCache settings
validate_timestamps (=true)
Check for file update to invalidate it
Checks are triggered every revalidate_freq seconds
revalidate_freq (=2)
How often check for file updates to invalidate them
0 = every time
Revalidate = syscall cached by PHP's realpath cache
revalidate_paths (=0)
1 : only the resolved realpath is used as cache key
0 : the unresolved path is also added as a cache key
use_cwd (=1)
prepend cwd to every cache key for relative paths
39. OPCache memory details
When a script changes, it is
recompiled (if validate_timestamps
= 1)
Its old memory space is then
considered as "wasted" (it is then
NOT freed)
When cache is full, if max_wasted_percentage is reached :
a cache restart is triggered
Cache restart = empty cache and recompile all
Cache is never restarted if not full
40. OPcache other settings
optimization_level (=0x7fffffff)
Enable/disable some optimizations.
enable_file_override (=0)
Redefines file_exists(), is_readable() and is_file() to look into cache
before : recommanded
blacklist_filename (=NULL)
Prevents caching some files you decide
consistency_checks (=0)
Computes a checksum at each file fetch. Not recommanded, ~5-
8% slowdown
opcache.save_comments (=1)
Saves PHPDoc comments to shared memory
41. OPcache other settings
enable_cli (=0)
Enables opcache in CLI mode
Long living apps like PHPUnit and COmposer mat benefit from the
optimizer and the cache
Other short scripts will pay an impact against the optimizer : don't
enable
huge_code_pages (=0)
Moves the PHP process code memory segment to huge pages
On some specific OS, with a mainly-statically-linked PHP, that can have
a beneficial impact
Check /proc/meminfo to activate HugePage before usage
protect_memory (=0)
mprotect() the SHM against writes. Useless until you find a bug, crash,
and want to debug it
42. Know what happens
error_log (=stderr)
File to write log to
log_verbosity_level (=1)
0=fatals … 4=debug
43. OPCache do's and don't's
Prime your cache smoothly
https://github.com/engineyard/ey-php-performance-tools
Prevent cache stampede
Have enough shared memory
Size your hashtables correctly
Try not to generate php files on runtime
Prevent highly modified files from beeing cached
Use blacklists
Every cache action will lock the shared memory
And PHP Engine is not threaded