SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Learning Erlang
(from a Prolog dropout's perspective)


               Kenji Rikitake, JJ1BDX
                   26-APR-2008
          For 1000speakers:4 conference

26-APR-2008      1000speakers:4 by JJ1BDX: Creative   1
                    Commons CC-BY 3.0 licensed
Disclaimers
*Strictly NO WARRANTY
    (Ab)use this presentation at your own risk
*JJ1BDX is the author and the only
responsible person for this presentation
    My (former) employers or anyone else have
    nothing to do with this work and the contents
*This is a work-in-progress
    You may find a bunch of errors and glitches

26-APR-2008     1000speakers:4 by JJ1BDX: Creative   2
                   Commons CC-BY 3.0 licensed
Who am I?
*... I've been the JJ1BDX since 1976
    JJ1BDX is my amateur radio callsign in Japan
*I’ve been an Internet activist since 1986
*In 1986, I was partying around with
fellow radio and computer hackers, like
what you guys are doing now in the
1000speakers conference and other
events. So I come here to enjoy. :-)
26-APR-2008     1000speakers:4 by JJ1BDX: Creative   3
                   Commons CC-BY 3.0 licensed
Why I didn't like prolog
               (in 1980s)
*programming only by matching?
*programming without assignment?
*you can't really compute numbers?
*parallelism on the desktop?
*runtime (slow) virtual machines?
               ...NO WAY!
 (and I spent too much time on NetNews)
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   4
                 Commons CC-BY 3.0 licensed
...then why Erlang NOW??
*...works fast enough on modern PCs
    it works OK even on Windoze! (UNIX rules)
*...has a bunch of practical applications
    yaws, ejabberd, ATM packet exchanges
*...can get the most out of parallelism
    threads and shared memory are headaches
*...is new to me and I’m sure I can learn
something new. That’s for sure.

26-APR-2008    1000speakers:4 by JJ1BDX: Creative   5
                  Commons CC-BY 3.0 licensed
Why Erlang is hard to learn?
*extraordinary syntax
    embedded Prolog-ism
        Horn clauses and pattern-matching branches
        message-driven parallelism
*I’m preoccupied by C and FORTRAN
    leaning tail recursion is not a trivial task
    local variable declaration is not explicit
*lots of new things
    modules, data structures, Mnesia, OTP...
26-APR-2008        1000speakers:4 by JJ1BDX: Creative   6
                      Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   7
                 Commons CC-BY 3.0 licensed
What I'm going to show you
*IPv6-related string manipulation
    generation of 10,000 random IPv6 addresses
    parsing IPv6 colon-notation addresses into
    Erlang-native tuple forms
    generating reverse-lookup names from the
    Erlang tuples
        colon-form addresses -> ip6.arpa name
*some crude profiling results
    with parallelism: using SMP Erlang VM

26-APR-2008        1000speakers:4 by JJ1BDX: Creative   8
                      Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   9
                 Commons CC-BY 3.0 licensed
Erlang IP address tuples
*IPv4
    {127,0,0,1} -> localhost
    (4 x 8-bit elements)
*IPv6
    {0,0,0,0,0,0,0,1} -> ::1 (... well, localhost)
    (8 16-bit big-endian elements)
*Address conversion function ready
    inet_parse:address() for both IPv4 and IPv6
26-APR-2008      1000speakers:4 by JJ1BDX: Creative   10
                    Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   11
                 Commons CC-BY 3.0 licensed
Reverse lookup is getting
       harder in IPv6 than IPv4
*IPv4:
    just reversing the tuple elements is enough
        127.0.0.1 -> 1.0.0.127.in-addr.arpa
        lists:reverse() for the tuple elements
*IPv6:
    parsing and string manipulation needed
        2001:1:3fff:dbde::1 ->
        1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.d.b.d.f.f.f.3.1.0.0.
        0.1.0.0.2.ip6.arpa
        ... binary bit pack/unpack operation is effective

26-APR-2008         1000speakers:4 by JJ1BDX: Creative      12
                       Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   13
                 Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   14
                 Commons CC-BY 3.0 licensed
Concurrency and map()ping
*simple list iteration: map()ping
    Applying a function to all the list members
    lists:map(fun(X) -> function(X) end, Arglist)
*parallelism: parallel map()
    Joe Armstrong’s pmap()
        (in Programming Erlang: Software for a Concurrent World)
        spawn()ing light-weight process per element
        preserving result list sequence
    caution: execution sequence implementation
    dependent – no side effect allowed in the function

26-APR-2008          1000speakers:4 by JJ1BDX: Creative            15
                        Commons CC-BY 3.0 licensed
map() .vs. pmap() results
 * 10,000 addresses / Core2Duo 2.33GHz
     (mean values of 5-time measurements)

completion time lists:map()                           Armstrong’s
for test functions                                    pmap()
non-SMP            1.309 seconds                      2.029 seconds
(single scheduler)                                    (+55.0%)
SMP (2 cores)        1.343 seconds 1.202 seconds
(2 schedulers)                     (-10.5%)

 26-APR-2008     1000speakers:4 by JJ1BDX: Creative               16
                    Commons CC-BY 3.0 licensed
Spawning overhead of
              lightweight processes
*cost of creating lightweight processes
    3 to 12 microseconds/process
*messaging overhead between processes
*more efficient utilization of CPUs needed
    granularity: per-function computation
    number of simultaneous processes
    efficient process spawning
        e.g., result list sequence need not be preserved

26-APR-2008        1000speakers:4 by JJ1BDX: Creative      17
                      Commons CC-BY 3.0 licensed
Conclusions and lessons
*Erlang is weird, but worth learning
    getting out of the modules is essential
*parallelism works (even for 2 CPUs!)
    write parallelism-aware functions:
        Erlang’s idioms help parallel programming
*programmers need to learn parallelism
    Erlang’s idea applicable to other languages
    effective serialization is also critical; some
    algorithms have to run fast (e.g., crypto)
26-APR-2008        1000speakers:4 by JJ1BDX: Creative   18
                      Commons CC-BY 3.0 licensed
Appendix: lighter function
    means less parallelism gain
* 10,000 addresses / Core2Duo 2.33GHz
    (mean values of 5-time measurements)
*Faster implementation
    io_lib:format() -> primitive hex conversion
completion time lists:map()                          Armstrong’s
for test functions                                   pmap()
SMP (2 cores)      0.129 seconds                     0.198 seconds
(2 schedulers)                                       (+53%)
26-APR-2008     1000speakers:4 by JJ1BDX: Creative              19
                   Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   20
                 Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   21
                 Commons CC-BY 3.0 licensed

Más contenido relacionado

La actualidad más candente

Code gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introductionCode gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introductionMarina Kolpakova
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathThomas Graf
 
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler OptimizationsPragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler OptimizationsMarina Kolpakova
 
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW ImplementationZhen Wei
 
Code GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory SubsystemCode GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory SubsystemMarina Kolpakova
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerSasha Goldshtein
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkAlexey Smirnov
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition 艾鍗科技
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMLinaro
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...Linaro
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 艾鍗科技
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)Yuuki Takano
 
Programming Trends in High Performance Computing
Programming Trends in High Performance ComputingProgramming Trends in High Performance Computing
Programming Trends in High Performance ComputingJuris Vencels
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkJaewook. Kang
 

La actualidad más candente (20)

Code gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introductionCode gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introduction
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable Datapath
 
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler OptimizationsPragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
 
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
 
Code GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory SubsystemCode GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory Subsystem
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Machine Trace Metrics
Machine Trace MetricsMachine Trace Metrics
Machine Trace Metrics
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
 
ocelot
ocelotocelot
ocelot
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
 
Programming Trends in High Performance Computing
Programming Trends in High Performance ComputingProgramming Trends in High Performance Computing
Programming Trends in High Performance Computing
 
Polyraptor
PolyraptorPolyraptor
Polyraptor
 
Code GPU with CUDA - SIMT
Code GPU with CUDA - SIMTCode GPU with CUDA - SIMT
Code GPU with CUDA - SIMT
 
Ns2pre
Ns2preNs2pre
Ns2pre
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
 

Similar a Learning Erlang (from a Prolog dropout's perspective)

Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Akihiro Hayashi
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPFAlex Maestretti
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stackHajime Tazaki
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyAnne Nicolas
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet FiltersKernel TLV
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Hajime Tazaki
 
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...Takahiro Katagiri
 
Lustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New FeaturesLustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New Featuresinside-BigData.com
 
Breaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIBreaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIDustin Franklin
 
Java on arm theory, applications, and workloads [dev5048]
Java on arm  theory, applications, and workloads [dev5048]Java on arm  theory, applications, and workloads [dev5048]
Java on arm theory, applications, and workloads [dev5048]Aleksei Voitylov
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareDaniel Blezek
 
Directive-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingDirective-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingRuymán Reyes
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real TimePiotr Perzyna
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDKKernel TLV
 
Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Takuya ASADA
 
Porting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsPorting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsIgor Sfiligoi
 
Nilesh ranpura systemmodelling
Nilesh ranpura systemmodellingNilesh ranpura systemmodelling
Nilesh ranpura systemmodellingObsidian Software
 
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra Umbra Software
 

Similar a Learning Erlang (from a Prolog dropout's perspective) (20)

Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stack
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
 
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
 
Lustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New FeaturesLustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New Features
 
Breaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIBreaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AI
 
ADCSS 2022
ADCSS 2022ADCSS 2022
ADCSS 2022
 
Java on arm theory, applications, and workloads [dev5048]
Java on arm  theory, applications, and workloads [dev5048]Java on arm  theory, applications, and workloads [dev5048]
Java on arm theory, applications, and workloads [dev5048]
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics Hardware
 
Directive-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingDirective-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous Computing
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real Time
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
 
Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3
 
Porting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsPorting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUs
 
Nilesh ranpura systemmodelling
Nilesh ranpura systemmodellingNilesh ranpura systemmodelling
Nilesh ranpura systemmodelling
 
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
 

Más de elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

Más de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Learning Erlang (from a Prolog dropout's perspective)

  • 1. Learning Erlang (from a Prolog dropout's perspective) Kenji Rikitake, JJ1BDX 26-APR-2008 For 1000speakers:4 conference 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 1 Commons CC-BY 3.0 licensed
  • 2. Disclaimers *Strictly NO WARRANTY (Ab)use this presentation at your own risk *JJ1BDX is the author and the only responsible person for this presentation My (former) employers or anyone else have nothing to do with this work and the contents *This is a work-in-progress You may find a bunch of errors and glitches 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 2 Commons CC-BY 3.0 licensed
  • 3. Who am I? *... I've been the JJ1BDX since 1976 JJ1BDX is my amateur radio callsign in Japan *I’ve been an Internet activist since 1986 *In 1986, I was partying around with fellow radio and computer hackers, like what you guys are doing now in the 1000speakers conference and other events. So I come here to enjoy. :-) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 3 Commons CC-BY 3.0 licensed
  • 4. Why I didn't like prolog (in 1980s) *programming only by matching? *programming without assignment? *you can't really compute numbers? *parallelism on the desktop? *runtime (slow) virtual machines? ...NO WAY! (and I spent too much time on NetNews) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 4 Commons CC-BY 3.0 licensed
  • 5. ...then why Erlang NOW?? *...works fast enough on modern PCs it works OK even on Windoze! (UNIX rules) *...has a bunch of practical applications yaws, ejabberd, ATM packet exchanges *...can get the most out of parallelism threads and shared memory are headaches *...is new to me and I’m sure I can learn something new. That’s for sure. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 5 Commons CC-BY 3.0 licensed
  • 6. Why Erlang is hard to learn? *extraordinary syntax embedded Prolog-ism Horn clauses and pattern-matching branches message-driven parallelism *I’m preoccupied by C and FORTRAN leaning tail recursion is not a trivial task local variable declaration is not explicit *lots of new things modules, data structures, Mnesia, OTP... 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 6 Commons CC-BY 3.0 licensed
  • 7. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 7 Commons CC-BY 3.0 licensed
  • 8. What I'm going to show you *IPv6-related string manipulation generation of 10,000 random IPv6 addresses parsing IPv6 colon-notation addresses into Erlang-native tuple forms generating reverse-lookup names from the Erlang tuples colon-form addresses -> ip6.arpa name *some crude profiling results with parallelism: using SMP Erlang VM 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 8 Commons CC-BY 3.0 licensed
  • 9. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 9 Commons CC-BY 3.0 licensed
  • 10. Erlang IP address tuples *IPv4 {127,0,0,1} -> localhost (4 x 8-bit elements) *IPv6 {0,0,0,0,0,0,0,1} -> ::1 (... well, localhost) (8 16-bit big-endian elements) *Address conversion function ready inet_parse:address() for both IPv4 and IPv6 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 10 Commons CC-BY 3.0 licensed
  • 11. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 11 Commons CC-BY 3.0 licensed
  • 12. Reverse lookup is getting harder in IPv6 than IPv4 *IPv4: just reversing the tuple elements is enough 127.0.0.1 -> 1.0.0.127.in-addr.arpa lists:reverse() for the tuple elements *IPv6: parsing and string manipulation needed 2001:1:3fff:dbde::1 -> 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.d.b.d.f.f.f.3.1.0.0. 0.1.0.0.2.ip6.arpa ... binary bit pack/unpack operation is effective 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 12 Commons CC-BY 3.0 licensed
  • 13. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 13 Commons CC-BY 3.0 licensed
  • 14. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 14 Commons CC-BY 3.0 licensed
  • 15. Concurrency and map()ping *simple list iteration: map()ping Applying a function to all the list members lists:map(fun(X) -> function(X) end, Arglist) *parallelism: parallel map() Joe Armstrong’s pmap() (in Programming Erlang: Software for a Concurrent World) spawn()ing light-weight process per element preserving result list sequence caution: execution sequence implementation dependent – no side effect allowed in the function 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 15 Commons CC-BY 3.0 licensed
  • 16. map() .vs. pmap() results * 10,000 addresses / Core2Duo 2.33GHz (mean values of 5-time measurements) completion time lists:map() Armstrong’s for test functions pmap() non-SMP 1.309 seconds 2.029 seconds (single scheduler) (+55.0%) SMP (2 cores) 1.343 seconds 1.202 seconds (2 schedulers) (-10.5%) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 16 Commons CC-BY 3.0 licensed
  • 17. Spawning overhead of lightweight processes *cost of creating lightweight processes 3 to 12 microseconds/process *messaging overhead between processes *more efficient utilization of CPUs needed granularity: per-function computation number of simultaneous processes efficient process spawning e.g., result list sequence need not be preserved 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 17 Commons CC-BY 3.0 licensed
  • 18. Conclusions and lessons *Erlang is weird, but worth learning getting out of the modules is essential *parallelism works (even for 2 CPUs!) write parallelism-aware functions: Erlang’s idioms help parallel programming *programmers need to learn parallelism Erlang’s idea applicable to other languages effective serialization is also critical; some algorithms have to run fast (e.g., crypto) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 18 Commons CC-BY 3.0 licensed
  • 19. Appendix: lighter function means less parallelism gain * 10,000 addresses / Core2Duo 2.33GHz (mean values of 5-time measurements) *Faster implementation io_lib:format() -> primitive hex conversion completion time lists:map() Armstrong’s for test functions pmap() SMP (2 cores) 0.129 seconds 0.198 seconds (2 schedulers) (+53%) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 19 Commons CC-BY 3.0 licensed
  • 20. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 20 Commons CC-BY 3.0 licensed
  • 21. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 21 Commons CC-BY 3.0 licensed