8000 Garbage collector documentation by vitiral · Pull Request #1230 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@vitiral
Copy link
Contributor
@vitiral vitiral commented May 5, 2015

This is to prepare for #1168. I would appreciate any comments on this documentation before I continue with making it apply to standard malloc/free.

Also, I am considering implementing a standard NEXT macro that gets the next piece of allocated memory -- this way the entire memory can easily be stepped through. All micro memory allocators that I have encountered (including tinymem) support this, so I think it should be a requirement for any memory manager that micro-python plugs into.

In addition, I think any memory manager we plug into should be able to do in-place marking of memory -- something that is also not necessarily supported with standard malloc/free.

Both of these requirements will increase the speed and reduce the memory consumption (and complexity) of any memory manager used by micropython.

@vitiral
Copy link
Contributor Author
vitiral commented May 5, 2015

Also, in unix folder:

$ cd unix
$ make test
...
430 tests performed (15767 individual testcases)
429 tests passed
1 tests failed: cmd_showbc

I am getting this failure in both master and my branch.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 50ba431 on cloudformdesign:gc_doc into * on micropython:master*.

@vitiral
Copy link
Contributor Author
vitiral commented May 5, 2015

I just realized that this doesn't apply to the "standard" way to document. Does upython have a "stanard" documentation? Have you thought about standardizing on doxygen?

I (try to) follow the contiki documenting style, which follows doxygen. Have you thought about using this? If there is no standard, I would suggest it as a good template:

https://github.com/contiki-os/contiki/blob/master/doc/code-style.c

@stinos
Copy link
Contributor
stinos commented May 6, 2015

I thought I saw comment style being mentioned once but I cannot find it anymore and it's also not in https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md so it's definitely worth some discussion.

I do think doxygen is interesting but I'd prefer something simpler instead of the particular style used here, main reason being this style is too hard to maintain: one needs x amount of indentation and y amount of dashes. Every commit with a comment would have to be carefully reviewed to check if the style matches, that is a waste of time. It is also not clear to me when those dashed lines should be used, nor why you chose to sometimes terminate comments (*/ at the end) and other times not. Simpler would be for example: no space before * and 1 space after it, no dashed lines anywhere and also doxygen has AUTOBRIEF options so that would already get rid of the need to repeat \brief all over the place.

You should probably generate the documentation once as well: some comments might not be placed where you actually want them. For example comment ATB Access Macros is placed directly above BLOCK_SHIFT so probably doxygen is going to generate it for that macro where it should rather be the documentation for a group of comments (afaik).

Apart from that: nice effort and certainly interesting for people just starting to look into the code.

@pfalcon
Copy link
Contributor
pfalcon commented May 6, 2015

Sorry, I don't see much of "documentation" here, more like personal notes. Perhaps, the original idea to put in wiki is better?

Here's discussion on related topic: http://stackoverflow.com/questions/167498/what-is-less-annoying-no-source-code-documentation-or-bad-code-documentation

@vitiral
Copy link
Contributor Author
vitiral commented May 6, 2015

@pfalcon Well, that discussion says:

Incorrect documentation that looks authoritative is worse than no documentation.

Incomplete documentation is better than no documentation.

Speculative documentation that is marked as such is, often, better than no documentation.

and

That doesn't mean I comment every line of code but method, class, etc summaries are mandatory and additional lines for difficult code parts are helping too.

All reasons why I wanted feedback on it. If you think it should be more brief and less descriptive I can try to do that, but I agree with the poster that "method, class, etc summaries are mandatory" -- and this module has no summaries.

I also agree that speculative documentation (that is marked as such) is often better than no documentation.

@vitiral
Copy link
Contributor Author
vitiral commented May 6, 2015

@stinos

The /*------...-----*/ lines are supposed to go in front of every function/structure definition, and every "group" of macro definitions. I didn't quite follow that yet.

I agree that doxygen is pretty picky, and I didn't realize about the autobrief -- I think your comments are accurate. If I had to choose, I would make the commenting as such:

*/----------------------------------------------------------------------------*/
/**
 * This is the documentation for a function or structure. This
 * first line should contain a short description
 * 
 * There should be a space between the first description
 * and the rest of the description. Use this space to comment
 * on the code.
 *
 * \param1 name     comment on parameters like this
 * \retval          comment on the return value like this
*/
int function(char *name){
    ...
    return 5;
}

@pfalcon
Copy link
Contributor
pfalcon commented May 6, 2015

If you think it should be more brief and less descriptive

It should be brief and descriptive, avoid "original research" in roughly wikipedia terms, like telling that allocation table is "allocator" (it is not), avoid providing trivial info like where something is defined (figuring that out is a basic skill, if something changes, your "documentation" is false), or that function which is named verify verifies, avoid providing repetitive info (something is member, member, member), etc. - all the things you read on http://thedailywtf.com/ and in other places.

That doesn't mean I comment every line of code but method, class, etc summaries are mandatory

The guy who said that is likely a big boss who does a payroll, so he knows what he's talking about. It's all simpler with open-source - documentation has lower priority, because functionality has higher and resources are usually rather limited. And in this situation, providing bad documentation is worse than providing better code. And if you know big boss guy who wants to sponsor writing docstrings for every piece of method - do let everyone know. (Just please don't tell that you're going to write doxygen docs for every function in uPy (possible) and maintain them (impossible)).

@pfalcon
Copy link
Contributor
pfalcon commented May 6, 2015

All reasons why I wanted feedback on it.

So, my feedback: I agree that this module lacks summary, it's worth saying that it provides simple conservative tracing garbage collector and link to wikipedia article. Otherwise, you started a wiki page https://github.com/micropython/micropython/wiki/Memory-Manager , please do maintain it as your understanding of inner working progresses.

As usual, it's just my opinion.

@dpgeorge
Copy link
Member
dpgeorge commented May 6, 2015

I just realized that this doesn't apply to the "standard" way to document. Does upython have a "stanard" documentation? Have you thought about standardizing on doxygen?

The standard is implicit in the format of existing comments: be concise, use // prefix, no extra fluff, only write comments for things that are not obvious.

In general I'm against lengthy and unnecessary comments, and I don't want to go down the doxygen route. Reading the code should be enough to describe what's happening, and, if it's not, then you write a comment.

Most of the comments in this PR go against the above rules. There are some comments that you have that are worth adding but they need trimming and re-formatting.

@vitiral
Copy link
Contributor Author
vitiral commented May 6, 2015

thanks for the comments @dpgeorge. That sounds good, I have added those comments to issue #1235 and will be adding them to the style guide.

I am closing this pull request as #1234 will encompass them. I will be sure to do what Damien suggested in that request before it is done.

@vitiral vitiral closed this May 6, 2015
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Oct 9, 2018
Translate strings in nrf directory
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.

5 participants

0