Avoid mmap for > 10 files

This commit is contained in:
John Kerl 2019-08-24 18:35:17 -04:00
parent c28770b039
commit 5cc470d83a
4 changed files with 9 additions and 5 deletions

View file

@ -261,7 +261,7 @@ cli_opts_t* parse_command_line(int argc, char** argv, sllv_t** ppmapper_list) {
slls_append(popts->filenames, argv[argi], NO_FREE);
}
// Check for use of mmap. It's fractionally faster than stdio (due to fewer data copies
// Check for use of mmap. It's about 20% faster than stdio (due to fewer data copies
// -- lrecs can be pointer-backed by mmap memory) but we can't use it in all situations.
if (no_input) {
slls_free(popts->filenames);
@ -269,6 +269,10 @@ cli_opts_t* parse_command_line(int argc, char** argv, sllv_t** ppmapper_list) {
} else if (popts->filenames->length == 0) {
// No filenames means read from standard input, and standard input cannot be mmapped.
popts->reader_opts.use_mmap_for_read = FALSE;
} else if (popts->filenames->length > 10) {
// https://github.com/johnkerl/miller/issues/256: too many small files is as bad as one big one
// (for which see immediately below).
popts->reader_opts.use_mmap_for_read = FALSE;
} else if (popts->reader_opts.use_mmap_for_read == TRUE) {
// https://github.com/johnkerl/miller/issues/160: don't use mmap for large files.
//

View file

@ -2464,7 +2464,7 @@ SEE ALSO
2019-06-04 MILLER(1)
2019-08-24 MILLER(1)
</pre>
</div>
<p/>

View file

@ -2270,4 +2270,4 @@ SEE ALSO
2019-06-04 MILLER(1)
2019-08-24 MILLER(1)

View file

@ -2,12 +2,12 @@
.\" Title: mlr
.\" Author: [see the "AUTHOR" section]
.\" Generator: ./mkman.rb
.\" Date: 2019-06-04
.\" Date: 2019-08-24
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "MILLER" "1" "2019-06-04" "\ \&" "\ \&"
.TH "MILLER" "1" "2019-08-24" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Portability definitions
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~