Google

กูเกิลประกาศในงาน Google I/O 2014 ว่า Android รุ่นหน้ารหัส L จะเปลี่ยนมาใช้รันไทม์ ART แทน Dalvik อย่างเป็นทางการแล้ว

  • รองรับ 3 สถาปัตยกรรมซีพียูที่แตกต่างกันคือ ARM, x86, MIPS
  • รองรับการประมวลผล 3 วิธีคือ AOT (ahead of time), JIT (just in time), interpreter
  • ประสิทธิภาพของ ART ดีกว่า Dalvik อย่างเห็นได้ชัด อัตราการหยุดพักของ garbage collector น้อยลง
  • รองรับ 64 บิตมาตั้งแต่ต้น รองรับหน่วยความจำขนาดใหญ่ขึ้น และไม่ต้องแก้โค้ดใดๆ เพราะตัวรันไทม์จัดการให้ทั้งหมด

upic.me

upic.me

upic.me

upic.me

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

ไม่เข้าใจว่าทำไมยังสนับสนุน JIT กับ interpreter อยู่ ถ้าจะใช้ ART
หรือว่าจะยังใช้ได้ทั้งสองอย่างทั้ง dalvik กับ ART เลยยังคง JIT กับ interpreter ไว้อยู่

คิดว่าน่าจะเป็นเรื่อง memory ครับ คือถึงแม้ JIT จะมี memory footprint ที่เยอะกว่า AOT ในโปรแกรมใหญ่ๆ แต่กับโปรแกรมเล็กๆที่ไม่ได้ทำงานตลอดเวลาและไม่ต้องการ performance มากนัก(เช่นเปิดแล้วปิด, ไม่ได้ทำงาน background) ขนาดของ heap เริ่มต้นที่เล็กกว่าของ JIT น่าจะช่วยลดการบริโภค memory ลงได้ครับ

เดี๋ยวก่อนนะครับ ที่ผมเข้าใจคือว่า ART เนี่ยมันเป็นแค่ runtime environment ไม่ใช่ virtual machine อย่าง dalvik แล้ว dex ก็ถูกคอมไพล์เป็น native machine code ตั้งแต่ตอนติดตั้งแอปนั้นๆแล้ว

ดังนั้นตอนที่แอปรัน มันจึงรันบนโปรเซสเซอร์และฮาร์ดแวร์โดยตรง ไม๋เหมือนกับการรันบน dalvik ที่คอย interpret dex bytecode เป็น machine code แล้วใช้ JIT ในการเพิ่มประสิทธิภาพการ interpret fragment ของ ้bytecode ที่เป็น hotspot

ที่ผมไม่เข้าใจคือในเมื่อต่อไปแอปจะรันบนโปรเซสเซอร์ตรงๆ แล้วจะมี interpreter กับ JIT ไว้ทำไมเพราะทั้งสองตัวไว้สำหรับการแปลง bytecode on the fly

ผมเดาเอาเองว่า การที่ Google บอกมาแบบนี้คือ ณ ตอนสร้าง App เราอาจสามารถใส่ flag ให้ apk นั้นๆว่าควรทำตัวในโหมดไหน (AOT - compile เป็น machine code, JIT/interpreter อยู่ในสถานะกึ่ง compile) หน่ะครับ เพราะอย่างที่คุณ takwing บอก AOT กับ JIT มันทำงานร่วมกันไม่ได้อยู่แล้ว

งานเล็กๆ loop น้อยๆ รันซ้ำน้อย แล้วไม่ต้องการ cache ไฟล์ที่คอมไพล์แล้ว การ interpret ได้ผลดีกว่าเยอะครับ

เป็นเหตุผลที่ Python รันสคริปต์เล็กๆ ได้เร็วมาก ขณะที่ bechmark (ซึ่งมักลูปจำนวนมาก) ทำได้แย่เสมอ

ตามที่ผมเข้าใจคือจุดประสงค์ที่ Python ถูกออกแบบมาพร้อมกับ interpreter น่าจะเป็นเพราะ 2 เหตุผลหลักๆ คือ

  1. portability เพราะ Python มันใช้ในการประมวลสคริปต์สำหรับเว็บเบราซ์เซอร์ที่อยู่บนหลายแพล็ตฟอร์ม
  2. dynamically typed language

มากกว่าเหตุผลที่ว่า การ interpret เร็วกว่าเพราะว่าการ interpret มันช้ากว่าการรัน native code ที่่ผ่านการคอมไพล์มาเรียบร้อยแล้วบนฮาร์ดแวร์จริงๆอยู่แล้วมากๆ

หลักฐานคือ ตอนแรกที่ dalvik ออกมามีแต่ interpreter เพียวๆ ตอนหลัง Google เลยตัดสินใจเพิ่ม JIT เข้าไปใน dalvik เพื่อลดขั้นตอนการ interpret เซ็คชันของโค้ดที่ถูก interpret บ่อยๆ และข้อดีอีกอย่างของ JIT คือมันสามารถ emit โค้ดตามสถาการณ์โดยการโปรไฟล์โค้ดขณะรันไปในตัว

ผมว่าการ benchmark กับ สคริปต์เล็กๆมันไม่ได้บอกผลอะไรมากเพราะเวลาที่ใช้มันสั้นเกินไปจนบอกประสิทธิภาพอะไรไม่ได้ แต่ Python เป็นที่นิยมน่าจะเป็นเพราะ ตัวภาษา Python เองตอบโจทย์ในเรื่องการเขียนโปรแกรมเพื่อประมวลผล regular expression มากกว่า

แล้วอย่างนี้ App จะใหญ่เป็นสองเท่าเหมือนตอนนี้มั้ยครับ เพราะผมใช้ CM11 พอเปลี่ยนเป็น ART แล้วพวก App มันกินเนื้อที่เพิ่มเป็นสองเท่ากว่าเลยครับ