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

Combined Joyent fixes and improvements #58

Merged
merged 12 commits into from
Aug 13, 2015

Conversation

jperkin
Copy link
Contributor

@jperkin jperkin commented Aug 10, 2015

This single pull requests incorporates all the recent fixes I've made, which may help with the merge process. It also includes a small fix to the output from the new summary code (was missing the final '\n').

Hopefully merging this single pull request will be simpler than handling the individual ones, there are a couple of merge conflicts if you do them separately.

Jonathan Perkin added 10 commits July 31, 2015 13:30
Previously list output would differ depending on whether the output was
a tty or not, causing issues with various automated tools.
At present there is no proper upgrade test, it merely checks whether
there are any entries in the database.  As this will be false on first
update, we don't want to have to confirm when we clearly need to perform
an update regardless.

Marked as '#ifdef notyet' so that if in the future the database format
does change we can write a query to detect that situation and re-enable
the check (though arguably we'd always want to upgrade anyway).
Previously package downloads would go through download_file() and cache
the entire file in RAM before writing to disk.  Introduce a new
download_pkg() function which streams 4K at a time and significantly
reduces memory usage.
While here add a few more const queries.
It is no longer used as a general purpose download function so remove
some bits and update some comments that no longer make sense.
Use libarchive (which we were linking against but not using) to handle
streaming the remote pkg_summary.  The copy of decompress.c is no longer
required.

We now stream one pkg_info record at a time, rather than loading the
entire contents in and then processing them all in one go.  They are
still processed as part of the same commit, so there is no performance
penalty (if anything this version is slightly faster).

Using the SmartOS 2015Q1 x86_64 repository as a test corpus, heap usage
for a clean "pkgin update" with this change goes down from 75MB to 29MB.
Testing against the SmartOS 2015Q1 x86_64 repository, using the default
cache size shows no difference in performance, but reduces the heap size
required from 29MB to 9MB.
@jperkin
Copy link
Contributor Author

jperkin commented Aug 12, 2015

I just added a new commit to this. 72cd834 completes the integration of libarchive and uses it to call libfetch directly, reducing both RSS usage and runtime.

This splits download_summary() into an initialise function (sum_open())
and three archive_read_open() callbacks (sum_start(), sum_read(),
sum_close()).  libarchive can handle EOF and read failures, so this also
simplifies things a little.

One side-effect of this change is that we no longer need individual
progress meters for the download and the database updates (in fact they
would clash), so we now only use the libfetch progress meter.

As we are now updating the database while the file is being fetched, if
the fetch is incomplete we delete the remote summary database rather
than leaving it in an inconsistent state.

With these changes applied on 64-bit SmartOS we see a 2MB reduction in
RSS usage, and a 1.5 second faster runtime for a fresh "pkgin update".
@jperkin
Copy link
Contributor Author

jperkin commented Aug 12, 2015

And one more to support pkg_summary.xz if available (635c3fa).

Testing shows it to be smaller and faster than bz2, at the cost of
around 4.5MB RSS: https://gist.github.com/jperkin/7e8ad0ffa8d6c66070b9

With recent memory improvements we can afford that for the benefits on
offer for the default case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant