Skip to content
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

Optimize libtar extract #131

Merged
merged 6 commits into from
Jun 9, 2020
Merged

Optimize libtar extract #131

merged 6 commits into from
Jun 9, 2020

Conversation

JonathonReinhart
Copy link
Owner

@JonathonReinhart JonathonReinhart commented Jun 9, 2020

This updates tar_extract_regfile() to make a single write() syscall, rather than writing 512 bytes at a time.

Closes #130

strace -c ./id-dev.sx 
uid=1000(jreinhart) gid=1000(jreinhart) groups=1000(jreinhart),...
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 31.61    0.000325          46         7           write
 17.12    0.000176           8        20         7 unlink
  7.59    0.000078           1        51           open
  6.23    0.000064           1        63           close
  6.03    0.000062           0        74           read
  5.54    0.000057           0        81           fcntl
  3.31    0.000034          34         1           rmdir
  3.21    0.000033           2        12        12 connect
  3.02    0.000031           5         6           symlink
  2.53    0.000026           5         5           munmap
  2.24    0.000023           7         3           madvise
  2.14    0.000022           0        27        26 mkdir
  1.85    0.000019           0        28           lseek
  1.85    0.000019           1        12           socket
  1.36    0.000014           2         7           utimensat
  0.97    0.000010           1         7           chmod
  0.68    0.000007           0        13           geteuid
  0.68    0.000007           3         2           getdents64
  0.49    0.000005           0         6           mmap
  0.49    0.000005           5         1           fork
  0.29    0.000003           0        14           lstat
  0.29    0.000003           0         4           rt_sigaction
  0.19    0.000002           2         1           wait4
  0.10    0.000001           1         1           stat
  0.10    0.000001           1         1           access
  0.10    0.000001           1         1           readlink
  0.00    0.000000           0         3           fstat
  0.00    0.000000           0         6           brk
  0.00    0.000000           0         3           rt_sigprocmask
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         1           arch_prctl
  0.00    0.000000           0         1           set_tid_address
------ ----------- ----------- --------- --------- ----------------
100.00    0.001028                   463        45 total

My unscientific test shows the total write going:

  • Before: 5517 calls, total 0.009341 sec
  • After: 7 calls, total 0.000325 sec (-96.5% 🎉)

@JonathonReinhart
Copy link
Owner Author

Travis is being a douchebag (#124) and not showing the checks, but the tests all passed.

@JonathonReinhart JonathonReinhart merged commit 6e2817f into master Jun 9, 2020
@JonathonReinhart JonathonReinhart deleted the 130-extract-optimize branch June 9, 2020 05:18
Copy link

@Ajckxska Ajckxska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tar_extract_regfile writes 512 bytes at a time
2 participants