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.3k
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.3k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
900
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
60
AWS上に構築する メンテ容易なElasticsearch System / Maintainable Elasticsearch system on AWS
moznion
2
3.9k
PROXY Protocol aware Proxy Server on Node.js
moznion
2
2.4k
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
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
860
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
120
[FOSS4G 2019 Niigata] AIによる効率的危険斜面抽出システムの開発について
nssv
0
310
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
350
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
330
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
280
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
TypeScript、上達の瞬間
sadnessojisan
46
13k
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
570
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
49
11k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
It's Worth the Effort
3n
183
27k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Building Adaptive Systems
keathley
38
2.3k
Optimizing for Happiness
mojombo
376
70k
Side Projects
sachag
452
42k
Designing for humans not robots
tammielis
250
25k
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?