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

Native ETag Support #675

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

hamdaankhalid
Copy link
Contributor

@hamdaankhalid hamdaankhalid commented Sep 18, 2024

Native ETag Support

Garnet provides support for ETags on raw strings. You can associate any string-based key-value pair inserted into Garnet with an automatically updated ETag.
Compatibility with non-ETag commands and the behavior of data inserted with ETags are detailed in the markdown for garnet specific commands. Please read the markdown file for API contracts, and compatibility.

HLD:

RecordInfo for a record indicated whether or not a record contains an ETag. This bit on the record info is used to indicate that the first 8 bytes of the payload of the record include a long data type that represents the eTag associated with the value that is present after the first 8 bytes.

Reads don't modify the eTag, but any RMW operations do. Blind Upsert (SET) will remove the eTag unless sent with the RETAINETAG flag.

ETags are incremented on each update, and the user can use them to handle things such as caching and Optimistic concurrency control.

@hamdaankhalid hamdaankhalid force-pushed the hkhalid/etag-impl branch 4 times, most recently from 77487f1 to d564238 Compare September 25, 2024 07:39
@hamdaankhalid hamdaankhalid marked this pull request as ready for review September 26, 2024 00:35
@yrajas yrajas requested a review from TedHartMS September 26, 2024 18:28
Copy link
Contributor

@TedHartMS TedHartMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not finished with review yet but sending a few comments now

libs/common/RespReadUtils.cs Outdated Show resolved Hide resolved
libs/server/Resp/BasicCommands.cs Show resolved Hide resolved
libs/server/Resp/BasicCommands.cs Outdated Show resolved Hide resolved
@hamdaankhalid
Copy link
Contributor Author

hamdaankhalid commented Dec 17, 2024

BDN Benchmark


My Branch:

BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2605)
11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK 8.0.404
[Host] : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
.NET 8 : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

Job=.NET 8 EnvironmentVariables=DOTNET_TieredPGO=0 Runtime=.NET 8.0
Server=True

Method Params Mean Error StdDev Median Allocated
Set ACL 12.771 μs 0.2463 μs 0.3610 μs 12.818 μs -
SetEx ACL 17.118 μs 0.3363 μs 0.2981 μs 17.004 μs -
SetNx ACL 16.405 μs 0.3277 μs 0.4375 μs 16.344 μs -
SetXx ACL 17.048 μs 0.3363 μs 0.3737 μs 16.956 μs -
GetFound ACL 11.828 μs 0.2078 μs 0.3046 μs 11.723 μs -
GetNotFound ACL 7.912 μs 0.1527 μs 0.2090 μs 7.845 μs -
Increment ACL 21.251 μs 0.4103 μs 0.5189 μs 21.269 μs -
Decrement ACL 19.766 μs 0.2592 μs 0.2164 μs 19.833 μs -
IncrementBy ACL 24.148 μs 0.3647 μs 0.3412 μs 24.207 μs -
DecrementBy ACL 24.927 μs 0.4746 μs 0.5828 μs 24.911 μs -
Set AOF 17.906 μs 0.3573 μs 0.3168 μs 17.879 μs -
SetEx AOF 22.909 μs 0.4445 μs 0.6231 μs 22.849 μs -
SetNx AOF 22.423 μs 0.3564 μs 0.3333 μs 22.553 μs -
SetXx AOF 23.534 μs 0.3453 μs 0.3061 μs 23.467 μs -
GetFound AOF 12.305 μs 0.2387 μs 0.2344 μs 12.340 μs -
GetNotFound AOF 8.207 μs 0.1632 μs 0.2288 μs 8.165 μs -
Increment AOF 25.539 μs 0.5108 μs 0.9718 μs 25.361 μs -
Decrement AOF 26.609 μs 0.5270 μs 1.2214 μs 26.361 μs -
IncrementBy AOF 31.919 μs 0.6351 μs 1.2387 μs 31.642 μs -
DecrementBy AOF 31.978 μs 0.6143 μs 1.4479 μs 31.679 μs -
Set None 12.811 μs 0.2660 μs 0.7631 μs 12.502 μs -
SetEx None 17.352 μs 0.2739 μs 0.2428 μs 17.365 μs -
SetNx None 16.492 μs 0.2216 μs 0.1850 μs 16.500 μs -
SetXx None 17.265 μs 0.2120 μs 0.1983 μs 17.275 μs -
GetFound None 12.055 μs 0.2364 μs 0.2814 μs 12.169 μs -
GetNotFound None 8.140 μs 0.1539 μs 0.1773 μs 8.057 μs -
Increment None 21.646 μs 0.4279 μs 0.6405 μs 21.641 μs -
Decrement None 20.855 μs 0.3618 μs 0.3716 μs 21.011 μs -
IncrementBy None 24.285 μs 0.3506 μs 0.3279 μs 24.159 μs -
DecrementBy None 24.758 μs 0.3743 μs 0.3501 μs 24.879 μs -

Commit: 635cd58 of main branch

BenchmarkDotNet v0.14.0, Windows 11 (10.0.22631.4602/23H2/2023Update/SunValley3)
11th Gen Intel Core i7-1185G7 3.00GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK 8.0.404
[Host] : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
.NET 8 : .NET 8.0.11 (8.0.1124.51707), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

Job=.NET 8 EnvironmentVariables=DOTNET_TieredPGO=0 Runtime=.NET 8.0
Server=True

Method Params Mean Error StdDev Allocated
Set ACL 11.276 us 0.1586 us 0.1406 us -
SetEx ACL 15.780 us 0.1784 us 0.1582 us -
SetNx ACL 14.703 us 0.1184 us 0.0989 us -
SetXx ACL 15.647 us 0.1717 us 0.1522 us -
GetFound ACL 10.823 us 0.1988 us 0.1859 us -
GetNotFound ACL 7.523 us 0.1216 us 0.1078 us -
Increment ACL 18.174 us 0.2018 us 0.1888 us -
Decrement ACL 17.774 us 0.1349 us 0.1195 us -
IncrementBy ACL 23.203 us 0.2031 us 0.1900 us -
DecrementBy ACL 21.799 us 0.3914 us 0.3661 us -
Set AOF 15.909 us 0.2025 us 0.1894 us -
SetEx AOF 20.320 us 0.2052 us 0.1714 us -
SetNx AOF 20.636 us 0.3904 us 0.3260 us -
SetXx AOF 26.672 us 1.2831 us 3.6398 us -
GetFound AOF 15.404 us 0.2987 us 0.6234 us -
GetNotFound AOF 10.314 us 0.2044 us 0.3685 us -
Increment AOF 30.120 us 0.4504 us 0.7273 us -
Decrement AOF 29.597 us 0.5715 us 0.6803 us -
IncrementBy AOF 35.447 us 0.7080 us 0.7869 us -
DecrementBy AOF 36.219 us 0.6909 us 0.5394 us -
Set None 16.062 us 0.3177 us 0.6907 us -
SetEx None 21.791 us 0.4335 us 1.0132 us -
SetNx None 19.906 us 0.3903 us 0.8061 us -
SetXx None 20.788 us 0.3932 us 0.3678 us -
GetFound None 14.644 us 0.1330 us 0.1633 us -
GetNotFound None 10.337 us 0.2034 us 0.1699 us -
Increment None 25.026 us 0.4128 us 0.5786 us -
Decrement None 23.746 us 0.4415 us 0.4534 us -
IncrementBy None 29.509 us 0.5801 us 0.4529 us -
DecrementBy None 30.158 us 0.5956 us 0.7090 us -

@hamdaankhalid hamdaankhalid changed the title Etag Implementation Native ETag Support Dec 17, 2024
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.

4 participants