Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
What's in a Mobile Database?
Samuel E. Giddins
March 03, 2015
Technology
0
44
What's in a Mobile Database?
Samuel E. Giddins
March 03, 2015
Tweet
Share
More Decks by Samuel E. Giddins
See All by Samuel E. Giddins
Switching Disciplines as a Tech Lead
segiddins
0
6
Source Code to Executable
segiddins
0
55
Empowering iOS Developers
segiddins
1
55
Empowering iOS Developers
segiddins
0
340
Making CocoaPods Fast (with Modern Ruby Tooling)
segiddins
0
18
Making CocoaPods Fast
segiddins
0
230
Answering the Existential Question
segiddins
0
27
Scaling CocoaPods
segiddins
0
33
Building Swift Static Libraries
segiddins
0
270
Other Decks in Technology
See All in Technology
PHPのimmutable arrayとは
hnw
1
180
金属加工屋の営業マンがSTマイクロで・・・
usashirou
0
180
SPA・SSGでSSRのようなOGP対応!
simo123
2
170
Dockerに疲れた人のためのLXDではじめるシステムコンテナ入門
devops_vtj
0
140
あつめたデータをどう扱うか
skrb
2
180
イ良い日ンマを作る(USBストレージ容量偽装の手法) / USB Storage Capacity Faking Techniques
shutingrz
0
560
書籍を書きました。 そう、VS Codeで。
takumanakagame
4
4.6k
Oracle Cloud Infrastructure:2023年1月度サービス・アップデート
oracle4engineer
PRO
0
190
Google Cloud Workflows: API automation, patterns and best practices
glaforge
0
110
5分でわかるファストドクターテクノロジーズ
fast_doctor
0
100
IoT から見る AWS re:invent 2022 ― AWSのIoTの歴史を添えて/Point of view the AWS re:invent 2022 with IoT - with a history of IoT in AWS
ma2shita
0
290
岐路に立つ若手がAmazonianの仕事術を学んできました / learning amazonian productivity hacks as a junior engineer
yayoi_dd
0
170
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
34
1.5k
How GitHub (no longer) Works
holman
298
140k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
29
8k
In The Pink: A Labor of Love
frogandcode
132
21k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
Fantastic passwords and where to find them - at NoRuKo
philnash
32
1.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
226
130k
Designing for humans not robots
tammielis
245
24k
Docker and Python
trallard
30
1.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
13
1.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
2
410
Why Our Code Smells
bkeepers
PRO
326
55k
Transcript
WHAT’S IN A MOBILE DATABASE?
SAMUEL GIDDINS REALM.IO
Show of hands: WHO’S USED A DATABASE?
LET’S NAME SOME
MOST OF THOSE ARE SERVER DATABASES
None
SQLITE THE STATUS QUO
▸ Single-threaded ▸ Dynamically-typed ▸ Weakly-typed ▸ Designed in 2000
WHAT ARE OUR CONSTRAINTS?
▸ Running on a device ▸ Can’t update database code
on a whim ▸ Little RAM ▸ Relatively few CPU cores ▸ Multiple processes ▸ Long-running use of data
WHAT DO WE WANT TO OPTIMIZE FOR?
▸ Querying ▸ Reading values ▸ Maintainable API ▸ Safe
Migrations ▸ Static + Dynamic Schemas
THE GOALS
▸ Cross-platform ▸ Memory-mapped ▸ Thread-safe ▸ Object-oriented ▸ Blazing
fast ▸ Sane interface
CROSS PLATFORM
People build services that need to run on multiple platforms.
Their database should reflect this.
MEMORY MAPPING
void *mmap( void *addr, size_t length, int prot, int flags,
int fd, off_t offset ); This function is magical.
Blur the line between in-memory and on-disk to get the
best of both worlds. Take advantage of optimizations in the kernel and let it do the hard work for you.
THREAD SAFETY
THREAD SAFETY PERHAPS THE MOST LOADED WORD IN CS
WELL-DEFINED THREADING MODEL ▸ What can be passed between threads?
▸ How easily can I isolate things that can’t be?
Built with speed & safety in mind: ▸ No reader
lock ▸ Allow concurrent reading & writing ▸ Let the user know when they violate the threading contract
OBJECT-ORIENTED API
▸ First-class model objects ▸ Support for persisted + in
memory objects ▸ No invisible web of classes
BLAZING FAST
WHY SHOULD OBJECTS AND THE DATABASE EVER GROW APART?
WHY SHOULD OBJECTS AND THE DATABASE EVER GROW APART? OR
WHERE ORMS WENT WRONG
▸ Lazily create objects in memory ▸ Access & set
values directly in the DB ▸ Optimized query engine
SANE API
▸ What do I need a reference to? ▸ Platform
coherence ▸ Isolate DB interaction ▸ Make it impossible to mess up
LET’S RECAP
▸ Cross-platform ▸ Memory-mapped ▸ Thread-safe ▸ Object-oriented ▸ Blazing
fast ▸ Sane interface
SOUNDS A LOT LIKE THE DREAM, RIGHT?
Make persistence just another aspect of your data, instead of
a whole convoluted system.
⾠ This might not be the approach for everyone. Take
a look at the goals, and see if they align with your own.
My company, Realm, is working towards building a database that
hits these bullet points. I’m not here to sell you on Realm. But building something that mirrors those goals is why we exist.
EXAMPLES?
Available now on Speaker Deck. https://speakerdeck.com/segiddins/whats-in-a-mobile-database
db.objects(Question).map { $0.ask }
SAMUEL GIDDINS REALM.IO @SEGIDDINS