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

libroach: further decomposition of db.cc #21636

Merged
merged 3 commits into from
Jan 23, 2018

Conversation

petermattis
Copy link
Collaborator

Split the various engine implementations out of db.cc. Move the merge
operator routines into merge.cc. Move the MVCC* routines into
mvcc.cc. Move the custom RocksDB comparator to comparator.cc.

This is all code movement: no functional changes.

Release note: None

@petermattis petermattis requested review from a team January 22, 2018 02:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@petermattis petermattis requested a review from tbg January 22, 2018 02:48
@petermattis petermattis force-pushed the pmattis/libroach-engines branch 4 times, most recently from 51d88bd to 124136e Compare January 22, 2018 03:02
@petermattis
Copy link
Collaborator Author

I think this gets us to a reasonable place.

@petermattis
Copy link
Collaborator Author

Added a few others as reviewers who might have opinions about the organization of code in libroach.

@petermattis
Copy link
Collaborator Author

Review status: 0 of 26 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


c-deps/libroach/ccl/db.cc, line 18 at r2 (raw file):

#include <rocksdb/write_batch.h>
#include "../batch.h"
#include "../comparator.h"

@benesch Do you know how to avoid these relative includes? Seems like there should be some cmake configuration.


Comments from Reviewable

@mberhault
Copy link
Contributor

I'm overall happy with this kind of re-org, just really not while #21580 is pending, this will be a nasty merge.


Review status: 0 of 26 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


c-deps/libroach/ccl/db.cc, line 18 at r2 (raw file):

Previously, petermattis (Peter Mattis) wrote…

@benesch Do you know how to avoid these relative includes? Seems like there should be some cmake configuration.

Things used in common by ./ and ccl/ should ideally be in sub-directories that are added to the include list. Easy enough for things like ../fmt.h, not so much for the ones listed here. The dirty way would be to include ./ as well.


Comments from Reviewable

@petermattis
Copy link
Collaborator Author

I'm overall happy with this kind of re-org, just really not while #21580 is pending, this will be a nasty merge.

I'll hold off on merging until #21580 goes in.


Review status: 0 of 26 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


Comments from Reviewable

@tbg
Copy link
Member

tbg commented Jan 22, 2018

:lgtm:


Reviewed 24 of 24 files at r1, 2 of 2 files at r2.
Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


c-deps/libroach/batch.cc, line 33 at r1 (raw file):

// pointing to "key" if no updates existing for that key in the batch.
//
// Note that RocksDB WriteBatches append updates

nit: weird flow


c-deps/libroach/mvcc.cc, line 80 at r1 (raw file):

  std::string prev_key;
  bool first = false;
  // NB: making this uninitialized triggers compiler warnings

This is random, but you didn't have any opinions on this, did you? This would be the first time any compiler was wrong about any warning issued to me.


Comments from Reviewable

@mberhault
Copy link
Contributor

Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


c-deps/libroach/ccl/db.cc, line 18 at r2 (raw file):

Previously, mberhault (marc) wrote…

Things used in common by ./ and ccl/ should ideally be in sub-directories that are added to the include list. Easy enough for things like ../fmt.h, not so much for the ones listed here. The dirty way would be to include ./ as well.

After checking, rocksdb does include its own PROJECT_SOURCE_DIR so that their includes look like util/blahblah.h. This seems reasonable to do for us as well. Moving things into separate subdirs can be done at a later date.


Comments from Reviewable

@bdarnell
Copy link
Contributor

:lgtm:

I think this may have gone a little too far towards lots of small files, but i don't have an alternative arrangement to offer.


Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


Comments from Reviewable

Split the various engine implementations out of `db.cc`. Move the merge
operator routines into `merge.cc`. Move the `MVCC*` routines into
`mvcc.cc`. Move the custom RocksDB comparator to `comparator.cc`. Move
the cache routines into `cache.cc`. Move the options routines into
`options.cc`.

This is all code movement: no functional changes.

Release note: None
Add an inclusion guard and place the constants in the cockroach
namespace.

Release note: None
@petermattis petermattis force-pushed the pmattis/libroach-engines branch from 1f213b2 to c4132e2 Compare January 22, 2018 15:38
@petermattis
Copy link
Collaborator Author

Review status: 23 of 26 files reviewed at latest revision, 3 unresolved discussions.


c-deps/libroach/batch.cc, line 33 at r1 (raw file):

Previously, tschottdorf (Tobias Schottdorf) wrote…

nit: weird flow

Fixed.


c-deps/libroach/mvcc.cc, line 80 at r1 (raw file):

Previously, tschottdorf (Tobias Schottdorf) wrote…

This is random, but you didn't have any opinions on this, did you? This would be the first time any compiler was wrong about any warning issued to me.

Seems reasonable to me that the compiler can't figure out that accrue_gc_age_nanos is being initialized before use. The compiler is doing some data flow analysis and you're running into the limits. This is fairly typical for C++ compiler warnings in my experience. We don't see this in Go because all variables are default 0 initialized.


Comments from Reviewable

@benesch
Copy link
Contributor

benesch commented Jan 22, 2018

Reviewed 23 of 24 files at r1, 3 of 3 files at r3, 1 of 2 files at r4.
Review status: 25 of 26 files reviewed at latest revision, 4 unresolved discussions, some commit checks pending.


c-deps/libroach/options.h, line 29 at r3 (raw file):

// local variables:
// mode: c++
// end:

Stray editor-specific config.


c-deps/libroach/ccl/db.cc, line 18 at r2 (raw file):

Previously, mberhault (marc) wrote…

After checking, rocksdb does include its own PROJECT_SOURCE_DIR so that their includes look like util/blahblah.h. This seems reasonable to do for us as well. Moving things into separate subdirs can be done at a later date.

I'd hesitate to use RocksDB's build system as an example of what to do in general, but agreed, sticking PRIVATE . into libroachccl's target_include_directories seems reasonable.

(The relative imports don't bother me though.)


Comments from Reviewable

@petermattis
Copy link
Collaborator Author

Per in-person discussion with @mberhault, I'm going to merge this and will help with any conflicts that arise with his PR.

@petermattis
Copy link
Collaborator Author

Review status: 15 of 30 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful.


c-deps/libroach/options.h, line 29 at r3 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

Stray editor-specific config.

Ack. I've removed all of these.


Comments from Reviewable

@petermattis petermattis merged commit c4bd367 into cockroachdb:master Jan 23, 2018
@petermattis petermattis deleted the pmattis/libroach-engines branch January 23, 2018 17:32
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.

6 participants