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

chore: update jsoncons version to 0.178 #4368

Merged
merged 1 commit into from
Jan 8, 2025
Merged

chore: update jsoncons version to 0.178 #4368

merged 1 commit into from
Jan 8, 2025

Conversation

romange
Copy link
Collaborator

@romange romange commented Dec 25, 2024

jsoncons 0.178 has some pmr related fixes that should contribute to better stability in our codebase.

Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

LGTM

kostasrim
kostasrim previously approved these changes Jan 7, 2025
@@ -1280,6 +1280,7 @@ auto OpResp(const OpArgs& op_args, string_view key, const WrappedJsonPath& json_
OpResult<bool> OpSet(const OpArgs& op_args, string_view key, string_view path,
const WrappedJsonPath& json_path, std::string_view json_str,
bool is_nx_condition, bool is_xx_condition) {
JsonMemTracker mem_tracker;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is not really used below I would rather have it local to the scope of the if statement below but IMO it doesn't really matter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is used. mem_tracker tracks used memory and ShardJsonFromString allocates from it

Copy link
Contributor

@kostasrim kostasrim Jan 8, 2025

Choose a reason for hiding this comment

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

I mean, that mem_tracker is local to the branch below and it's only used there and not in other places within this function.

See line 1311 mem_tracker.SetJsonSize(st->it->second, st->is_new); and after it we return.

Pardon me, I wasn't very clear 😄

// is to use absl::Cleanup and dispatch another Find() but that's too complicated because then
// you need to take into account the order of destructors.
OpResult<DbSlice::AddOrFindResult> st = SetJson(op_args, key, parsed_json.value());
OpResult<DbSlice::AddOrFindResult> st = SetJson(op_args, key, std::move(*parsed_json));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine, because:

  1. We pass a lambda now parse_json. See changes introduced by Stefan in fb8234c#diff-0799c8810dbf8758f9da40162075f38bb51639f806be28a06d9f669a6ebb0f76R1288

(The only redundancy here is the move on the lambda since it has no capture -- but I know you like calling move() anyways so it's fine).

  1. Moving the JsonMemTracker above is also fine. We no longer parse the json in this function but rather inside the lambda so when we construct the tracker we have no extra calculated allocations and when we call mem_tracker.SetJsonSize(st->it->second, st->is_new); below we already destructed the temporaries created within SetJson() from the lambda parse_json so the tracking deltas shall be correct

kostasrim
kostasrim previously approved these changes Jan 8, 2025
@kostasrim
Copy link
Contributor

@romange

Check failed: jsoncons::is_trivial_storage(u_.json_obj.cons.json_ptr->storage_kind()) || u_.json_obj.cons.json_ptr->get_allocator().resource() == tl.local_mr 

@romange
Copy link
Collaborator Author

romange commented Jan 8, 2025

I removed the lambda

VLOG(1) << "got invalid JSON string '" << json_str << "' cannot be saved";
return OpStatus::SYNTAX_ERR;
}
return parsed_json.value();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this does not move, this copies.

Copy link
Contributor

@BagritsevichStepan BagritsevichStepan left a comment

Choose a reason for hiding this comment

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

I'd like to suggest running sanitizers on this branch

@romange
Copy link
Collaborator Author

romange commented Jan 8, 2025

@BagritsevichStepan
Copy link
Contributor

BagritsevichStepan commented Jan 8, 2025

Thanks, I think it can fix this issue #4391

Upd.: Still fails

Copy link
Contributor

@kostasrim kostasrim left a comment

Choose a reason for hiding this comment

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

lgtm

@romange romange merged commit f3426bd into main Jan 8, 2025
9 of 10 checks passed
@romange romange deleted the Pr1 branch January 8, 2025 18:05
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