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 CI toolchain and clean up code #244

Merged
merged 10 commits into from
Aug 3, 2022

Conversation

tabokie
Copy link
Member

@tabokie tabokie commented Jul 15, 2022

Ref #235

Update toolchain to 2022-07-13, add a makefile.

A lot of minor refactoring:

  • Refactor scan_messages interface to share more code paths, and add tests for them.
  • Hide LogFileFormat from outer crate, it should stay an implementation detail of file_pipe_log.
  • Change DataLayout to u64, because otherwise it needs additional care to make sure Alignment(0) and NoAlignment don't coexist.
  • Remove some tests that aren't very useful.

Signed-off-by: tabokie [email protected]

@tabokie tabokie changed the title chore: update CI toolchain and clean up code chore: update CI toolchain and reseek after write failure Jul 15, 2022
Signed-off-by: tabokie <[email protected]>
@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #244 (f28f309) into master (c3a6156) will increase coverage by 0.44%.
The diff coverage is 99.22%.

@@            Coverage Diff             @@
##           master     #244      +/-   ##
==========================================
+ Coverage   97.24%   97.68%   +0.44%     
==========================================
  Files          30       30              
  Lines       10951    10715     -236     
==========================================
- Hits        10649    10467     -182     
+ Misses        302      248      -54     
Impacted Files Coverage Δ
src/env/mod.rs 100.00% <ø> (ø)
src/lib.rs 100.00% <ø> (ø)
src/swappy_allocator.rs 99.23% <0.00%> (ø)
src/engine.rs 97.90% <98.23%> (+0.99%) ⬆️
src/file_pipe_log/pipe.rs 99.24% <98.93%> (+0.08%) ⬆️
src/config.rs 97.50% <100.00%> (ø)
src/file_pipe_log/format.rs 99.51% <100.00%> (+0.58%) ⬆️
src/file_pipe_log/log_file.rs 100.00% <100.00%> (+0.43%) ⬆️
src/file_pipe_log/mod.rs 98.46% <100.00%> (+0.88%) ⬆️
src/file_pipe_log/pipe_builder.rs 96.20% <100.00%> (-0.04%) ⬇️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3a6156...f28f309. Read the comment docs.

@tabokie tabokie changed the title chore: update CI toolchain and reseek after write failure chore: update CI toolchain and clean up code Jul 15, 2022
Signed-off-by: tabokie <[email protected]>
Signed-off-by: tabokie <[email protected]>
@tabokie
Copy link
Member Author

tabokie commented Aug 3, 2022

/cc @LykxSassinator

@tabokie tabokie force-pushed the cleanup-220715 branch 2 times, most recently from 240d7bc to b873cce Compare August 3, 2022 08:16
Signed-off-by: tabokie <[email protected]>
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@tabokie tabokie merged commit 6a6fe3b into tikv:master Aug 3, 2022
Copy link
Contributor

@LykxSassinator LykxSassinator left a comment

Choose a reason for hiding this comment

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

Rest LGTM

## Run tests.
ifeq ($(WITH_STABLE_TOOLCHAIN), true)
test:
cargo test --all --features all_stable_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommend to add extra --color always, making the results both on successful and failed tests more readable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you encounter any problem using it? I think the default auto should work good enough.

Copy link
Contributor

@LykxSassinator LykxSassinator Aug 3, 2022

Choose a reason for hiding this comment

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

Actually,it's work fine in my environment, also on MacOS.

cargo test --test failpoints --features all_stable ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
else
test:
cargo test --all --features all_except_failpoints ${EXTRA_CARGO_ARGS} -- --nocapture
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

src/file_pipe_log/format.rs Show resolved Hide resolved
) -> Result<()> {
self.valid_offset = LogFileFormat::encode_len(format.version);
self.file_id = Some(file_id);
self.format = Some(format);
Copy link
Contributor

Choose a reason for hiding this comment

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

How about still using LogFileContext to represent the basics of file metadata ?

Copy link
Member Author

@tabokie tabokie Aug 3, 2022

Choose a reason for hiding this comment

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

Similar to my other comment, because the context no longer holds alignment, using it doesn't make sense here.

}
}

#[derive(Debug, Clone)]
pub struct LogFileContext {
pub id: FileId,
pub format: LogFileFormat,
pub version: Version,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not introduce LogFileFormat as an integrated representation of file metadata? Version is just a slice of metadata in the log, but LogFileFormat owns the whole.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hide LogFileFormat from outer crate, it should stay an implementation detail of file_pipe_log.

There's no need to expose it because only "file_pipe_log" needs to know about alignment.

handle,
reader,
// Set to an invalid offset to force a reseek at first read.
offset: u64::MAX,
Copy link
Contributor

Choose a reason for hiding this comment

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

I've got the purpose that u refactor the LogFileReader and its related method build_file_reader. But referring to the design on LogFileWriter, I still recommend to make the parse_format integrated into the processing of LogFileReader::open(), rather than open() -> manually parse_format by callers.

Copy link
Member Author

Choose a reason for hiding this comment

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

My change removes the format stored inside reader, because reader doesn't need a format to function. The writer, on the other hand, needs to do format-specific initialization, so we can't refactor it like reader.

cargo clippy --all --features all_stable --all-targets -- -D clippy::all
else
clippy:
cargo clippy --all --all-features --all-targets -- -D clippy::all
Copy link
Contributor

@LykxSassinator LykxSassinator Aug 3, 2022

Choose a reason for hiding this comment

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

Here, don't we need +nightly trait any more when ${WITH_STABLE_TOOLCHAIN} == false ?

I've tested the makefile on Centos:
Linux version 3.10.0-862.14.4.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Wed Sep 26 15:12:11 UTC 2018

And it returns the following failure:

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> src/lib.rs:16:34
   |
16 | #![cfg_attr(feature = "nightly", feature(test))]
   |                                  ^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> src/lib.rs:17:31

And if I add the +nightly trait, both make test and make clippy worked as expectation without errs, by setting ${WITH_STABLE_TOOLCHAIN} == false .
Also, the feature specification on all_except_failpoints in cargo.toml shows that we need +nightly.

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 idea is to assume user has set the correct default toolchain. But force setting sounds okay too, I'll add it later.

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