moby/pkg
Kir Kolyshkin c611f18a7f pkg/mount/mountinfo_linux: parser speed up
The mountinfo parser implemented via `fmt.Sscanf()` is slower than the one
using `strings.Split()` and `strconv.Atoi()`. This rewrite helps to speed it
up to a factor of 8x, here is a result from go bench:

> BenchmarkParsingScanf-4      	     300	  22294112 ns/op
> BenchmarkParsingSplit-4      	    3000	   2780703 ns/op

I tried other approaches, such as using `fmt.Sscanf()` for the first
three (integer) fields and `strings.Split()` for the rest, but it slows
things down considerably:

> BenchmarkParsingMixed-4      	    1000	   8827058 ns/op

Note the old code uses `fmt.Sscanf`, when a linear search for '-' field,
when a split for the last 3 fields. The new code relies on a single
split.

I have also added more comments to aid in future development.

Finally, the test data is fixed to now have white space before the first field.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-04-19 14:49:42 -07:00
..
aaparser Add canonical import comment 2018-02-05 16:51:57 -05:00
archive Set format in archiver 2018-04-12 13:34:33 -07:00
authorization Merge pull request #36778 from odg0318/master 2018-04-12 17:39:38 -07:00
broadcaster Add canonical import comment 2018-02-05 16:51:57 -05:00
chrootarchive Add canonical import comment 2018-02-05 16:51:57 -05:00
containerfs Set format in archiver 2018-04-12 13:34:33 -07:00
devicemapper pkg: devmapper: dynamically load dm_task_deferred_remove 2018-02-16 17:23:23 +11:00
directory Support cancellation in directory.Size() 2018-03-29 15:49:15 -04:00
discovery Add canonical import comment 2018-02-05 16:51:57 -05:00
dmesg Add canonical import comment 2018-02-05 16:51:57 -05:00
filenotify Add canonical import comment 2018-02-05 16:51:57 -05:00
fileutils Automated migration using 2018-03-16 11:03:43 -04:00
fsutils Add canonical import comment 2018-02-05 16:51:57 -05:00
homedir Add canonical import comment 2018-02-05 16:51:57 -05:00
idtools Automated migration using 2018-03-16 11:03:43 -04:00
ioutils Automated migration using 2018-03-16 11:03:43 -04:00
jsonmessage Cleanup pkg/jsonmessage progress tests 2018-03-16 11:03:47 -04:00
locker Add canonical import comment 2018-02-05 16:51:57 -05:00
longpath Add canonical import comment 2018-02-05 16:51:57 -05:00
loopback Add canonical import comment 2018-02-05 16:51:57 -05:00
mount pkg/mount/mountinfo_linux: parser speed up 2018-04-19 14:49:42 -07:00
namesgenerator Add canonical import comment 2018-02-05 16:51:57 -05:00
parsers Windows: Move kernel_windows to use golang registry functions 2018-03-16 09:47:45 -07:00
pidfile Add canonical import comment 2018-02-05 16:51:57 -05:00
platform Add canonical import comment 2018-02-05 16:51:57 -05:00
plugingetter Merge pull request #35829 from cpuguy83/no_private_mount_for_plugins 2018-02-21 12:28:13 +01:00
plugins Post migration assertion fixes 2018-03-16 11:03:46 -04:00
pools Automated migration using 2018-03-16 11:03:43 -04:00
progress Add canonical import comment 2018-02-05 16:51:57 -05:00
pubsub Add canonical import comment 2018-02-05 16:51:57 -05:00
reexec Automated migration using 2018-03-16 11:03:43 -04:00
signal Automated migration using 2018-03-16 11:03:43 -04:00
stdcopy Add canonical import comment 2018-02-05 16:51:57 -05:00
streamformatter Cleanup pkg/jsonmessage progress tests 2018-03-16 11:03:47 -04:00
stringid Add canonical import comment 2018-02-05 16:51:57 -05:00
symlink Add canonical import comment 2018-02-05 16:51:57 -05:00
sysinfo Automated migration using 2018-03-16 11:03:43 -04:00
system Automated migration using 2018-03-16 11:03:43 -04:00
tailfile Fix typos in pkg 2018-02-10 19:43:13 +08:00
tarsum Fix tarsum for go 1.10 2018-04-12 13:34:14 -07:00
term Post migration assertion fixes 2018-03-16 11:03:46 -04:00
truncindex Add canonical import comment 2018-02-05 16:51:57 -05:00
urlutil Add canonical import comment 2018-02-05 16:51:57 -05:00
useragent Add canonical import comment 2018-02-05 16:51:57 -05:00
README.md Rename a few docker to moby 2017-10-25 13:56:12 +02:00

pkg/ is a collection of utility packages used by the Moby project without being specific to its internals.

Utility packages are kept separate from the moby core codebase to keep it as small and concise as possible. If some utilities grow larger and their APIs stabilize, they may be moved to their own repository under the Moby organization, to facilitate re-use by other projects. However that is not the priority.

The directory pkg is named after the same directory in the camlistore project. Since Brad is a core Go maintainer, we thought it made sense to copy his methods for organizing Go code :) Thanks Brad!

Because utility packages are small and neatly separated from the rest of the codebase, they are a good place to start for aspiring maintainers and contributors. Get in touch if you want to help maintain them!