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 struct strmap and associated utility functions #835
Conversation
/submit |
Submitted as pull.835.git.git.1598035949.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Jeff King wrote (reply to this):
|
On the Git mailing list, Elijah Newren wrote (reply to this):
|
On the Git mailing list, Elijah Newren wrote (reply to this):
|
On the Git mailing list, Jeff King wrote (reply to this):
|
User |
On the Git mailing list, Elijah Newren wrote (reply to this):
|
User |
On the Git mailing list, Jeff King wrote (reply to this):
|
Excellent job! Thank you for sharing and your outstanding dedication.
On Tue, Sep 1, 2020, 4:33 AM gitgitgadget-git[bot] <notifications@github.com>
wrote:
… On the Git mailing list
***@***.***>,
Jeff King wrote (reply to this
<https://github.com/gitgitgadget/gitgitgadget/wiki/ReplyToThis>):
On Fri, Aug 28, 2020 at 08:29:44AM -0700, Elijah Newren wrote:
> > It may also be a sign that we should be growing the hash more
> > aggressively in the first place. Of course all of this is predicated
> > having some benchmarks. It would be useful to know which part actually
> > provided the speedup.
>
> Your thoughts here are great; I also had another one this past week --
> I could introduce a hashmap_partial_clear() (in addition to
> hashmap_clear()) for the special usecase I have of leaving the table
> allocated and pre-sized. It'd prevent people from accidentally using
> it and forgetting to free stuff, while still allowing me to take
> advantage. But, as you say, more benchmarks would be useful to find
> which parts provided the speedup before taking any of these steps.
Yeah, having a separate function to explicitly do "remove all elements
but keep the table allocated" would be fine with me. My big desire is
that clear() should do the safe, non-leaking thing by default.
-Peff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#835 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQIEWFO4ZO5GX4J2HM4KCSTSDS5YBANCNFSM4QHO4NVA>
.
|
The existence of hashmap_free() and hashmap_free_entries() confused me, and the docs weren't clear enough. We are dealing with a map table, entries in that table, and possibly also things each of those entries point to. I had to consult other source code examples and the implementation. Add a brief note to clarify the differences. This will become even more important once we introduce a new hashmap_partial_clear() function which will add the question of whether the table itself has been freed. Signed-off-by: Elijah Newren <newren@gmail.com>
/submit |
Submitted as pull.835.v2.git.git.1602549650.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
This branch is now known as |
This patch series was integrated into seen via 67250e0. |
This patch series was integrated into seen via d335da2. |
This patch series was integrated into seen via 2294c72. |
This patch series was integrated into seen via 5b2f544. |
This patch series was integrated into seen via 3afbd9f. |
This patch series was integrated into seen via ca48df1. |
This patch series was integrated into seen via 0207fe2. |
This patch series was integrated into seen via 11b1c72. |
This patch series was integrated into seen via 28cce76. |
This patch series was integrated into seen via b637f1e. |
This patch series was integrated into seen via fac590c. |
This patch series was integrated into seen via 870b4e5. |
User |
For heavy users of strmaps, allowing the keys and entries to be allocated from a memory pool can provide significant overhead savings. Add an option to strmap_init_with_options() to specify a memory pool. Signed-off-by: Elijah Newren <newren@gmail.com>
By default, we do not use a mempool and strdup_strings is true; in this case, we can avoid both an extra allocation and an extra free by just over-allocating for the strmap_entry leaving enough space at the end to copy the key. FLEXPTR_ALLOC_STR exists for exactly this purpose, so make use of it. Also, adjust the case when we are using a memory pool and strdup_strings is true to just do one allocation from the memory pool instead of two so that the strmap_clear() and strmap_remove() code can just avoid freeing the key in all cases. Signed-off-by: Elijah Newren <newren@gmail.com>
Now that hashamp has lazy initialization and a HASHMAP_INIT macro, hashmaps allocated on the stack can be initialized without a call to hashmap_init() and in some cases makes the code a bit shorter. Convert some callsites over to take advantage of this. Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
/submit |
Submitted as pull.835.v6.git.git.1605124942.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Jeff King wrote (reply to this):
|
User |
This patch series was integrated into seen via 0a6426c. |
This patch series was integrated into seen via 0a12bba. |
This patch series was integrated into next via 41519a5. |
This patch series was integrated into seen via 349b680. |
This patch series was integrated into seen via 8b4a8be. |
This patch series was integrated into seen via d018753. |
This patch series was integrated into seen via bf0a430. |
This patch series was integrated into next via bf0a430. |
This patch series was integrated into master via bf0a430. |
Closed via bf0a430. |
Here I introduce new strmap, strintmap, and strset types.
Changes since v5:
[1] https://lore.kernel.org/git/20180906191203.GA26184@sigill.intra.peff.net/
CC: Jeff King peff@peff.net
cc: Elijah Newren newren@gmail.com
cc: Phillip Wood phillip.wood123@gmail.com
cc: Chris Torek chris.torek@gmail.com