aconfig: update aconfig_storage_read_api
Right now, aconfig_storage_read_api rust lib would own mapped files. So individual flag lib does not need to. The original intent is that all these flag lib can dynamically link against this lib. So say we have different variants of flag lib for one flag package, there is just one unique memory mapped file. In addition, the exposed rust apis hides the memory mapped files. So when exporting these apis to c++/java, we don't have to implement memory mapping in c++/java flag read api lib. However, this design has its own downside. The biggest being that these memory mapped files are stored in a mutable static hash map. For rust, it must be protected by a mutex lock. The real effect on the lock is mostly minimal as it immediately unlocks when the clone of memory mapping is returned. But still we could get more performance out of it in exchange of having more c++/java side implementation of mapping files. (Note, apis that interpret mapped files are still exported by Rust, so no c++/java implementation needed). In this change, aconfig_storage_read_api give away its ownership of memory mapped file in its api to get memory mapped file. The memory mapped file is supposed to be owned by generated flag lib. By doing so, no more mutex lock is needed. Also, since each flag lib has one flag package, which maps to a single owning container. The flag lib can have the memory mapped files as non mutable static variables. So no mutex lock penalty on flag lib side. Bug: b/321077378 Test: atest aconfig_storage_read_api.test; atest aconfig_storage_read_api.test.rust Change-Id: I29060bae90db6f7d296252ed73f7e312143f4b7e
Loading
Please register or sign in to comment