At the beginning

Writing good documents is a highly sought-after skill in big factories. It’s not just a nice addition, it’s a weapon that many engineers use to get promoted and make their voices heard. One of the things I learned during my two years in the group was that most of the best senior engineers (not including the ones who just muddled along and got promoted by seniority) had a solid ability to write documents and capture the G-spot of their superiors and projects.

Some people may think that I am good at writing documents, why should I improve my ability to write documents? I should read more source code analysis. This is a common puzzle for beginning or novice engineers. This is because most of the friends who have just entered the industry have a very deep misunderstanding, that is, they think that doing software engineering is a job dealing with computers, but in fact it is not. Software engineering is not only dealing with code, but more importantly dealing with people. It is a very social job. In most companies, especially big factories, there are very, very many people and groups involved. In a small factory, people can exchange ideas and design by word of mouth, but once the number of people began to increase, only rely on documents. Unless you’re good enough to do all the coding yourself, it’s probably best to be honest about your documentation skills.

If you’re in the habit of writing a technical blog, congratulations, you’ve got some tips on how to reach a document audience. This will help you survive in dachang. Don’t be sad if you don’t, this article was designed with you in mind.

In this article, I will roughly put an Android project design document skeleton, and some of my work actually encountered positive and negative examples are listed, convenient for everyone to practice in the future work.

Scudo is a user-mode allocator designed to provide an additional mitigation approach to preventing heap vulnerabilities while maintaining good performance. It is open source and is part of LLVM’s Editor-RT project.

Scudo is currently the default allocator in Fuchsia and is enabled in some Android components and used in some Google production services. Although originally implemented on top of some components of Sanitizer_common, it has now been rewritten as stand-alone without relying on other compiler-RT parts for ease of use (and other performance and security benefits).

Scudo consists of the following components:

Primary distributor

This is a fast allocator for handling smaller requests (configurable at compile time). It is “isolated”, for example: blocks of the same size end up in the same storage area and are separated from other areas (64-bit separation is stronger, where storage areas are reserved for the main area); Blocks allocated by the master node are randomly allocated to avoid predictable sequences of addresses (note that the larger the size, the more predictable the addresses are from each other).

Secondary distributor

Wrapper platform memory allocation primitives, and therefore slower, for servicing larger allocations. Allocations done by secondary servers are surrounded by protected pages;

The local cache

These are thread-specific stores that hold Pointers to free blocks to reduce contention on the global free list. There are two modes: exclusive mode and shared mode. With the exclusivity model, each thread has a unique cache, which takes up more memory but has little contention. With a shared model, threads can share a certain amount of caches that can be dynamically reallocated at run time based on contention — it uses less memory than a dedicated model and generally better meets the needs of the end-user platform.

isolation

This can be equivalent to a deferred release list in the heap scope, where the most recently released block is retained for a period of time until a condition (usually a certain size) is met before it is released to the system. There are threads quarantines and a global quarantine. This is the most impactful in terms of memory usage and to some extent performance: even a small quarantine can have a big impact on the process RSS. Therefore, it is disabled by default and can be enabled on a per-process basis (and resized as needed by the process).

security

Enforce maximum size and alignment values, but also check that supplied Pointers are properly aligned; These are cheap checks to avoid integer overflows and to catch lower pending allocation errors (or abuses);

Each block is preceded by a header, which stores basic information about the allocation and a checksum to detect if the memory is corrupted.

The checksum of the header, the Pointers to work with, and the contents of the header – this is not meant to be cryptographically strong. As for the data stored in the header file, it holds the size of the allocation, the state of the block (available, allocated, quarantined), its origin (malloc, new, new []), and some internal data. Headers are atomically operated to detect competing attempts between threads running on the same block.

Ensure that the release function is consistent with the allocation function that returns the target block (e.g., free/malloc, delete/new); We randomly assign everything to make it as predictable as possible; One of the side benefits of thread caches is that if an attacker leverages allocation primitives in different threads, they make it more difficult for the attacker to get the required block in the desired state.

Let’s take a look at some typical benchmarks for Google production services, which involve many asynchronous threads, Protobuf, RPC and other benefits, all running on 72-core Xeon machines with 512GB of RAM (not to make the most rigorous comparison, but to keep you up to date). The first metric is the number of queries per second, and the second metric is the program’s RSS peak (reported by /usr/bin/time).

The last

In a word, the Android development industry is changing too fast, so as a technician, we should maintain a lifelong learning attitude and make learning ability become the core competitiveness. The so-called “lifelong learning”, only by constantly learning and constantly improving ourselves, can we keep up with the pace of the industry and not be eliminated by The Times.

Here I share a themselves, included finishing technology system diagram above related scores of companies such as tencent, headlines, ali, Meituan 19 years of interview questions, put together a video technology points and PDF (actually spent a lot of energy more than expected), contains the knowledge context + details, as space is limited, in the form of pictures here to show you. Need a friend can private letter I [information] or point here for free

There are advanced architecture technology advanced brain map, Android development interview topic information, advanced architecture information to help you learn to improve the advanced, but also save you on the Internet to search for information time to learn, can also share with friends around to learn together. Android learning PDF+ architecture video + the latest interview documents + source notes