SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
perlcc
or Reducing the startup cost of perl programs.
In the beginning…
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/9512/msg00900.html
(What’s a modem?)
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/9512/msg00904.html
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/9601/msg00124.html
Perl run states
• BEGIN
• Code is always executed as soon as it’s seen.
• UNITCHECK
• Code is run (LIFO) just after each file is compiled
• CHECK
• Code is run LIFO after ALL compilation
• B::C hooks here to do it’s magic
• INIT
• Runs FIFO at beginning of run time
• Does NOT run if module is loaded at runtime.
• END
• Run LIFO after exit()
http://perldoc.perl.org/perlmod.html
B.pm
• Compiler backend.
• Allows a Perl program to delve into its own innards
• Used by B::C to generate state information at the end
of the CHECK block
O.pm
• Interface to the compiler
• perl -MO=WHATEVA program.pl
• puts program into -c mode
• creates a CHECK block which runs
B::WHATEVA::compile with some info from the
compile process.
B::C
• Reduces your compile time to near zero by freezing
state at end of CHECK block
• perl -MO=-qq,C,-O3,-omyprog.c myprog.pl
• captures perl running state and writes out myprog.c
• compiled binary will start at INIT state
File handle gotchas
• opening file handles during compile and expecting
them to functon at run time
• BEGIN { open($fh, ‘<‘, ‘/var/log/foo’) or die }
• sub later { while(<$fh>) {…} }
• This also goes for things like numeric handles to
external libaries ( i.e. openssl handles (IO::Socket::SSL)
• https://rt.cpan.org/Public/Bug/Display.html?id=95452
What B::C is not
Doesn’t speed up your
program.
(mostly)
Can’t statically compile in XS
(mostly)
Can’t live independent of
libperl
(mostly)
What B::C can do
Speeds page hit of
traditional CGI apps.
( No running process when idle )
Shrink your program memory
size.
• Package removal during C code generation
• COW strings stored as C strings
• duplicates consolidated to 1 string.
• Strings, Arrays, Hashes optimized to perfect size.
Reducing your Moose
startup time
(Eventually)
https://code.google.com/p/perl-compiler/issues/detail?id=350
#damnitstevan
B::C Time Line
• 1995 - Announcement
• 1996 - Compiler development started (B, O, B::C)
• 1998 - a8581515f - Integrated into core (5.005)
• November 2003 - Perl 5.6.2
• December 2007 - Removed in 5.10.0
• June 2014 - Mostly Stable - 5.14.4
Today
• cPanel initiated effort to get B::C working.
• cPanel Perl code can compile and run against 5.14.4
• perlcc script does all the magic now
• perlcc -e ‘print “Hello worldn”’; ./a.out
• perlcc -o foo foo.pl
• Optimizations (-O1/-O2/-O3)
In the Past
$> cpanm B::C
#Installs perlcc into your perl bin directory
$> perl -MO=-qq,C,-O3,-fno-fold,-ot/C-COMPILED/
CORE—io--print.c t/C-COMPILED/CORE—io—print.t
$> perl script/cc_harness -q t/CORE-CPANEL/io/CORE
—io—print.c -o t/CORE-CPANEL/io/CORE—io—print.bin
$> ./t/CORE-CPANEL/io/CORE—io—print.bin
Example
$> cpanm B::C
$> perlcc -o foo foo.pl
$> ./foo
Hello World!
Tomorrow
• B::C Working on latest perl
• Compiled perl modules to .so files
• Byte Loader?
• B::CC
More information?
• irc.perl.org #compiler
• Issues: https://code.google.com/p/perl-compiler/issues/list
• Contribute: https://github.com/rurban/perl-compiler
• master (unstable)
• release (most recently released to CPAN)
• CPAN: https://metacpan.org/pod/B::C
• Me: Todd Rinaldo <toddr@cpan.org>

Weitere ähnliche Inhalte

Was ist angesagt?

How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)Wilfried Schobeiri
 
PHP Tour 2016 Phinx Presentation
PHP Tour 2016 Phinx PresentationPHP Tour 2016 Phinx Presentation
PHP Tour 2016 Phinx PresentationRob Morgan
 
Proxying DBI with DBD::Gofer and App::Staticperl
Proxying DBI with DBD::Gofer and App::StaticperlProxying DBI with DBD::Gofer and App::Staticperl
Proxying DBI with DBD::Gofer and App::Staticperlnohuhu
 
ruby + websocket + haproxy
ruby + websocket + haproxyruby + websocket + haproxy
ruby + websocket + haproxyMathieu Elie
 
App::RemoteCommand
App::RemoteCommandApp::RemoteCommand
App::RemoteCommandShoichi Kaji
 
10 Things you should know about Ruby
10 Things you should know about Ruby10 Things you should know about Ruby
10 Things you should know about Rubysikachu
 
Apache Camel workshop at BarcelonaJUG in January 2014
Apache Camel workshop at BarcelonaJUG in January 2014Apache Camel workshop at BarcelonaJUG in January 2014
Apache Camel workshop at BarcelonaJUG in January 2014Claus Ibsen
 
RedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with ChefRedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with ChefRitesh Angural
 
Creating SaltStack State data with Pyobjects
Creating SaltStack State data with PyobjectsCreating SaltStack State data with Pyobjects
Creating SaltStack State data with PyobjectsEvan Borgstrom
 
Travel with your mock server
Travel with your mock serverTravel with your mock server
Travel with your mock serverJorge Ortiz
 
Automated deployments using envoy by John Blackmore
Automated deployments using envoy by John BlackmoreAutomated deployments using envoy by John Blackmore
Automated deployments using envoy by John BlackmoreTechExeter
 
Scapy the packet 途中01
Scapy the packet 途中01Scapy the packet 途中01
Scapy the packet 途中01saba syake
 
Phinx CloudConf 2016 Presentation
Phinx CloudConf 2016 PresentationPhinx CloudConf 2016 Presentation
Phinx CloudConf 2016 PresentationRob Morgan
 
BSides London - Scapy Workshop
BSides London - Scapy WorkshopBSides London - Scapy Workshop
BSides London - Scapy WorkshopAdam Maxwell
 
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...Ortus Solutions, Corp
 
Extending Foreman the easy way with foreman_hooks
Extending Foreman the easy way with foreman_hooksExtending Foreman the easy way with foreman_hooks
Extending Foreman the easy way with foreman_hooksDominic Cleal
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014brian d foy
 

Was ist angesagt? (20)

How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
 
PHP Tour 2016 Phinx Presentation
PHP Tour 2016 Phinx PresentationPHP Tour 2016 Phinx Presentation
PHP Tour 2016 Phinx Presentation
 
Proxying DBI with DBD::Gofer and App::Staticperl
Proxying DBI with DBD::Gofer and App::StaticperlProxying DBI with DBD::Gofer and App::Staticperl
Proxying DBI with DBD::Gofer and App::Staticperl
 
ruby + websocket + haproxy
ruby + websocket + haproxyruby + websocket + haproxy
ruby + websocket + haproxy
 
App::RemoteCommand
App::RemoteCommandApp::RemoteCommand
App::RemoteCommand
 
Composer
ComposerComposer
Composer
 
10 Things you should know about Ruby
10 Things you should know about Ruby10 Things you should know about Ruby
10 Things you should know about Ruby
 
Apache Camel workshop at BarcelonaJUG in January 2014
Apache Camel workshop at BarcelonaJUG in January 2014Apache Camel workshop at BarcelonaJUG in January 2014
Apache Camel workshop at BarcelonaJUG in January 2014
 
RedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with ChefRedMart Migrating from EC2 to VPC with Chef
RedMart Migrating from EC2 to VPC with Chef
 
Creating SaltStack State data with Pyobjects
Creating SaltStack State data with PyobjectsCreating SaltStack State data with Pyobjects
Creating SaltStack State data with Pyobjects
 
Travel with your mock server
Travel with your mock serverTravel with your mock server
Travel with your mock server
 
Automated deployments using envoy by John Blackmore
Automated deployments using envoy by John BlackmoreAutomated deployments using envoy by John Blackmore
Automated deployments using envoy by John Blackmore
 
Scapy the packet 途中01
Scapy the packet 途中01Scapy the packet 途中01
Scapy the packet 途中01
 
Phinx CloudConf 2016 Presentation
Phinx CloudConf 2016 PresentationPhinx CloudConf 2016 Presentation
Phinx CloudConf 2016 Presentation
 
BSides London - Scapy Workshop
BSides London - Scapy WorkshopBSides London - Scapy Workshop
BSides London - Scapy Workshop
 
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
 
Extending Foreman the easy way with foreman_hooks
Extending Foreman the easy way with foreman_hooksExtending Foreman the easy way with foreman_hooks
Extending Foreman the easy way with foreman_hooks
 
Why I Love CPAN
Why I Love CPANWhy I Love CPAN
Why I Love CPAN
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
 
Perlbrew
PerlbrewPerlbrew
Perlbrew
 

Ähnlich wie perlcc made easy or, how to make a CGI Moose app

Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)p3castro
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelUnikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelThe Linux Foundation
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Molliewillemstuursma
 
ITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIOrtus Solutions, Corp
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?AFUP_Limoges
 
Conan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for DevelopersConan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for DevelopersUilian Ries
 
Pentesting tricks - Out with Powershell, in with C#
Pentesting tricks - Out with Powershell, in with C#Pentesting tricks - Out with Powershell, in with C#
Pentesting tricks - Out with Powershell, in with C#Michelangelo Sidagni
 
Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer George Markomanolis
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone CivettaCocoaHeads France
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 
Ruby v cpp_preso
Ruby v cpp_presoRuby v cpp_preso
Ruby v cpp_presojessicard
 
ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)
ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)
ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)DynamicInfraDays
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet
 

Ähnlich wie perlcc made easy or, how to make a CGI Moose app (20)

CommandBox at CFCamp 2014
CommandBox at CFCamp 2014CommandBox at CFCamp 2014
CommandBox at CFCamp 2014
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Command box
Command boxCommand box
Command box
 
Command box
Command boxCommand box
Command box
 
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernelUnikernel User Summit 2015: Getting started in unikernels using the rump kernel
Unikernel User Summit 2015: Getting started in unikernels using the rump kernel
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Mollie
 
CommandBox : Free CFML
CommandBox : Free CFMLCommandBox : Free CFML
CommandBox : Free CFML
 
ITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLI
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?
 
Conan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for DevelopersConan.io - The C/C++ package manager for Developers
Conan.io - The C/C++ package manager for Developers
 
Pentesting tricks - Out with Powershell, in with C#
Pentesting tricks - Out with Powershell, in with C#Pentesting tricks - Out with Powershell, in with C#
Pentesting tricks - Out with Powershell, in with C#
 
Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer Exploring the Programming Models for the LUMI Supercomputer
Exploring the Programming Models for the LUMI Supercomputer
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Monkey space 2013
Monkey space 2013Monkey space 2013
Monkey space 2013
 
Ruby v cpp_preso
Ruby v cpp_presoRuby v cpp_preso
Ruby v cpp_preso
 
ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)
ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)
ContainerDays Boston 2015: "Continuous Delivery with Containers" (Nick Gauthier)
 
Attack on the Core
Attack on the CoreAttack on the Core
Attack on the Core
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 

Kürzlich hochgeladen

Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

perlcc made easy or, how to make a CGI Moose app

  • 1. perlcc or Reducing the startup cost of perl programs.
  • 5. Perl run states • BEGIN • Code is always executed as soon as it’s seen. • UNITCHECK • Code is run (LIFO) just after each file is compiled • CHECK • Code is run LIFO after ALL compilation • B::C hooks here to do it’s magic • INIT • Runs FIFO at beginning of run time • Does NOT run if module is loaded at runtime. • END • Run LIFO after exit() http://perldoc.perl.org/perlmod.html
  • 6.
  • 7. B.pm • Compiler backend. • Allows a Perl program to delve into its own innards • Used by B::C to generate state information at the end of the CHECK block
  • 8. O.pm • Interface to the compiler • perl -MO=WHATEVA program.pl • puts program into -c mode • creates a CHECK block which runs B::WHATEVA::compile with some info from the compile process.
  • 9. B::C • Reduces your compile time to near zero by freezing state at end of CHECK block • perl -MO=-qq,C,-O3,-omyprog.c myprog.pl • captures perl running state and writes out myprog.c • compiled binary will start at INIT state
  • 10. File handle gotchas • opening file handles during compile and expecting them to functon at run time • BEGIN { open($fh, ‘<‘, ‘/var/log/foo’) or die } • sub later { while(<$fh>) {…} } • This also goes for things like numeric handles to external libaries ( i.e. openssl handles (IO::Socket::SSL) • https://rt.cpan.org/Public/Bug/Display.html?id=95452
  • 12. Doesn’t speed up your program. (mostly)
  • 13. Can’t statically compile in XS (mostly)
  • 14. Can’t live independent of libperl (mostly)
  • 16. Speeds page hit of traditional CGI apps. ( No running process when idle )
  • 17. Shrink your program memory size. • Package removal during C code generation • COW strings stored as C strings • duplicates consolidated to 1 string. • Strings, Arrays, Hashes optimized to perfect size.
  • 18. Reducing your Moose startup time (Eventually) https://code.google.com/p/perl-compiler/issues/detail?id=350 #damnitstevan
  • 19. B::C Time Line • 1995 - Announcement • 1996 - Compiler development started (B, O, B::C) • 1998 - a8581515f - Integrated into core (5.005) • November 2003 - Perl 5.6.2 • December 2007 - Removed in 5.10.0 • June 2014 - Mostly Stable - 5.14.4
  • 20. Today • cPanel initiated effort to get B::C working. • cPanel Perl code can compile and run against 5.14.4 • perlcc script does all the magic now • perlcc -e ‘print “Hello worldn”’; ./a.out • perlcc -o foo foo.pl • Optimizations (-O1/-O2/-O3)
  • 21. In the Past $> cpanm B::C #Installs perlcc into your perl bin directory $> perl -MO=-qq,C,-O3,-fno-fold,-ot/C-COMPILED/ CORE—io--print.c t/C-COMPILED/CORE—io—print.t $> perl script/cc_harness -q t/CORE-CPANEL/io/CORE —io—print.c -o t/CORE-CPANEL/io/CORE—io—print.bin $> ./t/CORE-CPANEL/io/CORE—io—print.bin
  • 22. Example $> cpanm B::C $> perlcc -o foo foo.pl $> ./foo Hello World!
  • 23. Tomorrow • B::C Working on latest perl • Compiled perl modules to .so files • Byte Loader? • B::CC
  • 24. More information? • irc.perl.org #compiler • Issues: https://code.google.com/p/perl-compiler/issues/list • Contribute: https://github.com/rurban/perl-compiler • master (unstable) • release (most recently released to CPAN) • CPAN: https://metacpan.org/pod/B::C • Me: Todd Rinaldo <toddr@cpan.org>