Improving Djinni - Snap Engineering
Read Full ArticleSummary
The article discusses the enhancements made to the Djinni project, a tool for generating bridging code between C++ and other programming languages, particularly for mobile applications. It highlights performance issues related to string marshalling and binary data transfer across the JNI boundary, detailing optimizations such as the introduction of DataView and DataRef types for efficient data handling. The article also addresses stability concerns with Java finalizers in the context of Android's garbage collection, proposing a solution that involves managing native object finalization outside of the Java GC. Overall, these improvements significantly enhance the performance and reliability of Snap's mobile applications.
Key Learnings
- 1Optimizing string marshalling by switching to standard UTF-16 encoding can lead to significant performance gains.
- 2Introducing zero-copy data handling types like DataView and DataRef can reduce overhead when transferring large binary data.
- 3Managing native object finalization in a dedicated cleanup thread can prevent crashes related to garbage collection in Android.
- 4Understanding the implications of JNI calls on performance is crucial for mobile development using C++.
- 5Maintaining a fork of an open-source project allows for tailored improvements that address specific organizational needs.
Who Should Read This
Senior Mobile Developers with experience in C++ looking to optimize cross-platform mobile application performance.
Test Your Knowledge
What are the trade-offs of using DataView versus DataRef for data transfer in Djinni?
How does the choice of string encoding impact performance in JNI calls?
What failure scenarios could arise from relying on Java finalizers for native object management?
Why is it important to optimize the performance of C++ code in mobile applications?
How do the improvements made to Djinni enhance cross-platform development for Snap's applications?
Topics
More articles about C++
Explore C++ engineering →More from Snap (Snapchat) Engineering
View Snap (Snapchat) engineering blogs →Spectacles - EyeConnect
The article discusses EyeConnect, a feature designed to facilitate shared augmented reality experiences by allowing users to connect their Spectacles through a novel motion tracking algorithm. Unlike...
Universal User Modeling (UUM): A Foundation Model for User Understanding at Snapchat
The article discusses Universal User Modeling (UUM) at Snapchat, a foundational model designed to enhance user understanding across various product surfaces. UUM captures user behaviors over time by...
From Monolith to Multicloud Micro-Services: Inside Snap’s Service Mesh - Snap Engineering
The article outlines Snap Engineering's transition from a monolithic application architecture to a microservices architecture deployed across multiple cloud providers, specifically AWS and Google...
Don't Rewrite Your App, Unless You Have To - Snap Engineering
The article discusses the Snapchat Engineering team's experience in rewriting their Android app to enhance performance and reduce bugs. It outlines the challenges faced due to the app's complexity...
Making The Most of a Rewrite - Snap Engineering
The article outlines the process and considerations involved in rewriting the Snapchat application, focusing on architectural improvements to enhance performance and maintainability. It emphasizes...