Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Remove Object Copy Cache #124

Merged
merged 6 commits into from
Mar 23, 2023
Merged

Conversation

irq0
Copy link
Member

@irq0 irq0 commented Mar 1, 2023

Removes the object copy cache to reduce mutexes in the hot path and to enable us to replace linear time object list filters with (indexed) SQL queries.

Split into two parts: 1. Refactoring to encapsulate Object and access to the objects cache better. 2. Remove the cache.

No new tests. Changes already covered by existing tests.

Issue https://github.com/aquarist-labs/s3gw/issues/214
Prepares code base for aquarist-labs/s3gw-tools#203

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

@irq0 irq0 force-pushed the pr/remove-types-objects branch 2 times, most recently from 143d1fc to c941dea Compare March 2, 2023 12:35
@irq0 irq0 self-assigned this Mar 2, 2023
@irq0 irq0 added this to the v0.13.0 milestone Mar 2, 2023
@irq0 irq0 mentioned this pull request Mar 2, 2023
11 tasks
@irq0 irq0 force-pushed the pr/remove-types-objects branch from c941dea to 79c6645 Compare March 2, 2023 15:29
@irq0 irq0 marked this pull request as ready for review March 2, 2023 18:36
@irq0 irq0 requested review from 0xavi0, jecluis and giubacc and removed request for 0xavi0 and jecluis March 2, 2023 18:37
@giubacc
Copy link

giubacc commented Mar 3, 2023

Extremely good work.
I think this is a fundamental refactoring improving greatly code-quality/performances.
I will give a deeper look next week.

@giubacc
Copy link

giubacc commented Mar 6, 2023

@irq0
It seems reasonably all good; I would like this PR to include the tests from legal holds PR because that contains a specific patch to certain methods modified in this refactoring.
Do you you think it feasible to merge that before this ? But you will have to rebase.

Copy link
Member

@jecluis jecluis left a comment

Choose a reason for hiding this comment

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

generally looks good, but there are a few things that caught my attention. I'll need to do a second pass tomorrow, after reading some code, because I have the nagging feeling we may succumb to races.

src/rgw/driver/sfs/types.cc Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.cc Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.cc Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.cc Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.h Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.h Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.cc Outdated Show resolved Hide resolved
src/rgw/driver/sfs/types.cc Outdated Show resolved Hide resolved
@@ -258,52 +323,75 @@ void MultipartUpload::abort(const DoutPrefixProvider *dpp) {
objref.reset();
}

bool Bucket::want_new_version(const rgw_obj_key& key, ObjectRef obj) {
return !(key.instance.empty() || key.instance == obj->instance);
bool Bucket::want_specific_version(const rgw_obj_key& key) {
Copy link
Member

Choose a reason for hiding this comment

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

the comment on the previous commit goes for this one, I would rather have s/want/wants/.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 agreed. Replacing with local variable as well, the method doesn't make much sense outside get_or_create

src/rgw/driver/sfs/types.cc Show resolved Hide resolved
0xavi0
0xavi0 previously requested changes Mar 13, 2023
Copy link

@0xavi0 0xavi0 left a comment

Choose a reason for hiding this comment

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

Looks generally okay to me but I think I'd need another round of review.
The only thing I that I would request to be changed so far is calling std::move on raw pointers.
The "constructor helpers" thingy is more a personal taste thing.


Object* Object::create_for_multipart(const std::string& name) {
Object* result = new Object(name, UUIDPath::create().get_uuid());
return result;
Copy link

Choose a reason for hiding this comment

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

Are all these really needed?

I see them as constructor helpers.

create_for_testing and create_for_multipart are the same. (at least for now, it they diverge at some point happy to have 2 different methods)

What about a single create_from_name? (or even a constructor with a single parameter which is the name)

And the create_for_immediate_deletion seems a bit weird to me.
If the object is immediately deleted I guess we don't need to set the deleted attribute to false.
I've tested this already removing the result->deleted = true; statement and as expected the GC tests pass.

I think calling the already existing Object(const std::string& _name, const uuid_d& _uuid) would be enough and we can save having that method around. (less code to be maintained)

I dunno, maybe it is a personal thing... but... to me...
create_from_obj_key would be just:

Object(const rgw_obj_key & key)

The one with only the name would be:

Object(const std::string& name)

and I would maybe just keep the helper for the query thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

The named constructors try to make the more clear what Object is created for. We sometimes use it to retrieve data, sometimes update data, sometimes create a new object. I'd like to remove some of the use cases from Object over time. The named constructors are a first step in that direction. They do feel like overkill right now, but will make it easier to remove dependencies from Object IMHO.

Comment on lines 505 to 506
objref.reset(std::move(sfs::Object::create_for_query(get_name(), uuid, deleted,
db_version->id)));
Copy link

Choose a reason for hiding this comment

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

All the create_for_* functions return a raw pointer.
Why calling std::move on a raw pointer? I think it adds confusion to the reader.
It would make sense if create_for_* functions were retuning a std::unique_ptr...

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch. will remove

@github-actions github-actions bot added the needs-rebase Changes need a rebase label Mar 21, 2023
@github-actions
Copy link

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Marcel Lauhoff added 2 commits March 21, 2023 14:56
Improve Object and Bucket encapsulation to make it easy to remove the
objects cache and mutex.

Add specific named constructors (create_..) to Object that replace
construction + metadata_init calls.

Make Object create methods return pointers to allow callers to decided
how to handle ownership. Without the object cache, we no longer need
shared pointers of Object at all places.

Separate Object data / metadata deletion (delete_object_data,
delete_object_metadata)

Add get, set, update methods for Object attrs and meta. Make both
private fields.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
Remove objects cache. Replace with direct Object creation from our
SQLite database. This changes semantics of Objects retrieved from
Bucket::get_or_create. Previously they pointed to the _same_
in-memory, database object representation. Now, subsequent calls
return different Objects created fresh from the database each time.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
@irq0 irq0 force-pushed the pr/remove-types-objects branch from 089ff0b to e14e9c4 Compare March 21, 2023 14:00
@irq0 irq0 changed the base branch from s3gw-2023-03-old to s3gw March 21, 2023 16:09
@irq0 irq0 removed the needs-rebase Changes need a rebase label Mar 21, 2023
@irq0 irq0 marked this pull request as draft March 21, 2023 16:22
@irq0 irq0 marked this pull request as ready for review March 21, 2023 16:22
@irq0 irq0 force-pushed the pr/remove-types-objects branch from e14e9c4 to eef95bb Compare March 21, 2023 16:32
Marcel Lauhoff added 4 commits March 21, 2023 17:40
Use docstrings, add issue reference.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
Move the 'from' before 'database' for better readability.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
Replace method with const bool wants_specific_version.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
@irq0 irq0 force-pushed the pr/remove-types-objects branch from eef95bb to 162e12d Compare March 21, 2023 16:41
@irq0 irq0 modified the milestones: v0.13.0, v0.14.0 Mar 21, 2023
@irq0 irq0 removed the dashboard label Mar 21, 2023
@irq0 irq0 requested review from jecluis and 0xavi0 March 22, 2023 09:25
@irq0
Copy link
Member Author

irq0 commented Mar 22, 2023

pr-triage failure: https://github.com/aquarist-labs/s3gw/issues/404

@irq0 irq0 mentioned this pull request Mar 22, 2023
11 tasks
@0xavi0
Copy link

0xavi0 commented Mar 23, 2023

We could, maybe, use this PR to remove (or adapt if we think it is useful for us) that pr-triage GH job...
Changes look good to me, but I guess we should address that CI issue first

@jecluis
Copy link
Member

jecluis commented Mar 23, 2023

We could, maybe, use this PR to remove (or adapt if we think it is useful for us) that pr-triage GH job... Changes look good to me, but I guess we should address that CI issue first

that should be a different PR I think. This one can be merged ignoring that check. But I agree that should be fixed before merging this one.

@irq0
Copy link
Member Author

irq0 commented Mar 23, 2023

local test run rebased on #122 successful

@irq0 irq0 merged commit 256ad80 into aquarist-labs:s3gw Mar 23, 2023
@irq0 irq0 deleted the pr/remove-types-objects branch March 23, 2023 08:40
@jecluis
Copy link
Member

jecluis commented Mar 23, 2023

note for the future: failed check has been dropped from this repository, but I was unable to find a way to rerun the workflows while dropping that specific check 🤷

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants