Skip to content

Hash table inefficiencies #4149

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

Merged
merged 18 commits into from
May 29, 2025
Merged

Conversation

Ian2327
Copy link
Contributor

@Ian2327 Ian2327 commented Apr 29, 2025

Proposed Changes

Current state of hash table bucket halving. Currently implemented in hash_table.h under HASH_TABLE_ITERATE

Merge Checklist

The following items must be completed before PRs can be merged.
Check these off to verify you have completed all steps.

  • make test Run local tests prior to pushing.
  • make format Format source code to comply with lint policies. Note that some lint errors can only be resolved manually (e.g., Python)
  • make lint Run lint on source code prior to pushing.
  • Manual Update: Update the manual to reflect user-visible changes.
  • Type Labels: Select a github label for the type: bugfix, enhancement, etc.
  • Product Labels: Select a github label for the product: TaskVine, Makeflow, etc.
  • PR RTM: Mark your PR as ready to merge.

@btovar btovar added this to the 7.15.3 milestone May 2, 2025
@btovar btovar modified the milestones: 7.15.3, 7.15.4 May 13, 2025
@btovar
Copy link
Member

btovar commented May 27, 2025

Updated benchmarks (calling reduce table on hash_table_remove). Note that the timings for adding and removing are pretty similar now. For each step, (2^i - 1) entries are added or removed. Every time an entry is added or removed, the benchmark calls HASH_TABLE_ITERATE.

INSERTION PHASE:
step   0 size          1 load_max 0.007874 load_now 0.007874 time 0.000001
step   1 size          3 load_max 0.023622 load_now 0.023622 time 0.000001
step   2 size          7 load_max 0.055118 load_now 0.055118 time 0.000002
step   3 size         15 load_max 0.118110 load_now 0.118110 time 0.000004
step   4 size         31 load_max 0.244094 load_now 0.244094 time 0.000010
step   5 size         63 load_max 0.496063 load_now 0.496063 time 0.000023
step   6 size        127 load_max 0.755906 load_now 0.498039 time 0.000074
step   7 size        255 load_max 0.752941 load_now 0.499022 time 0.000309
step   8 size        511 load_max 0.751468 load_now 0.499511 time 0.001174
step   9 size       1023 load_max 0.750733 load_now 0.499756 time 0.004688
step  10 size       2047 load_max 0.750366 load_now 0.499878 time 0.020509
step  11 size       4095 load_max 0.750183 load_now 0.499939 time 0.112303
step  12 size       8191 load_max 0.750092 load_now 0.499969 time 0.613042
step  13 size      16383 load_max 0.750046 load_now 0.499985 time 2.777665
step  14 size      32767 load_max 0.750023 load_now 0.499992 time 11.401937
step  15 size      65535 load_max 0.750011 load_now 0.499996 time 45.774249
REMOVAL PHASE:
step  15 size      32767 load_min 0.249994 load_now 0.249994 time 49.533629
step  14 size      16383 load_min 0.124993 load_now 0.124993 time 15.401450
step  13 size       8191 load_min 0.062493 load_now 0.062493 time 5.421695
step  12 size       4095 load_min 0.031243 load_now 0.031243 time 2.160678
step  11 size       2047 load_min 0.015617 load_now 0.015617 time 0.945477
step  10 size       1023 load_min 0.007805 load_now 0.007805 time 0.440412
step   9 size        511 load_min 0.003899 load_now 0.003899 time 0.211325
step   8 size        255 load_min 0.001946 load_now 0.001946 time 0.103570
step   7 size        127 load_min 0.000969 load_now 0.000969 time 0.051359
step   6 size         63 load_min 0.000481 load_now 0.000481 time 0.025469
step   5 size         31 load_min 0.000237 load_now 0.000237 time 0.012639
step   4 size         15 load_min 0.000114 load_now 0.000114 time 0.006320
step   3 size          7 load_min 0.000053 load_now 0.000053 time 0.003150
step   2 size          3 load_min 0.000023 load_now 0.000023 time 0.001588
step   1 size          1 load_min 0.000008 load_now 0.000008 time 0.000810
step   0 size          0 load_min 0.000000 load_now 0.000000 time 0.000407

@btovar
Copy link
Member

btovar commented May 28, 2025

Doubling and halving with reusing old entries (less mallocs) does make a difference:
(about 10s for the case of 64K entries)

INSERTION PHASE:
step   0 size        1 buckets      127 load_max 0.007874 load_now 0.007874 time 0.000001 time_norm 0.000001
step   1 size        3 buckets      127 load_max 0.023622 load_now 0.023622 time 0.000001 time_norm 0.000000
step   2 size        7 buckets      127 load_max 0.055118 load_now 0.055118 time 0.000001 time_norm 0.000000
step   3 size       15 buckets      127 load_max 0.118110 load_now 0.118110 time 0.000003 time_norm 0.000000
step   4 size       31 buckets      127 load_max 0.244094 load_now 0.244094 time 0.000007 time_norm 0.000000
step   5 size       63 buckets      127 load_max 0.496063 load_now 0.496063 time 0.000017 time_norm 0.000001
step   6 size      127 buckets      255 load_max 0.755906 load_now 0.498039 time 0.000057 time_norm 0.000001
step   7 size      255 buckets      511 load_max 0.752941 load_now 0.499022 time 0.000217 time_norm 0.000002
step   8 size      511 buckets     1023 load_max 0.751468 load_now 0.499511 time 0.000843 time_norm 0.000003
step   9 size     1023 buckets     2047 load_max 0.750733 load_now 0.499756 time 0.003290 time_norm 0.000006
step  10 size     2047 buckets     4095 load_max 0.750366 load_now 0.499878 time 0.013082 time_norm 0.000013
step  11 size     4095 buckets     8191 load_max 0.750183 load_now 0.499939 time 0.058701 time_norm 0.000029
step  12 size     8191 buckets    16383 load_max 0.750092 load_now 0.499969 time 0.380795 time_norm 0.000093
step  13 size    16383 buckets    32767 load_max 0.750046 load_now 0.499985 time 1.938658 time_norm 0.000237
step  14 size    32767 buckets    65535 load_max 0.750023 load_now 0.499992 time 8.082540 time_norm 0.000493
step  15 size    65535 buckets   131071 load_max 0.750011 load_now 0.499996 time 32.875638 time_norm 0.001003
REMOVAL PHASE:
step  15 size    32767 buckets   131071 load_min 0.249994 load_now 0.249994 time 35.550363 time_norm 0.001085
step  14 size    16383 buckets    65535 load_min 0.125001 load_now 0.249989 time 11.423033 time_norm 0.000697
step  13 size     8191 buckets    32767 load_min 0.125002 load_now 0.249977 time 2.761504 time_norm 0.000337
step  12 size     4095 buckets    16383 load_min 0.125004 load_now 0.249954 time 0.610764 time_norm 0.000149
step  11 size     2047 buckets     8191 load_min 0.125008 load_now 0.249908 time 0.117709 time_norm 0.000057
step  10 size     1023 buckets     4095 load_min 0.125015 load_now 0.249817 time 0.024749 time_norm 0.000024
step   9 size      511 buckets     2047 load_min 0.125031 load_now 0.249634 time 0.005994 time_norm 0.000012
step   8 size      255 buckets     1023 load_min 0.125061 load_now 0.249267 time 0.001561 time_norm 0.000006
step   7 size      127 buckets      511 load_min 0.125122 load_now 0.248532 time 0.000382 time_norm 0.000003
step   6 size       63 buckets      255 load_min 0.125245 load_now 0.247059 time 0.000103 time_norm 0.000002
step   5 size       31 buckets      127 load_min 0.125490 load_now 0.244094 time 0.000026 time_norm 0.000001
step   4 size       15 buckets      127 load_min 0.118110 load_now 0.118110 time 0.000010 time_norm 0.000001
step   3 size        7 buckets      127 load_min 0.055118 load_now 0.055118 time 0.000004 time_norm 0.000001
step   2 size        3 buckets      127 load_min 0.023622 load_now 0.023622 time 0.000002 time_norm 0.000001
step   1 size        1 buckets      127 load_min 0.007874 load_now 0.007874 time 0.000001 time_norm 0.000001

@btovar btovar merged commit 1b3bf37 into cooperative-computing-lab:master May 29, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants