Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The World of Inline Module
Search
moznion
March 03, 2018
Technology
0
5.4k
The World of Inline Module
YAPC::Okinawa 2018 Onnasonの資料です
moznion
March 03, 2018
Tweet
Share
More Decks by moznion
See All by moznion
Develop to Survive - YAPC::Hakodate 2024 Keynote
moznion
9
14k
これはPerl? それともRuby? クイズ〜〜〜〜〜!!!- Perl or Ruby Quiz
moznion
3
2.4k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
930
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
65
AWS上に構築する メンテ容易なElasticsearch System / Maintainable Elasticsearch system on AWS
moznion
2
3.9k
PROXY Protocol aware Proxy Server on Node.js
moznion
2
2.5k
Perl meets AWS Lambda
moznion
0
4.7k
ソフトウェア開発における 「設計」と「パフォーマンス」の相互作用 / Interaction Between Design and Performance on Software Development
moznion
12
6.9k
Javaカードの世界 / The world of Java Card
moznion
9
13k
Other Decks in Technology
See All in Technology
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
250
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
120
C++26 エラー性動作
faithandbrave
2
710
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
150
なぜCodeceptJSを選んだか
goataka
0
160
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
700
UI State設計とテスト方針
rmakiyama
2
450
How to be an AWS Community Builder | 君もAWS Community Builderになろう!〜2024 冬 CB募集直前対策編?!〜
coosuke
PRO
2
2.8k
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Designing for Performance
lara
604
68k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Facilitating Awesome Meetings
lara
50
6.1k
Speed Design
sergeychernyshev
25
670
Automating Front-end Workflow
addyosmani
1366
200k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
Being A Developer After 40
akosma
87
590k
Faster Mobile Websites
deanohume
305
30k
Transcript
The World of Inline Module YAPC::Okinawa 2018 Onnason @moznion
None
@moznion Software Engineer ࣾʹPerlϓϩδΣΫτ ͋Γ·ͤΜ͕ Δؾ࣍ୈͰͰ͖·͢
Inline?
Inline? • https://metacpan.org/pod/distribution/Inline/lib/Inline.pod • > Write Perl Subroutines in Other
Programming Languages • ʮPerlͷؔΛଞͷݴޠͰॻ͍ͯΈࠐΜͰ࣮ߦ͢Δʯ • ͝ଘ Ingy döt Net ޚେͷΞΠσΞ (2000)
Sample Code
Sample Code
Sample Code
Sample Code
Sample Code
Demo
How does it work?
How does it work? (Inline::C) • PerlͷίϯύΠϧϑΣΠζͰίϯύΠϧ͍ͯ͠Δ • _Inline/ σΟϨΫτϦʹՌ͕Ͱ͖Δ
• md5ͷϑΟϯΨʔϓϦϯτ͕༩͞ΕΔ • ίϯύΠϧͯ͠Ͱ͖ͨόΠφϦΛμΠφϛοΫϦϯΫ
How does it work? (Inline::C)
How does it work? (Inline::Python) • Python.hΛXSϨΠϠͰΈࠐΜͰ͍Δ • Python.hΛͬͯpythonίʔυΛevalͯ͠result objectʹ͢Δ
• result objectΛperlίʔυʹม • Python.hͰpythonίʔυ͔Β໊લۭؒใΛҾͬ͜ൈ͘ • Ҿͬ͜ൈ໊͍ͨલۭؒΛperlίʔυʹຒΊࠐΉ • Pythonͷݺͼग़͠෦Λϥοϓͯ͠perl͔Βݺͼग़͠Մೳʹ͢Δ • ͳͲ……
Why Inline?
Why Inline? • > The most obvious reason is performance.
• > you may be able to remove a bottleneck in your Perl code by using another language
Why Inline? • > There are already two major facilities
for extending Perl with C. They are XS and SWIG. • > There is a big fat learning curve involved with setting up and using the XS • (SWIGʹର͢Δݴٴͳ͠)
࣮ࡍͳͥInlineΛ? • Perlͷࢿ࢈͕͋ΓɼͲ͏ͯ͠PerlͰΔඞཁ͕͋Γɼ ͦͯ͠PerlͰύϑΥʔϚϯε͕ग़ͳ͍෦Λิ͏ • ྫ͑ܭࢉ
Seriously?
Seriously? • (ঢ়گʹΑͬͯ) Ϛδ
Benchmark • https://gist.github.com/moznion/83dfd5cccb6a8d59a7a7e9e101d64cf8
Benchmark
Pros/Cons
Pros • طଘࢿ࢈Λ্ͬͨͰ؆୯ʹυʔϐϯά͕Մೳ • ଞͷݴޠΛૉʹॻ͚ΔͷͰɼXSΑΓൺֱతͱ͖͍ͬͭ͢ [ཁग़య] • https://metacpan.org/pod/distribution/Inline-C/lib/Inline/C/Cookbook.pod • ο
Cons • ىಈ࣌ͷΦʔόϔου͕͋Δ • ڥߏங͕େม • ଈࢮ͢ΔՄೳੑ͕͋Δ
Management Cost • ॲཧܥ͕2ͭ (͋Δ͍ͦΕҎ্) ʹͳΔίετ • ։ൃڥඋ͕͠ΜͲ͍ (όʔδϣϯϩοΫ) •
ຊ൪ڥඋ͠ΜͲ͍ • όʔδϣϯϩοΫ • όʔδϣϯΞοϓ • Inline::X ͕͏Ϟδϡʔϧͷόʔδϣϯཧ
ଈࢮʁ
Mentality • ͦΕ͔ΓͳΜͱ…… • ͞·͟·ͳঢ়گʹΑΔ (ใྔ͕ແ)
GLUE language
άϧʔݴޠ • ଞͷιϑτΣΞίϯϙʔωϯτͱ࿈ܞͤ͞ΔͨΊͷݴޠ • e.g. γΣϧεΫϦϓτ
PerlͷཱͪҐஔ • ϓϩάϥϛϯάݴޠPerlΑΓൈਮ • > ಉ࣌ʹଟ͘ͷϑΝΠϧϓϩηεͱ௨৴Ͱ͖Δͱ͍͏͜ͱ͕ɺ Perl͕ྑ͍άϧʔݴޠͰ͋Δཧ༝ (ͷͻͱͭ) ʹͳ͍ͬͯΔ •
> ΤΫεςϯγϣϯϞδϡʔϧʹΑͬͯ෦ʹଞͷͷΛΈࠐ ΊΔ͜ͱ
Glue => Inline • Inlineͱάϧʔݴޠͷࢥڧؔ͘࿈͍ͯ͠Δ • PerlΛ࣮ߦج൫ͱͯ͠ଞͷݴޠΛΈࠐΜͰಈ͔͢ • Perlͷࢿ࢈ͱଞͷݴޠͷࢿ࢈ͱΛγʔϜϨεʹ݁ͼ͚ͭΔ͜ͱ͕ Ͱ͖Δ
͔͠͠άϧʔݴޠͬͯฉ͔ͳ͘ͳΓ·ͨ͠Ͷ • Over HTTPͷAPI callingͷൃୡ • ݴޠΑΓԼͷϨΠϠͷΠϯλʔϑΣʔε͕ͬͨͷͰɼͦ͜ ͰؤுΔඞཁ͕ബ͘ͳͬͨͱ͍͏ͷ͋Γͦ͏ • ͔ͭͯͷCORBASOAPXMLRPCΑΓஅવʹڥΑ͘ͳͬͨ
• ͱݴ͑Over HTTPͰAPIΛݺͼग़ͦ͏ͱ͢ΔͱϨΠςϯγ͕͋Δ • ͦͷϨΠςϯγ͕ແࢹͰ͖ͳ͘ͳΔλΠϛϯάଘࡏ͢Δ • ͦͷ࣌ͷͨΊͷग़ϋονͱͯ͠Inline͑Δ ͔͠͠άϧʔݴޠͬͯฉ͔ͳ͘ͳΓ·ͨ͠Ͷ
ର͢ΔLLVMͷख๏ • ҃ΔݴޠΛ҃Δݴޠʹม͢Δͱ͍͏ख๏ • ໌Β͔ʹਖ਼͍͠ʂʂʂʂʂ • ͜Εʮάϧʔݴޠʯ͕ਰୀ͍ͯͬͨ͠ҰҼͰͳ͍͔
Perl6ͷເ • use Inline::Perl5 • use Inline::Go • ͦͯ͠ଞݴޠͷมcompiler •
Java • Perl5 • JavaScript • ͳΜͰॻ͚Δ!!!
ॴײ
ॴײ • Perlͷطଘࢿ࢈͕ࢧతͰɼͲ͏ͯ͠ΘͶͳΒͳ͍߹ બࢶͷҰͭʹͳΓ͑Δ • ʮશ෦ॻ͖ͧ͢ʂʂʂʯ͕Ͱ͖ͳ͍͜ͱੈͷதʹଟ͍ • ͦͯ͠ಘͯͯ͠ʮશ෦ॻ͖ͧ͢ʂʂʂʯϙγϟΓ͕ͪ • ο
ॴײ • ͓ͱͳ͘͠XSͰॻ͘ͱ͍͏ํ๏͋Δ • ͓ͦΒ͘ϝϯόʔ͕XSͷΤΩεύʔτͰ͋Δඞཁ͕͋Δ • ͦ͏Ͱͳ͍߹υΩϡϝϯτʹ͋ΔΑ͏ʹ։ൃʹ͕͔͔࣌ؒΔ • ͔ͦ͠͠͏ͳͬͯ͘ΔͱPerlͰॻ͍͍ͯΔͷ͔Կͳͷ͔Θ͔Βͳ͘ ͳΔͧ……
ॴײ • ʮPerlͷطଘࢿ࢈͕ࢧతͰɼͲ͏ͯ͠ΘͶͳΒͳ͍߹ʯͰͳ͍ ߹ • ಛʹ͏ඞཁͳ͍ͱࢥ͏…… • ʮͲ͏ͯ͠Perlॻ͖ͨ͘ͳ͍ʂʂʯͱ͍͏γνϡΤʔγϣϯʹର͢Δग़ ϋονͰͳ͍ɹ •
ʮPerlॻ͚ͳ͍͚Ͳϫϯνϟϯ……ʯͱ͔ͳ͍ • ਓΛڻ͔ͤΔͷ͕తͷ߹༗ޮ (ʁ) ͔͠Εͳ͍
ॴײ • > Maybe the best reason is "Because you
want to!". Diversity keeps the world interesting. TMTOWTDI! • ࣄͩͱͦ͏ݴ͓ͬͯΕΜ……
·ͱΊ
·ͱΊ • PerlͷInlineϞδϡʔϧʹ͍ͭͯ͝հΛ͠·ͨ͠ • PerlͷInlineϞδϡʔϧͷpros/consʹ͍ͭͯઆ໌͠·ͨ͠ • ओʹੑೳ໘Ͱͷڧ͞Λૂ͑·͢ • άϧʔݴޠͷࠓੲʹ͍ͭͯ͠·ͨ͠ •
InlinePerl͕ݏʹͳͬͨਓͷͨΊͷग़ϋονͰͳ͍
མึͻΖ͍: ͜Μͳʹ͋ΔInlineϞδϡʔϧ
͜Μͳʹ͋ΔInlineϞδϡʔϧ
͜Μͳʹ͋ΔInlineϞδϡʔϧ
͜Μͳʹ͋ΔInlineϞδϡʔϧ • DAVIDO/Inline::CPP • RHOELZ/Inline::Lua • MIYAGAWA/Inline::Basic • RRS/Inline::Tcl •
NEILW/Inline::ASM • etc...
མึͻΖ͍: InlineϞδϡʔϧͷॻ͖ํ
InlineϞδϡʔϧͷॻ͖ํ • આ໌͢Δʹ͋·Γʹ͕࣌ؒͳ͍͜ͱ͕༧͞ΕΔͷͰͬ͘͟Γ • registerॻ͘ • buildॻ͘ • load/bindॻ͘ •
ʂʂʂ (͜͜ʹࢸΔ·Ͱʹͱͯͭͳ͍࿑ྗΛཁ͢Δ)
InlineϞδϡʔϧͷॻ͖ํ • Inline::CͱInline::PythonΑ͘Ͱ͖͍ͯΔͷͰࢀߟʹͳΔͱࢥ͍·͢
Q?