-
-
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
sort: -S/--buffer-size does not support memory percentages % #3500
Comments
There is an even bigger problem here, which is that |
@miDeb I wasn't aware of that issue, but it looks to me the two can be fixed independently from one another. |
Addresses issue uutils#3500, which calls for sort to permit percentage values for the buffer-size flag. Portability is an issue here, but I don't think this change constrains `sort`'s portability any more than its dependencies already do. To calculate a fraction of the system's memory, naturally we need to retrieve the system's total memory. GNU's equivalent -- see `physmem_total` in `lib/physmem.c` in gnulib -- has a series of `ifdef`s to decide how to retrive the value. Each platform has its own considerations, and the result is a pretty serious mess. This patch omits that mess. In exchange, it will only work on platforms with a functioning libc. The thing is, `sort` already includes libc, which is why I said this patch doesn't introduce new constraints on `sort`'s portability.
I will take a look at this one (only the percentage parsing for now) |
Fixes issue uutils#3500 by adding support for percentags of total memory for the buffer-size flag. The sysinfo crate is used to determine the total memory of a system. Usage of sysinfo instead of custom code makes this part very multi-platform compatible (See sysinfo documentation for supported OSes). As well as avoiding introducing unsafe code from libc's sysinfo.
Fixes issue uutils#3500 by adding support for percentags of total memory for the buffer-size flag. The sysinfo crate is used to determine the total memory of a system. Usage of sysinfo instead of custom code makes this part very multi-platform compatible (See sysinfo documentation for supported OSes). As well as avoiding introducing unsafe code from libc's sysinfo.
Fixes issue uutils#3500 by adding support for percentags of total memory for the buffer-size flag. The sysinfo crate is used to determine the total memory of a system. Usage of sysinfo instead of custom code makes this part very multi-platform compatible (See sysinfo documentation for supported OSes). As well as avoiding introducing unsafe code from libc's sysinfo.
Fixes issue uutils#3500 by adding support for percentags of total memory for the buffer-size flag. The sysinfo crate is used to determine the total memory of a system. Usage of sysinfo instead of custom code makes this part very multi-platform compatible (See sysinfo documentation for supported OSes). As well as avoiding introducing unsafe code from libc's sysinfo.
Is this open for contribution? |
Sure, go ahead! |
Is it ok to use sysinfo crate to get memory size? |
@zeroishero I think we already use that crate in some utils, so should be fine! |
Ok, then. I can probably do this. I will start it soon. |
@tertsdiepraam I don't see sysinfo being used. I meant this crate: |
Hmmm, I was sure we were using that somewhere, but maybe that was some other repo. If it's hard to get the info some other way, it might be fine to use that. You can make a PR with that first and then we'll figure out what to do. The crate is by Guillaume Gomez, so I definitely trust it 😄 |
Add support for parsing percent arguments to the `-S` option. The given percentage specifies a percentage of the total physical memory. For Linux, the total physical memory is read from `/proc/meminfo`. The feature is not yet implemented for other systems. In order to implement the feature, the `uucore::parser::parse_size` function was updated to recognize strings of the form `NNN%`. Fixes uutils#3500
Add support for parsing percent arguments to the `-S` option. The given percentage specifies a percentage of the total physical memory. For Linux, the total physical memory is read from `/proc/meminfo`. The feature is not yet implemented for other systems. In order to implement the feature, the `uucore::parser::parse_size` function was updated to recognize strings of the form `NNN%`. Fixes uutils#3500
GNU sort v. Rust sort:
Relevant excerpts from GNU sort manpage:
(this could be a good first issue)
The text was updated successfully, but these errors were encountered: