-
Notifications
You must be signed in to change notification settings - Fork 1
Update README.md #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,32 +4,27 @@ It features two processes that take turns calling functions `f()` and `g()` *in | |
|
|
||
|  | ||
|
|
||
| How? | ||
| How it Works | ||
| === | ||
| There’s nothing new in Lua being flexible: it allows to override all the memory management by passing a custom allocator to [`lua_newstate`](https://www.lua.org/manual/5.3/manual.html#lua_newstate). | ||
| There’s nothing new in Lua being flexible. It allows to override all memory management by passing a custom allocator to [`lua_newstate`](https://www.lua.org/manual/5.3/manual.html#lua_newstate). | ||
| The only things left are to create a shared memory mapping and implement an allocator working in it. | ||
|
|
||
| This is more or less safe as long as Lua knows nothing about parallelism. Some things in the standard library do know, though; see the “Caveats” section. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| This is safe as long as Lua knows nothing about parallelism. Some things in the standard library do know, please see the “Caveats” section. | ||
|
|
||
| On systems other that Linux, shared memory mappings have to be of fixed size; by default, this PoC allocates 16 Mb on these systems. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? We have two related independent clauses but no conjunction is used; so we need to use a semicolon.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sentence is too long. I do not think we need to use a semi-colon whenever there are two related independent clauses. Both clauses can be separate sentences, and still give the same message. |
||
| On systems other that Linux, shared memory mappings have to be of fixed size. By default, this PoC allocates 16 Mb on these systems. | ||
|
|
||
| In fact, Linux shared memory mappings also have to be of fixed “size” — of fixed *virtual size*: | ||
| thanks to the [overcommit feature](https://www.kernel.org/doc/Documentation/vm/overcommit-accounting) and the [`MAP_NORESERVE`](http://man7.org/linux/man-pages/man2/mmap.2.html) `mmap` flag, | ||
| which tells Linux to only allocate physical pages on demand (this does *not* depend on which overcommit policy your system is configured to use), we can only pay for what we use, | ||
| and not a page more. And with [`madvise(..., MADV_REMOVE)`](http://man7.org/linux/man-pages/man2/madvise.2.html), we can reclaim the pages we don’t need anymore. Yay! | ||
|
|
||
| On Linux, this PoC goes on to allocate 16 Gb of *virtual* memory. Because this ought to be enough for anybody. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| If your virtual memory is, in some reason, limited, run it as `./main -p`, which forces it to fall back to a portable 16 Mb mapping. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes just for sake of changes are no good.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "in some reason" is not useful information for the reader so that is why I removed it. |
||
| On Linux, this PoC allocates 16 Gb of *virtual* memory as this ought to be enough for anybody. | ||
| If your virtual memory is limited, then run it as `./main -p`. This forces it to fall back to a portable 16 Mb mapping. | ||
|
|
||
| Caveats | ||
| === | ||
| * Some functions in Lua’s standard library *really* don’t expect being called with such a setup. | ||
| These functions are `os.execute`, `io.popen`, `os.exit` and `os.setlocale`. | ||
|
|
||
| * All actions on files (including opening and closing) are local to the current process. | ||
|
|
||
| * My memory allocator sucks. Implementing a better one — possibly leveraging the aforementioned Linux features — is left as an exercise for the reader. | ||
|
|
||
| * Some functions in Lua’s standard library *really* don’t expect being called with such a setup. These functions are `os.execute`, `io.popen`, `os.exit`, and `os.setlocale`. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line is too long.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is long, but I joined them together to be consistent with the bullet-point ordering. |
||
| * All actions on files, including opening and closing, are local to the current process. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was better that way.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, both ways are correct. Whichever one you choose is fine. |
||
| * My memory allocator is not optimal. Implementing a better one — possibly leveraging the aforementioned Linux features — is left as an exercise for the reader. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “not optimal” may create an illusion that it… eh, does not suck. And it does suck. So no.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you say so. I generally avoid saying "suck" to describe my work. |
||
| * Does not work with LuaJIT. | ||
|
|
||
| * Be careful with external modules. | ||
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.
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 main reasons for all the changes I have made is to make it easier for a reader to understand. It could be grammatically correct, but may still be confusing to read.
Yes, you are correct in using colon to connect two independent clauses together. I changed the colon to a period as they imply the same meaning for me when I had read the sentence for the first time. So using colon or period are both okay, but I chose periods for the sake of avoiding confusion between the two clauses.
"the" is to be used for definite articles and when a noun is specified. Using "all the memory management" is not specific as "all" was used, so "the" was removed. Source: https://owl.english.purdue.edu/owl/resource/540/1/