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 42 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 Show resolved Hide resolved
@hamdaankhalid
Copy link
Contributor Author

hamdaankhalid commented Dec 17, 2024

BDN Benchmark

Commit: 4e327b4 of my 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 Median Allocated
Set ACL 13.102 μs 0.4563 μs 1.3165 μs 12.776 μs -
SetEx ACL 17.341 μs 0.5056 μs 1.4094 μs 16.800 μs -
SetNx ACL 15.394 μs 0.3004 μs 0.3689 μs 15.381 μs -
SetXx ACL 16.160 μs 0.2877 μs 0.2402 μs 16.139 μs -
GetFound ACL 12.472 μs 0.5838 μs 1.6371 μs 12.037 μs -
GetNotFound ACL 7.989 μs 0.1579 μs 0.2966 μs 7.954 μs -
Increment ACL 18.597 μs 0.3277 μs 0.3065 μs 18.587 μs -
Decrement ACL 18.344 μs 0.3614 μs 0.3867 μs 18.358 μs -
IncrementBy ACL 23.720 μs 0.4204 μs 0.3933 μs 23.652 μs -
DecrementBy ACL 23.773 μs 0.4573 μs 1.0779 μs 23.483 μs -
Set AOF 16.430 μs 0.3162 μs 0.6015 μs 16.355 μs -
SetEx AOF 21.385 μs 0.2904 μs 0.2575 μs 21.334 μs -
SetNx AOF 20.749 μs 0.3717 μs 0.3295 μs 20.597 μs -
SetXx AOF 21.634 μs 0.3568 μs 0.3163 μs 21.618 μs -
GetFound AOF 11.011 μs 0.1476 μs 0.1757 μs 11.000 μs -
GetNotFound AOF 7.725 μs 0.1019 μs 0.0903 μs 7.735 μs -
Increment AOF 23.524 μs 0.4212 μs 0.3734 μs 23.641 μs -
Decrement AOF 23.032 μs 0.3912 μs 0.3267 μs 23.039 μs -
IncrementBy AOF 28.487 μs 0.3811 μs 0.3379 μs 28.507 μs -
DecrementBy AOF 29.484 μs 0.4923 μs 0.8225 μs 29.358 μs -
Set None 11.608 μs 0.2198 μs 0.1948 μs 11.586 μs -
SetEx None 16.549 μs 0.3266 μs 0.3495 μs 16.528 μs -
SetNx None 15.839 μs 0.2813 μs 0.3851 μs 15.867 μs -
SetXx None 16.661 μs 0.3124 μs 0.2922 μs 16.608 μs -
GetFound None 11.618 μs 0.2289 μs 0.4976 μs 11.512 μs -
GetNotFound None 8.731 μs 0.1669 μs 0.1786 μs 8.720 μs -
Increment None 19.210 μs 0.2462 μs 0.2303 μs 19.221 μs -
Decrement None 19.306 μs 0.2564 μs 0.2398 μs 19.368 μs -
IncrementBy None 22.566 μs 0.3320 μs 0.2772 μs 22.464 μs -
DecrementBy None 23.824 μs 0.4657 μs 0.4129 μs 23.924 μ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