[DYNAREC] Optimized bigblock add_next performance with hash table#3890
Merged
Conversation
I noticed that when I run `wine explorer` with Wine 11.8 without DynaCache on a Snapdragon 8cx Gen3, there is a hotspot on `add_next`:
```diff
- 22.63% 22.62% explorer.exe box64 [.] add_next
0.01% 0.01% wine64 box64 [.] add_next
0.00% 0.00% wineserver box64 [.] add_next
```
After applying this optimization, the hotspot disappeared:
```diff
+ 0.94% 0.57% explorer.exe box64 [.] add_next
0.02% 0.01% wine64 box64 [.] add_next
0.00% 0.00% conhost.exe box64 [.] add_next
```
The measured startup time of `wine explorer` dropped from 21s to 16s, which is now quite close to the 14s achieved with DynaCache enabled.
ptitSeb
reviewed
May 24, 2026
| if(k != kh_end(khnextset)) | ||
| return; | ||
| int ret; | ||
| kh_put(nextset, khnextset, addr, &ret); |
Owner
There was a problem hiding this comment.
There is a way to just use kh_put here, instead of kh_get+kh_put, and check ret to see if kh_put actualy add a key or not (ret==0 eans key aready exist so can exit here)
Owner
|
Interesting, but I wonder if an rbtree woud be better, as there is a notion of order in the added addresses? |
Collaborator
Author
|
I'll give rbtree a try. |
Collaborator
Author
|
nah I don't think an rbtree is useful here, a sorted array is more suitable. but anyway, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed that when I run
wine explorerwith Wine 11.8 without DynaCache on a Snapdragon 8cx Gen3, there is a hotspot onadd_next:- 22.63% 22.62% explorer.exe box64 [.] add_next 0.01% 0.01% wine64 box64 [.] add_next 0.00% 0.00% wineserver box64 [.] add_nextAfter applying this optimization, the hotspot disappeared:
+ 0.94% 0.57% explorer.exe box64 [.] add_next 0.02% 0.01% wine64 box64 [.] add_next 0.00% 0.00% conhost.exe box64 [.] add_nextThe measured startup time of
wine explorerdropped from 21s to 16s, which is now quite close to the 14s achieved with DynaCache enabled.