SlideShare a Scribd company logo
1 of 33
Download to read offline
© 2016– Andrei Alexandrescu. Do not redistribute. 1 / 33
Opening Keynote
Prepared for DConf 2016
Andrei Alexandrescu, Ph.D.
2016-05-04
© 2016– Andrei Alexandrescu. Do not redistribute. 2 / 33
Welcome to DConf
2016!
Sup
© 2016– Andrei Alexandrescu. Do not redistribute. 3 / 33
First Five Minutes
© 2016– Andrei Alexandrescu. Do not redistribute. 5 / 33
• First five minutes become the next five years
• Out of the box experience
◦ Website
◦ Tutorials
◦ Documentation
◦ Libraries
• (Self-)Curating dub
Scaling Up
© 2016– Andrei Alexandrescu. Do not redistribute. 6 / 33
• Many thanks for a great year!
◦ Thanks for being here!
◦ The Foundation is up!
• Roles: build czar, sysadmin, webmaster, social
media, conference organizer. . .
• Enhance the “point of contact” approach
• Please get me fired!
• I’m in charge of too many things
Raising the Bar on Contributions
© 2016– Andrei Alexandrescu. Do not redistribute. 7 / 33
• The weird thing about “okay work”
• Reasons to NOT pull something:
◦ “Porque no?”
◦ Respected contributor
◦ “That’s a lot of work”
◦ One-liners and many-liners
◦ Renames
◦ Refactorings showing no clear
improvement
• Churn, illusion of progress
Raising the Bar on Contributions
© 2016– Andrei Alexandrescu. Do not redistribute. 8 / 33
• Reasons to pull something:
◦ Adds value
◦ Refactors for a net benefit
◦ Fixes a bug “positively”
◦ Makes code simpler
◦ Makes code faster
◦ Automates
◦ Improves documentation
• talent × time = win
Resource Management
© 2016– Andrei Alexandrescu. Do not redistribute. 9 / 33
Take the Garbage Out
© 2016– Andrei Alexandrescu. Do not redistribute. 10 / 33
Commit to making D
great with and without
a GC
Issues with RC
© 2016– Andrei Alexandrescu. Do not redistribute. 11 / 33
• Overall: RC a qualified success story in
computing
• Make it work with immutable
• Make it safe
• Make it work with classes and value types
• Make it work lazily (COW)
◦ Copies should not have arbitrary cost
Basics
© 2016– Andrei Alexandrescu. Do not redistribute. 12 / 33
• The C++ way: library smart pointers
+ Apply to any type
− Apply to any type (unsafe)
− Needs mutable
• Envisioned:
◦ In-language support + library hooks
◦ Attribute @rc
◦ opIncRef(uint), opDecRef(uint)
Safety
© 2016– Andrei Alexandrescu. Do not redistribute. 13 / 33
• Main issue: unaccounted refs
struct RC { int a; ... }
void fun(ref RC obj, ref int x) {
obj = RC();
... use x ...
}
void gun() {
RC obj = ...;
fun(obj, obj.f);
}
• Variant: obj is global
• Attack: Insert extra incs/decs for ref params
• Fuse successive incs/decs where possible
• Elide increments where possible
immutable
© 2016– Andrei Alexandrescu. Do not redistribute. 14 / 33
• Apparent contradiction!
◦ immutable: “I’ll never change, honey”
◦ RC: surreptitious change in metadata
• We considered revoking immutable rights for
RC objects
• If only we had a means to:
◦ allocate metadata along with each object
◦ type metadata independently
◦ access metadata in O(1). . .
© 2016– Andrei Alexandrescu. Do not redistribute. 15 / 33
“Why do you completely discard
external reference counting
approach (i.e. storing refcount in
GC/allocator internal data
structures bound to allocated
memory blocks)?”
– Dicebot
© 2016– Andrei Alexandrescu. Do not redistribute. 16 / 33
“Never ascribe to malice that
which is adequately explained by
incompetence.”
– Robert J. Hanlon
AffixAllocator!. . . AffixAllocator!. . .
© 2016– Andrei Alexandrescu. Do not redistribute. 17 / 33
• Part of std.experimental.allocator from
day one
• AffixAllocator!(GCAllocator, uint):
◦ fronts each allocation with an extra uint
◦ . . . that’s independently typed
◦ Accessible in O(1)!
• Use this allocator for creating RC objects
import bigo;
© 2016– Andrei Alexandrescu. Do not redistribute. 18 / 33
“Big O” Notation
© 2016– Andrei Alexandrescu. Do not redistribute. 19 / 33
• Compact characterization of algorithms
• Growing importance in recent years
• Usually confined to documentation
• Pen and paper suffices for non-generic code
• Better: make it generic and a discoverable
part of the API
Scaling Naming Conventions
© 2016– Andrei Alexandrescu. Do not redistribute. 20 / 33
• Nomenclature approaches don’t scale
• removeLinTime, removeLogTime,
removeConstTime
• Hierarchy of speeds: faster functions
subsume slower ones
• Sometimes O(·) depends on 2+ parameters
• Helpless with HOFs
• Doesn’t scale to large APIs
• We want to automate this
Related Work
© 2016– Andrei Alexandrescu. Do not redistribute. 21 / 33
• Java: initially complexity-oblivious APIs
◦ Later: RandomAccess “marker” interface
• STL carefully specifies complexity
◦ Archetypal examples: push_front,
push_back, operator[]
◦ Syntax complexity follows algo complexity
◦ Undecided on “best effort” vs. “present or
not”, e.g. distance
Loosely Related Work
© 2016– Andrei Alexandrescu. Do not redistribute. 22 / 33
• O(·) analysis part of typechecking (Marion
2011)
• Automated Higher-Order Complexity Analysis
(Benzinger 2004)
• Monotonic State (Pilkiewicz et al 2011)
Here
© 2016– Andrei Alexandrescu. Do not redistribute. 23 / 33
• User:
◦ Introduces annotations
◦ Defines composition
• Framework:
◦ Provides algebra
◦ Propagates attributes
◦ Calculates composition
• Notably for higher-order functions
◦ Makes result available by static
introspection
Synopsis
© 2016– Andrei Alexandrescu. Do not redistribute. 24 / 33
// Generic doubly-linked list of E
struct DoublyLinkedList(E) {
...
// Complexity is O(1)
void insertFront(E x) @O(1);
}
// Generic contiguous array of E
struct Array(E) {
...
// Complexity is O(n) in the first argument (this)
void insertFront(E x) @O("n");
}
Synopsis
© 2016– Andrei Alexandrescu. Do not redistribute. 25 / 33
// Complexity of insertFrontMany is the complexity of
// C.insertFront multiplied by the size of the second
// argument.
void insertFrontMany(C, E)(ref C container, E[] items)
@(complexity!(C.insertFront) * O("n2")) {
foreach (item; items) {
c.insertFront(item);
}
}
Introspection
© 2016– Andrei Alexandrescu. Do not redistribute. 26 / 33
static assert(
complexity!(insertFrontMany!MyC) <=
O("n2") * log(O("n1")),
"Too high complexity for insertFrontMany.");
Conventions
© 2016– Andrei Alexandrescu. Do not redistribute. 27 / 33
• Unannotated functions are considered O(1)
• "nk" for the kth parameter
• this is the first parameter
• "n" if only one parameter of interest
Algebra
© 2016– Andrei Alexandrescu. Do not redistribute. 28 / 33
• Credit: Timon Gehr
C O
i j
v
pij
ij loglij
vij
• pij, lij positive, pij + lij > 0
• log n, n, n log n,
√
n1 + n2 log n2, n2 log n1 . . .
Normal Form & Partial Order
© 2016– Andrei Alexandrescu. Do not redistribute. 29 / 33
• Normal form for terms: most compact form
• A ≤ A′
immediate (compare vars and powers)
• T ≤ T′
iff for each atom A in T there’s an
atom A′
in T′
with A ≤ A′
• C ≤ C′
iff for each term T in C there’s a term
T′
in C′
with T ≤ T′
• Normal form for complexities: no terms are
ordered by ≤
Operations on Complexities
© 2016– Andrei Alexandrescu. Do not redistribute. 30 / 33
• Comparison for equality and ≤
• Addition (add, then normalize)
• Multiplication (multiply, then normalize)
• Normalization keeps only the fastest-growing
terms: O (n +
√
m + m log n) + O m2
+ log n
is O n + m2
+ m log n
• log just a bit trickier (can’t express
log(n1 + n2))
log for Complexities
© 2016– Andrei Alexandrescu. Do not redistribute. 31 / 33
• Rely on a simple approximation
log
i j
v
pij
ij loglij
vij
i j,pij>0
log vij (1)
• log log very slow growing, ignore
• log(a + b) ≤ log(ab)
Implementation
© 2016– Andrei Alexandrescu. Do not redistribute. 32 / 33
• Operator overloading (==, <=, +, *)
• Pivotal use of compile-time evaluation
◦ Perfect match with attribute expressions
• Run-time computation automatically available
• Sweet spot between convenience and
complexity (sic)
• Coming soon!
© 2016– Andrei Alexandrescu. Do not redistribute. 33 / 33
One Last Thing

More Related Content

Similar to DConf 2016 Opening Keynote

Avogadro 2 and Open Chemistry
Avogadro 2 and Open ChemistryAvogadro 2 and Open Chemistry
Avogadro 2 and Open ChemistryMarcus Hanwell
 
12735 cse539 at2 hw
12735 cse539 at2 hw12735 cse539 at2 hw
12735 cse539 at2 hwAnkur Saxena
 
Resonance Introduction at SacPy
Resonance Introduction at SacPyResonance Introduction at SacPy
Resonance Introduction at SacPymoorepants
 
Parallel Optimization in Machine Learning
Parallel Optimization in Machine LearningParallel Optimization in Machine Learning
Parallel Optimization in Machine LearningFabian Pedregosa
 
Solvcon PyCon APAC 2014
Solvcon PyCon APAC 2014Solvcon PyCon APAC 2014
Solvcon PyCon APAC 2014weijr
 
02-tradition-ml.pdf
02-tradition-ml.pdf02-tradition-ml.pdf
02-tradition-ml.pdfKarasuLee
 
Use of OpenSees for the development of physics based tsunami fragility functions
Use of OpenSees for the development of physics based tsunami fragility functionsUse of OpenSees for the development of physics based tsunami fragility functions
Use of OpenSees for the development of physics based tsunami fragility functionsopenseesdays
 
A seminar on neo4 j
A seminar on neo4 jA seminar on neo4 j
A seminar on neo4 jRishikese MR
 

Similar to DConf 2016 Opening Keynote (12)

Avogadro 2 and Open Chemistry
Avogadro 2 and Open ChemistryAvogadro 2 and Open Chemistry
Avogadro 2 and Open Chemistry
 
12735 cse539 at2 hw
12735 cse539 at2 hw12735 cse539 at2 hw
12735 cse539 at2 hw
 
Resonance Introduction at SacPy
Resonance Introduction at SacPyResonance Introduction at SacPy
Resonance Introduction at SacPy
 
Parallel Optimization in Machine Learning
Parallel Optimization in Machine LearningParallel Optimization in Machine Learning
Parallel Optimization in Machine Learning
 
Solvcon PyCon APAC 2014
Solvcon PyCon APAC 2014Solvcon PyCon APAC 2014
Solvcon PyCon APAC 2014
 
02-tradition-ml.pdf
02-tradition-ml.pdf02-tradition-ml.pdf
02-tradition-ml.pdf
 
Use of OpenSees for the development of physics based tsunami fragility functions
Use of OpenSees for the development of physics based tsunami fragility functionsUse of OpenSees for the development of physics based tsunami fragility functions
Use of OpenSees for the development of physics based tsunami fragility functions
 
Three Optimization Tips for C++
Three Optimization Tips for C++Three Optimization Tips for C++
Three Optimization Tips for C++
 
Three Optimization Tips for C++
Three Optimization Tips for C++Three Optimization Tips for C++
Three Optimization Tips for C++
 
A seminar on neo4 j
A seminar on neo4 jA seminar on neo4 j
A seminar on neo4 j
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
 

More from Andrei Alexandrescu

Andrei Alexandrescu keynote at CSDN 2007 in Beijing, China
Andrei Alexandrescu keynote at CSDN 2007 in Beijing, ChinaAndrei Alexandrescu keynote at CSDN 2007 in Beijing, China
Andrei Alexandrescu keynote at CSDN 2007 in Beijing, ChinaAndrei Alexandrescu
 
DConf 2016: What Parnas72 Means for D by Luis Marques
DConf 2016: What Parnas72 Means for D by Luis MarquesDConf 2016: What Parnas72 Means for D by Luis Marques
DConf 2016: What Parnas72 Means for D by Luis MarquesAndrei Alexandrescu
 
DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)
DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)
DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)Andrei Alexandrescu
 
DConf 2016: Sociomantic & D by Leandro Lucarella
DConf 2016: Sociomantic & D by Leandro LucarellaDConf 2016: Sociomantic & D by Leandro Lucarella
DConf 2016: Sociomantic & D by Leandro LucarellaAndrei Alexandrescu
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetAndrei Alexandrescu
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright Andrei Alexandrescu
 

More from Andrei Alexandrescu (6)

Andrei Alexandrescu keynote at CSDN 2007 in Beijing, China
Andrei Alexandrescu keynote at CSDN 2007 in Beijing, ChinaAndrei Alexandrescu keynote at CSDN 2007 in Beijing, China
Andrei Alexandrescu keynote at CSDN 2007 in Beijing, China
 
DConf 2016: What Parnas72 Means for D by Luis Marques
DConf 2016: What Parnas72 Means for D by Luis MarquesDConf 2016: What Parnas72 Means for D by Luis Marques
DConf 2016: What Parnas72 Means for D by Luis Marques
 
DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)
DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)
DConf 2016: Sociomantic & D by Leandro Lucarella (extended version)
 
DConf 2016: Sociomantic & D by Leandro Lucarella
DConf 2016: Sociomantic & D by Leandro LucarellaDConf 2016: Sociomantic & D by Leandro Lucarella
DConf 2016: Sociomantic & D by Leandro Lucarella
 
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury SechetDConf 2016: Bitpacking Like a Madman by Amaury Sechet
DConf 2016: Bitpacking Like a Madman by Amaury Sechet
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
 

Recently uploaded

Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 

Recently uploaded (20)

Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 

DConf 2016 Opening Keynote

  • 1. © 2016– Andrei Alexandrescu. Do not redistribute. 1 / 33 Opening Keynote Prepared for DConf 2016 Andrei Alexandrescu, Ph.D. 2016-05-04
  • 2. © 2016– Andrei Alexandrescu. Do not redistribute. 2 / 33 Welcome to DConf 2016!
  • 3. Sup © 2016– Andrei Alexandrescu. Do not redistribute. 3 / 33
  • 4.
  • 5. First Five Minutes © 2016– Andrei Alexandrescu. Do not redistribute. 5 / 33 • First five minutes become the next five years • Out of the box experience ◦ Website ◦ Tutorials ◦ Documentation ◦ Libraries • (Self-)Curating dub
  • 6. Scaling Up © 2016– Andrei Alexandrescu. Do not redistribute. 6 / 33 • Many thanks for a great year! ◦ Thanks for being here! ◦ The Foundation is up! • Roles: build czar, sysadmin, webmaster, social media, conference organizer. . . • Enhance the “point of contact” approach • Please get me fired! • I’m in charge of too many things
  • 7. Raising the Bar on Contributions © 2016– Andrei Alexandrescu. Do not redistribute. 7 / 33 • The weird thing about “okay work” • Reasons to NOT pull something: ◦ “Porque no?” ◦ Respected contributor ◦ “That’s a lot of work” ◦ One-liners and many-liners ◦ Renames ◦ Refactorings showing no clear improvement • Churn, illusion of progress
  • 8. Raising the Bar on Contributions © 2016– Andrei Alexandrescu. Do not redistribute. 8 / 33 • Reasons to pull something: ◦ Adds value ◦ Refactors for a net benefit ◦ Fixes a bug “positively” ◦ Makes code simpler ◦ Makes code faster ◦ Automates ◦ Improves documentation • talent × time = win
  • 9. Resource Management © 2016– Andrei Alexandrescu. Do not redistribute. 9 / 33
  • 10. Take the Garbage Out © 2016– Andrei Alexandrescu. Do not redistribute. 10 / 33 Commit to making D great with and without a GC
  • 11. Issues with RC © 2016– Andrei Alexandrescu. Do not redistribute. 11 / 33 • Overall: RC a qualified success story in computing • Make it work with immutable • Make it safe • Make it work with classes and value types • Make it work lazily (COW) ◦ Copies should not have arbitrary cost
  • 12. Basics © 2016– Andrei Alexandrescu. Do not redistribute. 12 / 33 • The C++ way: library smart pointers + Apply to any type − Apply to any type (unsafe) − Needs mutable • Envisioned: ◦ In-language support + library hooks ◦ Attribute @rc ◦ opIncRef(uint), opDecRef(uint)
  • 13. Safety © 2016– Andrei Alexandrescu. Do not redistribute. 13 / 33 • Main issue: unaccounted refs struct RC { int a; ... } void fun(ref RC obj, ref int x) { obj = RC(); ... use x ... } void gun() { RC obj = ...; fun(obj, obj.f); } • Variant: obj is global • Attack: Insert extra incs/decs for ref params • Fuse successive incs/decs where possible • Elide increments where possible
  • 14. immutable © 2016– Andrei Alexandrescu. Do not redistribute. 14 / 33 • Apparent contradiction! ◦ immutable: “I’ll never change, honey” ◦ RC: surreptitious change in metadata • We considered revoking immutable rights for RC objects • If only we had a means to: ◦ allocate metadata along with each object ◦ type metadata independently ◦ access metadata in O(1). . .
  • 15. © 2016– Andrei Alexandrescu. Do not redistribute. 15 / 33 “Why do you completely discard external reference counting approach (i.e. storing refcount in GC/allocator internal data structures bound to allocated memory blocks)?” – Dicebot
  • 16. © 2016– Andrei Alexandrescu. Do not redistribute. 16 / 33 “Never ascribe to malice that which is adequately explained by incompetence.” – Robert J. Hanlon
  • 17. AffixAllocator!. . . AffixAllocator!. . . © 2016– Andrei Alexandrescu. Do not redistribute. 17 / 33 • Part of std.experimental.allocator from day one • AffixAllocator!(GCAllocator, uint): ◦ fronts each allocation with an extra uint ◦ . . . that’s independently typed ◦ Accessible in O(1)! • Use this allocator for creating RC objects
  • 18. import bigo; © 2016– Andrei Alexandrescu. Do not redistribute. 18 / 33
  • 19. “Big O” Notation © 2016– Andrei Alexandrescu. Do not redistribute. 19 / 33 • Compact characterization of algorithms • Growing importance in recent years • Usually confined to documentation • Pen and paper suffices for non-generic code • Better: make it generic and a discoverable part of the API
  • 20. Scaling Naming Conventions © 2016– Andrei Alexandrescu. Do not redistribute. 20 / 33 • Nomenclature approaches don’t scale • removeLinTime, removeLogTime, removeConstTime • Hierarchy of speeds: faster functions subsume slower ones • Sometimes O(·) depends on 2+ parameters • Helpless with HOFs • Doesn’t scale to large APIs • We want to automate this
  • 21. Related Work © 2016– Andrei Alexandrescu. Do not redistribute. 21 / 33 • Java: initially complexity-oblivious APIs ◦ Later: RandomAccess “marker” interface • STL carefully specifies complexity ◦ Archetypal examples: push_front, push_back, operator[] ◦ Syntax complexity follows algo complexity ◦ Undecided on “best effort” vs. “present or not”, e.g. distance
  • 22. Loosely Related Work © 2016– Andrei Alexandrescu. Do not redistribute. 22 / 33 • O(·) analysis part of typechecking (Marion 2011) • Automated Higher-Order Complexity Analysis (Benzinger 2004) • Monotonic State (Pilkiewicz et al 2011)
  • 23. Here © 2016– Andrei Alexandrescu. Do not redistribute. 23 / 33 • User: ◦ Introduces annotations ◦ Defines composition • Framework: ◦ Provides algebra ◦ Propagates attributes ◦ Calculates composition • Notably for higher-order functions ◦ Makes result available by static introspection
  • 24. Synopsis © 2016– Andrei Alexandrescu. Do not redistribute. 24 / 33 // Generic doubly-linked list of E struct DoublyLinkedList(E) { ... // Complexity is O(1) void insertFront(E x) @O(1); } // Generic contiguous array of E struct Array(E) { ... // Complexity is O(n) in the first argument (this) void insertFront(E x) @O("n"); }
  • 25. Synopsis © 2016– Andrei Alexandrescu. Do not redistribute. 25 / 33 // Complexity of insertFrontMany is the complexity of // C.insertFront multiplied by the size of the second // argument. void insertFrontMany(C, E)(ref C container, E[] items) @(complexity!(C.insertFront) * O("n2")) { foreach (item; items) { c.insertFront(item); } }
  • 26. Introspection © 2016– Andrei Alexandrescu. Do not redistribute. 26 / 33 static assert( complexity!(insertFrontMany!MyC) <= O("n2") * log(O("n1")), "Too high complexity for insertFrontMany.");
  • 27. Conventions © 2016– Andrei Alexandrescu. Do not redistribute. 27 / 33 • Unannotated functions are considered O(1) • "nk" for the kth parameter • this is the first parameter • "n" if only one parameter of interest
  • 28. Algebra © 2016– Andrei Alexandrescu. Do not redistribute. 28 / 33 • Credit: Timon Gehr C O i j v pij ij loglij vij • pij, lij positive, pij + lij > 0 • log n, n, n log n, √ n1 + n2 log n2, n2 log n1 . . .
  • 29. Normal Form & Partial Order © 2016– Andrei Alexandrescu. Do not redistribute. 29 / 33 • Normal form for terms: most compact form • A ≤ A′ immediate (compare vars and powers) • T ≤ T′ iff for each atom A in T there’s an atom A′ in T′ with A ≤ A′ • C ≤ C′ iff for each term T in C there’s a term T′ in C′ with T ≤ T′ • Normal form for complexities: no terms are ordered by ≤
  • 30. Operations on Complexities © 2016– Andrei Alexandrescu. Do not redistribute. 30 / 33 • Comparison for equality and ≤ • Addition (add, then normalize) • Multiplication (multiply, then normalize) • Normalization keeps only the fastest-growing terms: O (n + √ m + m log n) + O m2 + log n is O n + m2 + m log n • log just a bit trickier (can’t express log(n1 + n2))
  • 31. log for Complexities © 2016– Andrei Alexandrescu. Do not redistribute. 31 / 33 • Rely on a simple approximation log i j v pij ij loglij vij i j,pij>0 log vij (1) • log log very slow growing, ignore • log(a + b) ≤ log(ab)
  • 32. Implementation © 2016– Andrei Alexandrescu. Do not redistribute. 32 / 33 • Operator overloading (==, <=, +, *) • Pivotal use of compile-time evaluation ◦ Perfect match with attribute expressions • Run-time computation automatically available • Sweet spot between convenience and complexity (sic) • Coming soon!
  • 33. © 2016– Andrei Alexandrescu. Do not redistribute. 33 / 33 One Last Thing