Description
While examining Box64's memory management system, particularly the usage of rbtree
, I observed unusual behavior involving the dynamap
tree. By running Box64 combined with Wine64 on a Windows 64-bit chess game, I noticed that the dynamap
tree significantly outnumbers other trees in node count. However, despite the high node usage, nodes from dynamap
were rarely (if ever) actively accessed during execution (rb_get
, rb_get_64
, rb_get_end
, rb_get_end_64
, rb_get_right
or rb_get_left
calls).
Additionally, I collected detailed statistics on node creation and usage:
A total of 54,306 rbtree nodes were created during execution.
Only 17,886 nodes were released before the process terminated.
Among the released nodes, the breakdown of unused nodes (i.e., created but never accessed) is as follows:
blockstree
: 0 unused nodesdb_sizes
: 52 unused nodesdynamap
: 16,697 unused nodes (100% of releaseddynamap
nodes were unused)envmap
: 1 unused nodemapallmem
: 158 unused nodesmapmem
: 105 unused nodesmemprot
: 873 unused nodesrbt_dynmem
: 0 unused nodes
To further verify this observation, I experimentally disabled the usage of dynamap within the Box64 codebase and repeated my tests. Surprisingly, the system functioned perfectly without noticeable issues.
int rb_set_64(rbtree_t *tree, uintptr_t start, uintptr_t end, uint64_t data) {
if(!strcmp(“dynamap”, tree->name))
return 0;
//--skip--//
}
Given these observations, I seek clarification on the following points:
-
Intended Purpose: What was the initial purpose behind implementing the
dynamap
tree within Box64's memory management system? -
Node Utilization: Why does
dynamap
contain so many nodes if these nodes are rarely (or never) accessed during regular operations? -
Impact of Removal: Considering that disabling
dynamap
had no observable negative impact in my tests, could removing or optimizingdynamap
improve memory efficiency or overall performance?
Experimental Environment:
- Box64 Version: v0.3.5 d3d3fa2 on apr 7
- Wine64 Version: wine-9.22
- Host System: Raspberry Pi 400 running
Linux Debian 6.12.3-arm64 #1 SMP Debian 6.12.3-1 (2024-12-07) aarch64 GNU/Linux
- Game Tested: chess
- Build Configuration:
cmake \
-G Ninja \
-D RPI4ARM64=1 -D ARM_DYNAREC=ON \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D CMAKE_C_COMPILER=aarch64-none-linux-gnu-gcc \
..
ninja