-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
More rust training content #7
Conversation
cc @nrc happy to hear any suggestions. |
I've pushed another commit that completes the text for project 1. |
rust/CONTRIBUTING.md
Outdated
solutions - students should learn where to get the answers from the | ||
pre-requisites and lessons. | ||
|
||
Proect text may include inline links to pages that offer explanatios of terms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
Proect text may include inline links to pages that offer explanatios of terms | |
Project text may include inline links to pages that offer explanations of terms |
@@ -0,0 +1,89 @@ | |||
TODO organize this | |||
|
|||
Every md file has a html relative symlink to index.html: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to explain the reason? I first felt confused until I find out we are loading the md dynamically according to the url.
rust/CONTRIBUTING.md
Outdated
|
||
## Contributor notes | ||
|
||
- each md file needs a relative symlink to index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more clarified, let's use an html relative symlink
same as the beginning.
rust/CONTRIBUTING.md
Outdated
|
||
> _Use [crates.io](https://crates.io) to find the documentation | ||
for the `clap` crate, and implement the command line interface | ||
such that the `cli_*` test cases pass._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the rendered page, the _
in the inline code interrupts the em
block. It's actually a bug of marked. Should we use html tag as a workaround or wait for them fixing it?
rust/projects/tools/project.md
Outdated
|
||
_Use [crates.io](https://crates.io) to find the documentation | ||
for the `clap` crate, and implement the command line interface | ||
such that the `cli_*` test cases pass._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same.
|
||
- Lesson: Build-time Rust | ||
- Use hyper for synchronous networking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my knowledge, as HTTP servers, the latest hyper and iron are all asynchronous and run over the tokio runtime. Maybe we can consider use http
crate to build a synchronous HTTP server ourselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault. Only at the master branch iron uses hyper 0.12 but the released 0.6.0 version uses the synchronous hyper 0.10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, how will we make it single threaded first and change it to multi-threaded in the next project? By using hyper 0.10 or iron, that's simply to set the thread num of the pool to 1 first and then make it larger. This does not make much sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression hyper still offered a synchronous API, but it does not seem to.
Building a synchronous HTTP server could be interesting, requiring direct use of the std networking APIs. It's also demystifying, shows that HTTP is approachable. It's not all that practical, since most people should not implement HTTP themselves.
Another solution would be to use gRPC instead of HTTP.
I'm going to leave this an open question.
rust/projects/tools/project.md
Outdated
through the project, otherwise you will be distracted by the many failing tests | ||
that you are not currently working on fixing. | ||
that you have not yet fixed. | ||
|
||
**Question D**: even if a given test suite doesn't contain any tests, why |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**Question D**: even if a given test suite doesn't contain any tests, why | |
**Question D**: Even if a given test suite doesn't contain any tests, why |
rust/projects/tools/project.md
Outdated
|
||
Again, the interface for the CLI is: | ||
|
||
- `kvs set [KEY] [VALUE]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think KEY and VALUE are all required arguments. Is it better to change the square brackets to angle brackets <>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch.
rust/projects/tools/project.md
Outdated
|
||
Set the value of a string key to a string | ||
|
||
- `kvs get [KEY]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
rust/.gitignore
Outdated
@@ -1,2 +1,2 @@ | |||
*~ | |||
yarn-error.log | |||
target/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No newline at eof
target/ | |
target/ | |
|
||
Print the version | ||
|
||
The `kvs` library contains a type, `KvStore`, that supports the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior is not clearly specified, for example, the behavior of getting the value of a non-existing key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change the return value of get
to be Option<String>
.
rust/projects/tools/project.md
Outdated
through the project, otherwise you will be distracted by the many failing tests | ||
that you are not currently working on fixing. | ||
that you have not yet fixed. | ||
|
||
**Question D**: even if a given test suite doesn't contain any tests, why | ||
might we not want them to run? Besides issuing the above command, how could |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean "why might we want to to run?" here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean "not", but I can see how the sentence suggests the opposite. I'll change it to just "Why might we not want to run empty test suites". The only answer I'm thinking of has to do with compile times. This question may be too obscure to keep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still feel the question a bit confusing. Can we add something to lead readers to thinking about the compile time? For example, add "It takes no time to run an empty test.` to the beginning?
- Asyncronous programming with [futures] and [tokio] | ||
- High-performance networking with [GRPC] and [prost] | ||
- Asyncronous programming with [futures] | ||
- Networking with [hyper] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyper focuses on the HTTP protocol. I wonder what kind of service this subject will accomplish? (Plain HTTP 1.0 APIs or HTTP2 steaming APIs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't planning to do anything HTTP2 specific, though I assume hyper will negotiate a HTTP2 upgrade if it can. Do you have any suggestions?
I'm torn about using HTTP for this, since gRPC is what PingCAP uses. But @siddontang and I discussed that it may be too much to require gRPC for this project. If we don't do gRPC in the initial set of projects, I'm thinking it could be in a subsequent project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think teaching 'networking with Hyper' is not a good idea since we don't use it at pingCAP (afaik) and it is not an essential library and the domain is still in flux. I think it is OK to use Hyper, just emphasize that we're teaching networking in Rust rather than any particular library (could even just use TCP?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -37,6 +37,9 @@ in the README. | |||
- Ana likes this | |||
- variable shadowing | |||
- DSTs | |||
- configuring clippy / rustfmt | |||
- scripting clippy / rustfmt for CI | |||
- CI setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, it is very important for open-source projects, I just fixed a bug today during setting up CI. But which one do we want to target? Maybe we can make a list of CI doc link, let students choose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offhand I'd prefer to be opinionated and pick either travis or circle, whichever has the most open source mindshare (or maybe whichever pingcap uses). That way we can be specific about requirements, and have a better chance at automatically verifying they set up CI correctly.
It's not a strong opinion though.
It's also a chance to talk about the README and other boilerplate files, the various badges and other services Rust projects typically use.
@@ -0,0 +1,8 @@ | |||
#[test] | |||
fn cli_no_args() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be filled with a test case? So students can focus on implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fill the tests.
rust/projects/tools/src/lib.rs
Outdated
@@ -0,0 +1,3 @@ | |||
pub fn main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main
function name is confusing. It is the same name as binary entry points, but in this case, it is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good feedback. I'll change it to run
, but let me know if you've got a better name. Or better ideas about how to test the cli (I'd rather stay within cargo test
than explain how some custom scripts work).
Thanks so much for the reviews @sticnarf, @06kellyjac, @overvenus ! I've pushed a commit that addresses all of the feedback except for the problem that there's no synchronous hyper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor comments inline. Bigger picture, I think the questions would make good exam questions, but are perhaps not so good as exercises in lessons since there is usually just one right answer, and finding that answer probably won't help the student learn too much. For example,
Notice that there are four different set of tests running
(each could be called a "test suite"). Where do each of those test suites come
from?
This is a good check of knowledge, but the if the student is just googling this, then it feels a bit like trivia, and doesn't help them remember the knowledge. If you wanted to have a question like this, I think it would be better to direct them to ways to solve it, e.g., instead of asking "Where do each of those test suites come from?", ask "Can you write a test which is part of each of the four test suites?", then give a hint such as listing the four kind of tests with names which can be googled to lead to good descriptions.
My other big picture thing is that I worry about the overall goals of the course and how focussed it should be: is this an intermediate course which happens to use networking as a teaching tool? Or is it a networking course? Or a Rust networking course? etc. I think it would be good to think specifically about what audience we expect, and what 'problem' we are solving for them.
- Asyncronous programming with [futures] and [tokio] | ||
- High-performance networking with [GRPC] and [prost] | ||
- Asyncronous programming with [futures] | ||
- Networking with [hyper] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think teaching 'networking with Hyper' is not a good idea since we don't use it at pingCAP (afaik) and it is not an essential library and the domain is still in flux. I think it is OK to use Hyper, just emphasize that we're teaching networking in Rust rather than any particular library (could even just use TCP?)
rust/plan.md
Outdated
counts toward extra credit during final evaluation_. Pull requests to any other | ||
project used during this course count as well. This is an opportunity to gain | ||
experience contributing to an open-source Rust project. Make this a better | ||
course for the next to take it than it was for you. That is how open source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
course for the next to take it than it was for you. That is how open source | |
course for the next students to take than it was for you. That is how open source |
@@ -24,209 +24,240 @@ A suggested workflow: | |||
- if taking the course online, read the writeups that accompany the slides | |||
- Follow each project according to their own instructions, writing Rust programs | |||
that pass the projects' accompanying tests. | |||
- (Optionally) Submit project for online grading via [TODO]. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have some explicit prerequisites - do we expect people to know Rust already? Or another programming language? Enough about DBs to know what a KV store is?
- Lesson: Formatting, println et. al, log, and slog | ||
**Topics**: `#[test]`, how does test work?, what does `cargo run` actually do?, | ||
clippy, rustfmt, controlling clippy and rustfmt, links to other useful tools, | ||
cargo / rustc wrapping pattern in depth (ex rustup, `RUSTC_WRAPPER`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't feel like the other topics - it is probably worth thinking explicitly about how much internals stuff we want to cover (my vote would be for a minimal amount - just enough to understand things like repr(packed))
- Topics: formatting tips, derive Debug in depth, how does format! work?, log | ||
demo, slog and structured logging, env_logger, APIs that take format | ||
strings, | ||
### [Lesson: Formatting, println et. al, log, and slog][t-fmt] ([slides][s-fmt]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation for this? I expect if the student already knows Rust basics, then they can use println
and I don't think advanced format string stuff helps too much with the goal of networking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation is to teach interesting intermediate Rust material that is related to the project at hand. This project has evolved such that there's not a lot of formatting going on though.
I've heard quite a bit of feedback about the scope of the project and the lessons not focusing on only the information needed for the projects.
I'm just going to delete all the lessons and focus on the projects for now.
rust/projects/tools/project.md
Outdated
things to do before it is a polished piece of Rust software, ready for | ||
contributions or publication. | ||
|
||
First, public items should have doc comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bit strong, but this is kind of a bee in my personal bonnet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a qualifier.
the `target/doc` folder. Note though that `target/doc` folder does not contain | ||
an `index.html`. Your crate's documentation will be located at | ||
`target/doc/kvs/index.html`. You can launch a web browser at that location with | ||
`cargo doc --open`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth mentioning rustup doc
here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. It doesn't help complete the project. The only way I can think to fit it in is as an aside, like "Relatedly, when you need to browse Rust's own documentation, you can run rustup doc
."
rust/projects/tools/project.md
Outdated
information gathered from the type signature. They explain why and how one would | ||
use a function, what the return value is on both success and failure, error and | ||
panic conditions. The library you have written is very simple so the | ||
documentation can be simple as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 though I might go further and say that the simple docs aren't necessary at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
--doc`. | ||
|
||
You may want to add `#![deny(missing_docs)]` to the top of `src/lib.rs` | ||
to enforce that all public items have doc comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate making this lint deny
, but it might be a minority opinion
|
||
``` | ||
rustup component add clippy | ||
rustup component add rustfix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rustup component add rustfix | |
rustup component add rustfmt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
When I was writing the project, any time I hit a task that could be done multiple ways, with different pros and cons; or when I had some thoughts about the subject beyond the task at hand, I wrote it down as a question, with the intent that the student thinks deeper about the subject and also gains that knowledge. Some of @sticnarf's comments on his own followup PR probably make two of the questions moot, so I'll probably just drop the notion of questions altogether. |
Hi @nrc. This question of the goals of the course, and the intended audience are distressing. It's been asked a number of times, and I've tried to convey it clearly in the readme. Right now the readme contains this statement:
And this
The goal statement expresses my teaching interests - I want to convey knowledge that can't be found in the books, the types of things that I find myself considering when writing Rust software. The projects - to me - are simply a backdrop for stirring up subjects to dig deep into. This doesn't seem to resonate with others though, since I hear lots of confusion about the lesson subjects not being relevant to the projects. So it looks like I need to adjust my idea for this course, focus on projects that teach the technologies that TiKV uses, providing the background material needed for that, and cut everything else out. I'll think of new statements about the goals and audience, but I'm very glad to take suggestions. Maybe once we have a revised goal statement I or someone else will annotate every topic to explain the motivation, since that is a question that comes up on every pull request. cc @sticnarf this thread has discussion about the goals of the project. I've pushed a commit to address @nrc's suggestions, except for mentioning For the sake of progress I'm going to merge this, but please file bugs if you disagree with any of it. |
I'll keep discussion of general goals on #24
Sorry, I don't mean to cause distress. A contributing factor may be that I have heard several different motivations for the course from different people at different times and I am taking that into account as well as the actual text.
👍 |
It's been a long time since I've submitted anything, so here's my current branch.
The main things to note here is that project 1 has more text now, and that I've removed gRPC and tokio from the plan (from discussion with Liu we agreed they were too ambitious for these 5 projects and could come in a later project).
Rendered
Tomorrow I will create an issue outlining the next steps so that others might help.
PTAL @overvenus @nolouch