Skip to content

feat: momento apis - set_if_absent, set_if_present_and_not_equal, item_get_type#372

Open
nidhidhamnani wants to merge 4 commits intoiopsystems:mainfrom
nidhidhamnani:momento_set_if_api
Open

feat: momento apis - set_if_absent, set_if_present_and_not_equal, item_get_type#372
nidhidhamnani wants to merge 4 commits intoiopsystems:mainfrom
nidhidhamnani:momento_set_if_api

Conversation

@nidhidhamnani
Copy link
Copy Markdown

@nidhidhamnani nidhidhamnani commented Mar 27, 2025

Adding momento's set_if_absent, set_if_present_and_not_equal, and item_get_type apis to be able to load test it

Testing

Both set_if_absent and set_if_present_and_not_equal fall under set_if api internally, hence 8K tps instead of 4K.

Screenshot 2025-03-28 at 2 19 29 PM

@nidhidhamnani nidhidhamnani changed the title feat: momento set_if_absent api feat: momento apis - set_if_absent, set_if_present_and_not_equal, item_get_type Mar 28, 2025
Comment thread src/config/workload.rs Outdated
Comment thread src/config/workload.rs Outdated
Comment thread src/metrics/mod.rs
Comment thread src/workload/client.rs
@nidhidhamnani nidhidhamnani requested a review from krispraws March 28, 2025 23:08
Copy link
Copy Markdown
Contributor

@krispraws krispraws left a comment

Choose a reason for hiding this comment

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

One question about old and new values for SetIfPresentAndNotEqual, and one minor nit about DRYing up the metrics for conditional writes.

Comment thread src/workload/mod.rs
key: keyspace.sample(rng),
value: keyspace.gen_value(sequence as _, rng),
new_value: keyspace.gen_value(sequence as _, rng),
old_value: keyspace.gen_value(sequence as _, rng),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you generate different values for old_value and new_value, the result will always be stored. Is that intentional?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There might not be a good alternative. We don't really have any place we're keeping history for each key to do some % of overwrite. Similar problem as testing something like a CAS operation. You might be able to fake something with two keyspaces? But the workload generation isn't really designed with this in mind.

If there's need in the future, what I'd consider is some mechanism for playing workload from a file and trying to make that flexible in terms of whether exact or random out of N values are used in each place. Then you could dial in some very specific patterns by generating that file or getting some prod trace and replaying it.

For now, maybe a comment acknowledging this behavior and that it's expected would be good?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sounds good

.await;

record_result!(result, SET_IF_ABSENT)
.await
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we could move some of this boilerplate code into record_result!. Especially for conditional write responses where we do not care about the actual value of the item in the response and just want to record metrics for stored vs not_stored. The macro already seems to have some logic based on 3 arguments being passed to it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you could, but it'd need enough other code to support inspecting arbitrary enums to check stored/not_stored (some sort of trait that's implemented for each conditional write response enum?) that I don't know if it'd save any real code.

record_result!() could maybe still be used here for the EX and TIMEOUT - it'd expect to increment something like SET_IF_ABSENT_OK - which should exist since the request! macro does some paste magic to generate _OK, _EX, and _TIMEOUT metrics for the same base request type. Then this could be a record_result!() and an

record_result!(...);

if let Ok(Ok(r)) = r { 
    match r { 
        /// enum variant handling 
    }
 }

Might be worth making that change

)
.await
{
Ok(Ok(r)) => match r {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here as with my comment above. record_result + if let might make this cleaner)

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.

3 participants