why a developer writes

CPU Profiling Tools on Linux

| Comments

Profiling is an effective method to provide measurements for the performance of software applications. With profiling, you get fine grained information for the components of an application, such as how often a function is called, how long a routine takes to execute and how much time are spent of different spots in the code. With these information, you could identify the performance bottlenecks and the poorly implemented parts in a software application, and find effective methods to improve them.

In this post I’ll write a brief summary of two profiling methods: Instrumentation and Sampling, and four CPU profiling tools on Linux: perf, gprof, Valgrind and Google’s gperftools.

Profiling Methods

Different profiling methods use different ways to measure the performance of an application when it is executed. Instrumentation and Sampling are the two categories that profiling methods fall into.

Facebook Infrastructure: Streaming Video Engine (SVE)

| Comments

In last year’s Facebook F8 conference, Sachin Kulkarni, who worked on Facebook’s Video Infrastructure, gave a talk (watch it here) to introduce the design of Facebook’s Streaming Video Engine System (SVE). I found this talk particularly interesting because it revealed, in a very well structured, concise yet informative way, how Facebook infrastructure team came up with a solution to build a video system solving user frustrations by reviewing the end-to-end process, and how such a design meet the goal of being fast, flexible, scalable, and efficient. After watching the presentation video for a few times, I thought it would be helpful to write down some notes here, for my own reviewing in the future, and for people who might be interested in Facebook’s media infrastructure.

Sharing on Facebook started from largely text, and quickly changed to be largely photos. Since 2014, more videos started to be posted and shared among users. The challenge was, building a video processing system is much harder than building a text or image processing system. Videos are greedy, they will consume all your resources: CPU, memory, disk, network, and anything else.

Before building the Streaming Video Engine system, the team started by reviewing Facebook’s existing video uploading and processing process, which was slow and not scalable. They found several problems need change or improvement:

How Instagram Moved to Python 3

| Comments

Instagram, the famous brunch sharing app, presented in PyCon 2017 and gave a talk in the keynote session on “How Instagram moves to Python 3”. If you have 15 minutes, read the interview with the speakers, Hui Ding and Lisa Guo from Instagram Infrastructure team, here. If you have 45 minutes, watch their PyCon talk video, here. If you have only 5 minutes, continue reading, right here.

Instagram’s backend, which serves over 400 million active users every day, is built on Python/Django stack. The decision on whether moving from Python 2 to Python 3, was really a decision on whether investing in a version of the language that was mature, but wasn’t going anywhere (Python 2 is expected to retire in 2020) – or the language that was the next version and had great and growing community support. The major motivations behind Instagram’s migration to Python 3 are:

  • Typing support for dev velocity
  • Better performance than Python 2
  • Community continues to make Python 3 better and faster

The whole migration process took about 10 months, in roughly 3 stages.

CMake: Use the Correct Options to Solve Linker Errors

| Comments

A few months ago when I worked on a project using zlib to compress and decompress files, I once met linker errors complaining about unable to resolve symbols of zlib functions:

cannot resolve symbols _gzbuffer, _gzopen, ...

In the end I fixed these linker errors by using TARGET_LINK_LIBRARIES command in the project’s CMakefile to specify the linker package dependency, as the following:

TARGET_LINK_LIBRARIES(myProject zlibstatic)

When I was looking for solutions to fix those linker errors, I found several related CMake commands which look quite similar and could be confusing in terms of their functions and when to use them. Here is a quick summary of these commands.

Related CMake commands:

  • add_dependencies
  • link_directories
  • link_libraries
  • target_link_libraries

谈谈微信小程序的入口设计 | on WeChat Design for Mini Programs

| Comments


  1. 对微信产品设计的认可和关注
  2. 对张小龙产品设计理念的好奇与学习

最近几个月来微信最引人注目的功能变化,无疑是“微信小程序”的推出和初步推广。微信小程序,英文版名称为Mini Program,其实是微信推出的类似于React和Weex的以Javascript为基础的程序框架。微信小程序为开发者提供了各种UI组件和调用底层的API。通过小程序实现的App,无需安装就可以在微信平台使用。

微信小程序的入口,设置在微信底部4个固定Tab之一的”发现“菜单中。从功能上来看,微信小程序的入口类似于Apple App Store,但它的设计和App Store完全不同。下面是一些比较。