Origin of Ray

Lift the fog of the Internet together

After reading the chapter of the storage system in the principle of computer composition, combined with the memory management and file management in the operating system, I have a new understanding of the storage management of the entire computer, and here I will summarize it together.
First of all, I will throw out a few new understandings after reading it in general:

  • Computer storage management is hierarchical, from cache to memory to external memory, the speed is reduced in turn, the size is gradually increased, and the price is gradually cheaper.
  • The speed at which the CPU obtains data from these three layers gradually decreases. We have done so many operations in storage management. In fact, it is to save money at the same time, not only improve the access speed (locality principle, layer-by-layer cache), but also improve the available address space (virtual memory).
  • No matter which level, the problems faced are address mapping, space allocation, and replacement strategy when space is not enough (the three are strongly correlated, such as the allocation method of paging, address mapping It is necessary to use the page table, the allocation method of request paging, and the allocation and replacement of space are also strongly correlated).
  • Replacement strategies are only needed when there is insufficient space, such as cache replacement, such as request-style paged memory. Like continuous allocation or ordinary paging allocation, there is no replacement strategy. If there is not enough space, it will not be allocated, and there is no problem of which memory to temporarily replace.
  • Various space management methods are not independent, but have an inherent progressive relationship. Taking memory allocation as an example, it is continuous allocation at the beginning, but it is found that continuous allocation is prone to fragmentation problems, so it is thought of discontinuous allocation. Discontinuous allocation is divided into segmentation, paging and segment paging, but note that so far, it is only a problem of memory allocation, and the entire program still needs to be completely loaded into memory at the beginning. Therefore, we put forward the concept of virtual memory. In order to match the virtual memory, we upgrade the segmentation, paging and segment page type to request type, and there will be more fields in the page table entry or segment table entry for the external memory address when the page is missing., there will be more fields for the flag when memory is replaced.
  • Paging/segment and virtual memory are two different things. Paging is a way of space allocation, and virtual memory is a way to logically expand Memory Space, but virtual memory uses requested paging or segmentation.
  • Continuous allocation and basic paging segmentation only have allocation strategies, such as first adaptation algorithm, near adaptation algorithm, etc., but there is no special replacement strategy, there is no replacement when the program is still running, it is all allocated at one time, and it can be allocated. Run and uninstall all at once after running. And its allocation strategy like request paging also involves replacement strategy.
  • The memory access path of modern operating systems is roughly as follows: first, the program gives the relative address of virtual memory for instructions or data, then obtains the actual address of virtual memory through address relocation, and then queries whether the segment table or page table has been loaded into memory. In memory, if it is loaded into memory and in cache, it will return directly from cache. If it is in memory and no longer in cache, it will be loaded from memory and updated cache (replacement may occur). If it is not in memory, it will be loaded from page Find the external memory address in the table entry, load it into memory (replacement may occur), and then return to the CPU and update the cache No.
Read more »

Recently, I have been researching Unity Performance optimization related content and came into contact with several Unity official tools. Here is a summary of how they are used and how to use them in combination.

I mainly use the following tools:

  • UPR(Unity Performance Report)
  • Profiler
  • Memory Profiler

First, let’s talk about the relationship between the three in general: Profiler is a performance analysis tool that comes with Unity Editor. It does not require additional downloads and can collect performance data of CPU, GPU, memory, Render, physics, network, etc. The UPR uses the data of the Profiler for further professional analysis and statistics. The Memory Profiler conducts a special analysis of the memory data of the Profiler, and can collect snapshots of the memory during operation.

Read more »

After we package Unity into an apk in il2cpp + release mode, the internal code will be packaged into a so file. This thing is actually the format of the Linux dynamic link library, which corresponds to the DLL of Windows or the dylib of Mac. It can also be called a symbol table on the android side, because it will store the correspondence between the virtual memory address and the assembly code internally.

After packaging in this way, it will reduce our package size and help our code to protect against plagiarism, but it will also cause us developers to not understand the error message, because these error messages are virtual memory addresses, not The name of the function, so how do we read the error message that occurs online?

Read more »

Recently, I found that the Unity project consumes a lot of memory during operation, and there will be frequent GC causing the game’s CPU to overheat. So I went to read the official best practice doc, learned some knowledge of Unity’s memory management, and summarized it a little.

Read more »

With the gradual increase in use, I can’t stand the use of these concepts in the vague situation, so I found some official doc to learn these concepts in C #, mainly to distinguish between delegates and events.

In fact, I personally have been very vague about these concepts before reading the doc, and even once was confused by various blogs on the Internet, and even confused Action, Func and commission.

Finally, after I went to read the official doc, I had some understanding of these concepts.

First of all, the most important conclusion is thrown. Both delegates and events are to provide a way to post-process functions. Events are actually multicast based on delegates, and it is inconvenient to define a new delegate type every time you use a delegate, so it is provided. Two strong types of delegates are Action and Func.

Read more »

Demand background

The upper limit of the game room can have a maximum count of people. When the user enters the room, he needs to go to the remote server to obtain the clothing configuration of the count characters. After the acquisition is successful, load them one by one.
The current solution is to get the configuration of all characters at once, and then do it in a way that loads almost simultaneously.
In the worst case, this solution will have count Replacement tasks running at the same time, resulting in CPU Preemption between count tasks, and the result is that it looks stuck.
In order to make the performance of the game more smooth, it is necessary to design a plan for prioritized batch loading.

Read more »

We all know that the core of the computer is the CPU, and the CPU is the arithmetic unit and controller, and its role is to perform mathematical operations.

If you want to understand the working principle of the CPU, you must start from two aspects, on the one hand, how the data in the computer is represented, and on the other hand, how the operation rules are and how the computer uses the circuit to represent this operation.

Read more »

Trying to bake a scene this week, after introducing two oversized terrains, re-baked, encountered two problems, the first problem, there were a lot of dark spots in some parts of the terrain, and the second problem, the number of lightmaps I had skyrocketed, from 3 to 16.

I asked other bosses for their opinions, because the terrain is too large.

Read more »
0%