Optimizing .dex IR strings lookup
Looking up strings is a very common operation during bytecode instrumention (since we keep a set of unique strings even allocating a string requires a lookup first) This change is the result of a couple of days of evaluating various options: - std::map - std::unordered_map - std::set - insertion sort - custom lookup index The std::unordered_map has superb runtime performance but at a high memory cost (~5Mb for large.dex). Crafting a specialized hash table using the same hash function (DBJ2a) resulted in a slightly faster index using only ~30% of the std::unordered_map<const char, String*> memory. Using this new string lookup, the overall time for stress_entry_hook over medium.dex improved considerably: before: 1050.294 ms, after: 264.143ms Test: bazel test :dexter_tests Change-Id: I9b5cb889707a498846c8f2530b28f58564a0598d
Loading
Please sign in to comment