New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a find_add function in Hashtbl (weak and not weak) #7644
Comments
Comment author: @xavierleroy This is a common usage pattern for hash tables, indeed. Just make sure that the "find_add" function you propose increases performance noticeably. I would expect some performance increase for hashtables but none for purely-functional maps. |
Comment author: ChriChri Why no increase for purely functional map ? I think you divide by two the number of compare, Anyway, I will propose it for hash tables first. |
Comment author: ChriChri I just did a PR with update for Hashtbl and Ephemeron as in Map. This only increase speed when
On the test I did, find_add (which I implemented too) is faster because |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Original bug ID: 7644
Reporter: ChriChri
Status: acknowledged (set by @xavierleroy on 2017-09-29T18:03:11Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.05.0
Category: standard library
Monitored by: ChriChri
Bug description
When using hash on medium or large structure,
very often the time spend in hash (reported by profiling)
is between 5% and 15% of the total time (from gprof of perf).
Often this program use a pattern like (common for memoization):
I propose to add a function that replaces the above by
This both simplifies the code and divides by 2 the number of call to hash.
Similar functions could be added for weak hashtbl and Map library.
Additional information
If people agree that it is worth it, I will propose a pull request.
The text was updated successfully, but these errors were encountered: