SlideShare a Scribd company logo
Erlang
Tightly coupled Erlang

Yatce: Yet Another TC-Erlang binding

     4th Tokyo Erlang Workshop
        in Aoyama, 2010/2/26
              @kuenishi
           http://creativecommons.org/licenses/by-sa/2.1/jp/
@kuenishi

http://www.google.com/profiles/kuenishi

           : an employee

Distributed System Developer, C/C++



   OCaml    …
Why YATCE?
Erlang
I/O
mnesia
dets
Tew4 Yatce presentation
Tew4 Yatce presentation
Tew4 Yatce presentation
TokyoCabinet
TokyoCabinet   Erlang


    Erlang
Erlang   C
C node
C node
     A process behaves like an Erlang node,

     BERT/TCP connected,

     Failure doesn’t involve the other.


main(){
   ...                 TCP           Erlang
        C node
  ...                                 node
}
Port
Driver
Port Driver
==Popen3, just an IPC,

BERT/stdin/stdout connected,

tolerant for Child process’ failure.

           fork/exec

              stdin        Erlang
any CUI
                          process
             stdout
tcerl

Pioneer in TC-Erlang!

Port driver,

“I couldn’t make it work”, - matthew,

seems not being maintained.
Linkedin
 Driver
Linked-in Driver
in-process erlang-port,

  % acts like an Erlang process

  % Message can be sent/recv’d,

less failure-separeted.
                              Erlang
                             process

                           output(..){
     ?DEMO.                 ... }
message passing
                                       to port

                            Process

             Process
                                 Process
     ! or
port_command/3      ! or
                   return


             port


          socket
Port!{self(), {command, Data}}
Process
                   or port_command/2


                   port


                    erl_drv_entry#output(...)



           ! or
          return



                     driver_output(...)
everything wrapped

OS
driver_alloc, driver_free

driver_enq, driver_deq

driver_monitor_process

erl_driver_select

erl_drv_thread_create, erl_drv_thread_join, erl_drv_mutex_lock, ...

     s/erl_drv_/p/g

driver_set_timer, driver_cancel_timer, driver_read_timer




R13B04          API
Toke

Most famous in TC-Erlang,

Linked-in driver,

Simple: just what matthew/LShift wants,

to be used in RabbitMQ?.
Yatce

Made in Japan by me,

Linked-in driver (0.10)

port_control instead of port_command

interface based on tokyocabinet.idl,

http://bitbucket.org/kuenishi/yatce
Yatce 0.10
                                                                                                                                     R13B02
                                        response time vs thruput for each key-value store (with my Dual-core SSD’d MacBook)
                             3000




                             2250
average response time (us)




                             1500




                             750




                               0
                                    0                    1750                   3500                  5250                    7000
                                                                            Thruput (qps)

                                             ets            dets            yatce             tcerl
one more
problem...
port
locking
Python   GIL


Ruby   GVL


       driver
Port!{self(), {command, Data}}
Process
                   or port_command/2


                   port


                    erl_drv_entry#output(...)



           ! or
          return



                     driver_output(...)
ERTS
                 Worker
Worker


          Worker




         tcadb
TC
driver        port   port level locking
  TC     DB      port
                                          …
R13B03
Native Interface
     Functions

Since R13B03, Beta,

Built-in code runs inside ERTS,

easy way to write Erlang module in C,

Nothing separated.
it’s just a function pointer
             calling inside ERTS


                         nif_func_in_c(...){


call_nif()->
  nif_func_in_c(..),
  hoge,
  done.

                            return term;
                        }

     Erlang                       C
ERTS




Thread   Thread   Thread




         tcadb
Yatce 0.20
                                                                                                                        R13B03
                               response time vs thruput for each key-value store (with my Dual-core SSD’d MacBook)
                     700




                     525
Response time (us)




                     350




                     175




                      0
                           0                     5000                  10000                15000               20000
                                                                 Throughput (qps)
                                                ets             dets                yatce
NIF


                R13B04
           erlang-patches        erlang-questions   GitHub   erlang/otp
          NIF    Erlang VM                                          IO
                   linkedin driver                      I/O
       pthread     driver_select                                  Yatce
0.20                                           TC
                                   TC


           NIF     Yatce                Erlang VM
Choose what fits to
        you!
Slow   C node
                          Safe

       Port driver

       Linked-in driver

         port_command/3

         port_control/3

Fast   NIF                Difficult
Any Questions?
          or
come on to the party
     and ask me!
References
ERTS: Interoperability tutorial guide
      http://www.erlang.org/doc/tutorial/overview.html

BERT/BERT-RPC
      http://github.com/blog/531-introducing-bert-and-bert-rpc

      http://bert-rpc.org/

Erlang external term format
      http://erlang.org/doc/apps/erts/erl_ext_dist.html

NIF
      http://erlang.org/doc/man/erl_nif.html

Toke, vs tcerl
      http://bit.ly/8nPhm2

More Related Content

KEY
TEW4 Yatce deprecated slides
ODP
Python Compiler Internals Presentation Slides
PDF
1 hour dive into Erlang/OTP
PDF
Arduino programming
ZIP
Inside Python [OSCON 2012]
ZIP
Inside PHP [OSCON 2012]
ODP
I Know Kung Fu - Juggling Java Bytecode
PDF
Lifting The Veil - Reading Java Bytecode During Lunchtime
TEW4 Yatce deprecated slides
Python Compiler Internals Presentation Slides
1 hour dive into Erlang/OTP
Arduino programming
Inside Python [OSCON 2012]
Inside PHP [OSCON 2012]
I Know Kung Fu - Juggling Java Bytecode
Lifting The Veil - Reading Java Bytecode During Lunchtime

What's hot (20)

PDF
Lifting The Veil - Reading Java Bytecode
PDF
Jython: Integrating Python and Java
PDF
You got ur Erlang in my Ruby
PDF
A(n abridged) tour of the Rust compiler [PDX-Rust March 2014]
PPTX
Flash memory
PDF
Parrot -- "one bytecode to rule them all"
ODP
An introduction to erlang
PDF
Parallel Programming
PDF
FregeDay: Design and Implementation of the language (Ingo Wechsung)
DOCX
Aac boolean formulae
PDF
Python coroutine
PDF
The dark side of Ruby, or Learn functional programming with Ruby
PDF
Static analysis for perl
PDF
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
PDF
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
PDF
Whats new in Java 7
PDF
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
PPTX
PPTX
PPT
Programmable Logic Devices Plds
Lifting The Veil - Reading Java Bytecode
Jython: Integrating Python and Java
You got ur Erlang in my Ruby
A(n abridged) tour of the Rust compiler [PDX-Rust March 2014]
Flash memory
Parrot -- "one bytecode to rule them all"
An introduction to erlang
Parallel Programming
FregeDay: Design and Implementation of the language (Ingo Wechsung)
Aac boolean formulae
Python coroutine
The dark side of Ruby, or Learn functional programming with Ruby
Static analysis for perl
Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
Whats new in Java 7
FregeDay: Roadmap for resolving differences between Haskell and Frege (Ingo W...
Programmable Logic Devices Plds
Ad

Viewers also liked (20)

KEY
LT on Python Hackathon #2
PDF
[db tech showcase Tokyo 2015] B34:データの仮想化を具体化するIBMのロジカルデータウェアハウス by 日本アイ・ビー・エ...
PDF
[db tech showcase Tokyo 2015] C14:30万のユーザ部門を抱える日立、情シスの「理想と現実」 by 株式会社日立製作所 情報...
PDF
Couchbase introduction-20150611
PDF
Mongodb x business
PDF
Db tech showcase2015
PDF
[db tech showcase Tokyo 2015] D32:HPの全方位インメモリDB化に向けた取り組みとSAP HANAインメモリDB の効果を...
PDF
Db tech show - hivemall
PPTX
[db tech showcase Tokyo 2015] E26 Couchbaseの最新情報/JBoss Data Virtualizationで仮想...
PDF
[db tech showcase Tokyo 2015] D33:Superdome X 上の SQL Server 2014 OLTP 検証結果と S...
PDF
[db tech showcase Tokyo 2015] D16:マイケルストーンブレーカー発の超高速データベースで実現する分析基盤の簡単構築・運用ステ...
PDF
[db tech showcase Tokyo 2015] C15:DevOps MySQL in カカクコム~ OSSによる可用性担保とリアルタイムパフ...
PDF
gen_paxos
PDF
DBTS2015 Tokyo DBAが知っておくべき最新テクノロジー
PDF
[DB tech showcase Tokyo 2015] B37 :オンプレミスからAWS上のSAP HANAまで高信頼DBシステム構築にHAクラスタリ...
PDF
[db tech showcase Tokyo 2015] C27:楽天MySQL Backup Structure by 楽天株式会社 粟田啓介
PDF
[db tech showcase Tokyo 2015] C33:ビッグデータ・IoT時代のキーテクノロジー、CEPの「今」を掴む! by 株式会社日立...
PDF
[db tech showcase Tokyo 2015] B36:Hitachi Advanced Data Binder 実践SQLチューニング方法 ...
PDF
[db tech showcase Tokyo 2015] A33:Amazon DynamoDB Deep Dive by アマゾン データ サービス ...
PDF
[db tech showcase Tokyo 2015] D22:インメモリープラットホームSAP HANAのご紹介と最新情報 by SAPジャパン株式...
LT on Python Hackathon #2
[db tech showcase Tokyo 2015] B34:データの仮想化を具体化するIBMのロジカルデータウェアハウス by 日本アイ・ビー・エ...
[db tech showcase Tokyo 2015] C14:30万のユーザ部門を抱える日立、情シスの「理想と現実」 by 株式会社日立製作所 情報...
Couchbase introduction-20150611
Mongodb x business
Db tech showcase2015
[db tech showcase Tokyo 2015] D32:HPの全方位インメモリDB化に向けた取り組みとSAP HANAインメモリDB の効果を...
Db tech show - hivemall
[db tech showcase Tokyo 2015] E26 Couchbaseの最新情報/JBoss Data Virtualizationで仮想...
[db tech showcase Tokyo 2015] D33:Superdome X 上の SQL Server 2014 OLTP 検証結果と S...
[db tech showcase Tokyo 2015] D16:マイケルストーンブレーカー発の超高速データベースで実現する分析基盤の簡単構築・運用ステ...
[db tech showcase Tokyo 2015] C15:DevOps MySQL in カカクコム~ OSSによる可用性担保とリアルタイムパフ...
gen_paxos
DBTS2015 Tokyo DBAが知っておくべき最新テクノロジー
[DB tech showcase Tokyo 2015] B37 :オンプレミスからAWS上のSAP HANAまで高信頼DBシステム構築にHAクラスタリ...
[db tech showcase Tokyo 2015] C27:楽天MySQL Backup Structure by 楽天株式会社 粟田啓介
[db tech showcase Tokyo 2015] C33:ビッグデータ・IoT時代のキーテクノロジー、CEPの「今」を掴む! by 株式会社日立...
[db tech showcase Tokyo 2015] B36:Hitachi Advanced Data Binder 実践SQLチューニング方法 ...
[db tech showcase Tokyo 2015] A33:Amazon DynamoDB Deep Dive by アマゾン データ サービス ...
[db tech showcase Tokyo 2015] D22:インメモリープラットホームSAP HANAのご紹介と最新情報 by SAPジャパン株式...
Ad

Similar to Tew4 Yatce presentation (20)

PDF
Feuerlabs Exosense
PDF
Bare metal performance in Elixir
PDF
Erlang Message Passing Concurrency, For The Win
PDF
IL: 失われたプロトコル
PDF
Meiga Guadec 2009 English
PDF
Why Erlang? - Bar Camp Atlanta 2008
PDF
In-Network Acceleration with FPGA (MEMO)
PPT
Erlang OTP
PDF
Erlang Embedded — Concurrent Blinkenlights and More!
PDF
C&C Botnet Factory
PDF
Examples 2.0
PDF
Implement Checkpointing for Android (ELCE2012)
PDF
Disruptive IP Networking with Intel DPDK on Linux
PDF
XS Japan 2008 Xen Mgmt English
PDF
ARM LPC2300/LPC2400 TCP/IP Stack Porting
PDF
Implement Checkpointing for Android
KEY
Fosscon 2012 firewall workshop
KEY
Erlang bootstrap course
PDF
VyattaCore TIPS2013
PDF
Everybody Polyglot! - Cross-Language RPC with Erlang
Feuerlabs Exosense
Bare metal performance in Elixir
Erlang Message Passing Concurrency, For The Win
IL: 失われたプロトコル
Meiga Guadec 2009 English
Why Erlang? - Bar Camp Atlanta 2008
In-Network Acceleration with FPGA (MEMO)
Erlang OTP
Erlang Embedded — Concurrent Blinkenlights and More!
C&C Botnet Factory
Examples 2.0
Implement Checkpointing for Android (ELCE2012)
Disruptive IP Networking with Intel DPDK on Linux
XS Japan 2008 Xen Mgmt English
ARM LPC2300/LPC2400 TCP/IP Stack Porting
Implement Checkpointing for Android
Fosscon 2012 firewall workshop
Erlang bootstrap course
VyattaCore TIPS2013
Everybody Polyglot! - Cross-Language RPC with Erlang

Tew4 Yatce presentation

  • 1. Erlang Tightly coupled Erlang Yatce: Yet Another TC-Erlang binding 4th Tokyo Erlang Workshop in Aoyama, 2010/2/26 @kuenishi http://creativecommons.org/licenses/by-sa/2.1/jp/
  • 2. @kuenishi http://www.google.com/profiles/kuenishi : an employee Distributed System Developer, C/C++ OCaml …
  • 5. I/O
  • 11. TokyoCabinet Erlang Erlang
  • 12. Erlang C
  • 14. C node A process behaves like an Erlang node, BERT/TCP connected, Failure doesn’t involve the other. main(){ ... TCP Erlang C node ... node }
  • 16. Port Driver ==Popen3, just an IPC, BERT/stdin/stdout connected, tolerant for Child process’ failure. fork/exec stdin Erlang any CUI process stdout
  • 17. tcerl Pioneer in TC-Erlang! Port driver, “I couldn’t make it work”, - matthew, seems not being maintained.
  • 19. Linked-in Driver in-process erlang-port, % acts like an Erlang process % Message can be sent/recv’d, less failure-separeted. Erlang process output(..){ ?DEMO. ... }
  • 20. message passing to port Process Process Process ! or port_command/3 ! or return port socket
  • 21. Port!{self(), {command, Data}} Process or port_command/2 port erl_drv_entry#output(...) ! or return driver_output(...)
  • 22. everything wrapped OS driver_alloc, driver_free driver_enq, driver_deq driver_monitor_process erl_driver_select erl_drv_thread_create, erl_drv_thread_join, erl_drv_mutex_lock, ... s/erl_drv_/p/g driver_set_timer, driver_cancel_timer, driver_read_timer R13B04 API
  • 23. Toke Most famous in TC-Erlang, Linked-in driver, Simple: just what matthew/LShift wants, to be used in RabbitMQ?.
  • 24. Yatce Made in Japan by me, Linked-in driver (0.10) port_control instead of port_command interface based on tokyocabinet.idl, http://bitbucket.org/kuenishi/yatce
  • 25. Yatce 0.10 R13B02 response time vs thruput for each key-value store (with my Dual-core SSD’d MacBook) 3000 2250 average response time (us) 1500 750 0 0 1750 3500 5250 7000 Thruput (qps) ets dets yatce tcerl
  • 28. Python GIL Ruby GVL driver
  • 29. Port!{self(), {command, Data}} Process or port_command/2 port erl_drv_entry#output(...) ! or return driver_output(...)
  • 30. ERTS Worker Worker Worker tcadb
  • 31. TC
  • 32. driver port port level locking TC DB port …
  • 34. Native Interface Functions Since R13B03, Beta, Built-in code runs inside ERTS, easy way to write Erlang module in C, Nothing separated.
  • 35. it’s just a function pointer calling inside ERTS nif_func_in_c(...){ call_nif()-> nif_func_in_c(..), hoge, done. return term; } Erlang C
  • 36. ERTS Thread Thread Thread tcadb
  • 37. Yatce 0.20 R13B03 response time vs thruput for each key-value store (with my Dual-core SSD’d MacBook) 700 525 Response time (us) 350 175 0 0 5000 10000 15000 20000 Throughput (qps) ets dets yatce
  • 38. NIF R13B04 erlang-patches erlang-questions GitHub erlang/otp NIF Erlang VM IO linkedin driver I/O pthread driver_select Yatce 0.20 TC TC NIF Yatce Erlang VM
  • 39. Choose what fits to you! Slow C node Safe Port driver Linked-in driver port_command/3 port_control/3 Fast NIF Difficult
  • 40. Any Questions? or come on to the party and ask me!
  • 41. References ERTS: Interoperability tutorial guide http://www.erlang.org/doc/tutorial/overview.html BERT/BERT-RPC http://github.com/blog/531-introducing-bert-and-bert-rpc http://bert-rpc.org/ Erlang external term format http://erlang.org/doc/apps/erts/erl_ext_dist.html NIF http://erlang.org/doc/man/erl_nif.html Toke, vs tcerl http://bit.ly/8nPhm2