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

[FEATURE]: Support for Type Parameters, aka, generics #317

Open
paivagustavo opened this issue Nov 28, 2022 · 1 comment
Open

[FEATURE]: Support for Type Parameters, aka, generics #317

paivagustavo opened this issue Nov 28, 2022 · 1 comment
Labels
kind/feature Something completely new we should consider.

Comments

@paivagustavo
Copy link

Have you tried Ristretto before this proposal? and did not find anything similar?

No response

What you wanted to do.

I would like to be able to use the ristretto cache using type parameters to avoid conversions to/from interface{}. This both makes the code more performant and also cleaner to use.

What you actually did.

No response

Why wasn't it great, with examples.

No response

Additional information.

I've done an experiment migrating ristretto to Generics, It does seems to have positive impact on performance as well as we can see on some benchmarks added:

benchstat
name                            old time/op    new time/op    delta
CacheSet-8                        26.8ns ±15%    19.4ns ± 6%   -27.36%  (p=0.000 n=10+10)
ConcurrentCacheSetNeverEvict-8    80.1ns ±10%    78.4ns ±24%      ~     (p=0.661 n=9+10)

name                            old speed      new speed      delta
CacheSet-8                      37.5MB/s ±14%  51.5MB/s ± 6%   +37.18%  (p=0.000 n=10+10)

name                            old alloc/op   new alloc/op   delta
CacheSet-8                          113B ± 5%       79B ± 5%   -30.38%  (p=0.000 n=10+10)
ConcurrentCacheSetNeverEvict-8      105B ± 0%       88B ± 0%   -16.19%  (p=0.001 n=7+7)

name                            old allocs/op  new allocs/op  delta
CacheSet-8                          1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
ConcurrentCacheSetNeverEvict-8      3.00 ± 0%      1.00 ± 0%   -66.67%  (p=0.000 n=10+10)

I'm willing to submit these changes (and some other improvements) if Ristretto is willing to add support to Type Parameters.

@paivagustavo paivagustavo added the kind/feature Something completely new we should consider. label Nov 28, 2022
@Yiling-J
Copy link

Or you can try my high hit ratio & good perofrmance generic cache package:
https://github.com/Yiling-J/theine-go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something completely new we should consider.
Projects
None yet
Development

No branches or pull requests

2 participants