how facebook cut image load times in half

Post on 01-Jul-2015

527 Views

Category:

Internet

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Saving a Century a Day:Cut image loading time in half

Tyrone Nicholas

Software Engineer

10 October 2014

Demo

The Image Pipeline

JPG

BMP

BMP JPG

JPG

JPG

UI thread Non-UI threads

The bane of our existence

Android memory heapsDalvik Native

Native memory

Using native memory“Naïve native”

Native pools and streams

Native pools and streams

OutputStream

InputStream

Image Operation

Native Chunk

Native Chunk

Native ChunkNative

Chunk

Pool

Pinned purgeables

PurgeablesHowto

How purgeables work

Need memory?

Look for unpinned memory

Free it

Ashmem

• allocate

• pin

• unpin

How purgeables work

Allocate Draw Pin Decode

Stop drawing

Unpin

Draw cycle

Er, wait a minute…

How to do it (1)

How to do it (2)

Benefits

Risks

Reference counting in Java

SharedReference

CloseableReference

Using references

When?

When are you done with a bitmap?

Safe closing

Put byte buffers in native memory

Use purgeable bitmaps and pin them

Free your objects at the right time

(c) 2009 Facebook, Inc. or its licensors. "Facebook" is a registered trademark of Facebook, Inc.. All rights reserved. 1.0

tnicholas @ fb.com

Twitter: @tyronen

We’re hiring!

top related