web2day - speed up your python code going native

34
Cpu-bound intensive processing #Python #LLVM #Numba iAdvize - @SamuelBerthe SPEED UP YOUR PYTHON CODE GOING NATIVE

Upload: samuel-berthe

Post on 08-Jan-2017

137 views

Category:

Engineering


6 download

TRANSCRIPT

Page 1: Web2day - Speed up your Python code going native

Cpu-bound intensive processing #Python #LLVM #Numba

iAdvize - @SamuelBerthe

SPEED UP YOUR PYTHON CODE GOING NATIVE

Page 2: Web2day - Speed up your Python code going native

{ “about” : “me” }

UX explorer CoFound er ed

Happy DevOps \o/

Current status:

Hunger debugger in Python

Page 3: Web2day - Speed up your Python code going native

2000+ CUSTOMERS 40+ ENERGY TOTAL (FR) Entega GmbH Gas Natural (ES) RWE (DE)

SERV ICES Pole Emploi La Poste DGFIP UWV

CARS Citroen Renault Toyota Fiat BMW

INSURANCE Amaguiz Direct Assurance Groupama Europ Assistance MAIF Asstel Smile.direct Malakoff Mederic AXA Maaf Mutuelle Générale

TELECOM Bouygues Telecom SRR (SFR) Canal+ Sosh - Orange

RETA IL Fnac Cdiscount Florajet Monoprix House of Fraser Newlook Ukais Darty Redoute GrosBill Electrodepot Worten Charlotte Olympia Devanlay 3 Suisses Matches Fashion

LUXURY Louis Vuitton Christian Dior Christofle Chanel Boucheron Bottega Veneta Christian Louboutin Lacoste

TRAVEL TUI DE Air France VSC Marmara Pierre et Vacances Air Austral Corsair Thomas Cook Thalys

F INANCE Banque Populaire Crédit Mutuel Boursorama Banque Monabanq Fortuneo Beobank Cofidis Cofinoga Sofinco Cetelem VIVUS AXA Banque Groupama Banque Natixis Banque Degroof

6 YEARS . 190+ TALENTS . 10+ NATIONALITIES . 9 CORE VALUES . 100+% GROWTH/Y . 5TH GPTW . FAST 50

Page 4: Web2day - Speed up your Python code going native

“Python ecosystem is huge, but performances are really BAD”

Anonymous, StackOverflow

Page 5: Web2day - Speed up your Python code going native

CPU-BOUND INTENSIVE PROCESSING PYTHON - LLVM - NUMBA 101

SAMUEL BERTHE

DATA SCIENCE , MACHINE LEARNING

Page 6: Web2day - Speed up your Python code going native

CPU-BOUND INTENSIVE PROCESSING PYTHON - LLVM - NUMBA 101

SAMUEL BERTHE

VIDEO ENCODING

Page 7: Web2day - Speed up your Python code going native

“PYTHON CAN BE FAST”

Me

Page 8: Web2day - Speed up your Python code going native

CPU-BOUND INTENSIVE PROCESSING PYTHON - LLVM - NUMBA 101

SAMUEL BERTHE

RUN AT LOW LEVEL

Page 9: Web2day - Speed up your Python code going native

C Extension ?

Page 10: Web2day - Speed up your Python code going native

Cython ?

Page 11: Web2day - Speed up your Python code going native

Pypy ?

Page 12: Web2day - Speed up your Python code going native

NUMBA LOW-LEVEL RUNTIME BASED ON LLVM

Numba 0.26 - conda install numba

Page 13: Web2day - Speed up your Python code going native

WHY IS LLVM USEFUL FOR YOUR PYTHON RUNTIME ?

Page 14: Web2day - Speed up your Python code going native

LL… what ? C++

JAVA

HASKELL

GOLANG

ARM

X86

C++

INTERMEDIATE REPRESENTATION

Page 15: Web2day - Speed up your Python code going native

Going NATIVE at RUNTIME

Page 16: Web2day - Speed up your Python code going native

Just-in-time Execution(JIT)

Page 17: Web2day - Speed up your Python code going native

MAN NUMBA

Page 18: Web2day - Speed up your Python code going native

PURE-PYTHON Numpy addition

Page 19: Web2day - Speed up your Python code going native

NUMBA Numpy addition

Page 20: Web2day - Speed up your Python code going native

PERF ??? + GIF = BIMMM

From 300ms to 900μs

Page 21: Web2day - Speed up your Python code going native

Nested calls - Inlining

Page 22: Web2day - Speed up your Python code going native

Generators

Page 23: Web2day - Speed up your Python code going native

MORE COMPLEX JOBS ?

Page 24: Web2day - Speed up your Python code going native

@cuda.jit

Page 25: Web2day - Speed up your Python code going native

THAT’S ALL ! NO MORE OBSCUR STUFF WITH CYTHON

Page 26: Web2day - Speed up your Python code going native

CALL. REPEAT. JIT =

Page 27: Web2day - Speed up your Python code going native

TRUTH IS IN BENCHMARK !

Page 28: Web2day - Speed up your Python code going native

OBSERVED PERFORMANCES

CNUMBACYTHON

C EXTENSIONPYPY

PYTHON

X 1 X 2 X 3 X 4 X 5Speed-up indice

Page 29: Web2day - Speed up your Python code going native

NOT READY FOR RECURSION

LIMITATIONS

Page 30: Web2day - Speed up your Python code going native

LIMITATIONS

Exception handling Lists (partial)

`with` statement Dictionaries

Page 31: Web2day - Speed up your Python code going native

About Numba dependencies

$ docker pull jupyter/datascience-notebook

Page 32: Web2day - Speed up your Python code going native

Q/A @SamuelBerthe

github.com/samber

Page 33: Web2day - Speed up your Python code going native
Page 34: Web2day - Speed up your Python code going native