Skip to content
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

feat(strmap): new pkg for optimizing GC issues #26

Merged
merged 1 commit into from
Sep 17, 2024
Merged

feat(strmap): new pkg for optimizing GC issues #26

merged 1 commit into from
Sep 17, 2024

Conversation

xiaost
Copy link
Collaborator

@xiaost xiaost commented Sep 16, 2024

Usage:

m := make(map[string]bool)
// populate m
// ...

sm := strmap.New(m)
m = nil // no need the original map

v, ok := sm.Get(key) // it replaces v, ok := m[key]

Benchmark:

BenchmarkGC/std-keysize_20_n_100000-12          	     126	    950226 ns/op
BenchmarkGC/new-keysize_20_n_100000-12          	    1069	    110980 ns/op
BenchmarkGC/std-keysize_100_n_100000-12         	     145	    888562 ns/op
BenchmarkGC/new-keysize_100_n_100000-12         	    1023	    112419 ns/op
BenchmarkGC/std-keysize_20_n_400000-12          	      87	   2935875 ns/op
BenchmarkGC/new-keysize_20_n_400000-12          	    1032	    112177 ns/op
BenchmarkGC/std-keysize_100_n_400000-12         	      46	   2813522 ns/op
BenchmarkGC/new-keysize_100_n_400000-12         	    1054	    110864 ns/op

This change also deprecated xfnv which is an experimental impl, and it's not good enough in terms of distribution

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

Usage:
```
m := make(map[string]bool)
// populate m
// ...

sm := strmap.New(m)
m = nil // no need the original map

v, ok := sm.Get(key) // it replaces v, ok := m[key]
```

Benchmark:
```
BenchmarkGC/std-keysize_20_n_100000-12          	     126	    950226 ns/op
BenchmarkGC/new-keysize_20_n_100000-12          	    1069	    110980 ns/op
BenchmarkGC/std-keysize_100_n_100000-12         	     145	    888562 ns/op
BenchmarkGC/new-keysize_100_n_100000-12         	    1023	    112419 ns/op
BenchmarkGC/std-keysize_20_n_400000-12          	      87	   2935875 ns/op
BenchmarkGC/new-keysize_20_n_400000-12          	    1032	    112177 ns/op
BenchmarkGC/std-keysize_100_n_400000-12         	      46	   2813522 ns/op
BenchmarkGC/new-keysize_100_n_400000-12         	    1054	    110864 ns/op
```

This change also deprecated xfnv which is an experimental impl,
and it's not good enough in terms of distribution
@xiaost xiaost merged commit ab10e41 into main Sep 17, 2024
16 checks passed
@xiaost xiaost deleted the feat-strmap branch September 17, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants