summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAge
* Add a likely_pkg hint argument to sync_db_readDan McGee2011-01-21
| | | | | | | | | | | | | | | In most (all?) cases, we will process all files for a given sync database entry sequentially. The code currently does an _alpm_pkg_find() for every file in the database, but we had the "current" package readily available. Shift some local variables around a bit to expose this to sync_db_read() and use it if the package is the correct one. On my system, this cuts calls to _alpm_pkg_find() from 20,769 to 10,349 calls during a -Qu operation, and results in a ~30% speedup of the same operation (0.35 sec -> 0.27 sec). This benefit should be apparent anywhere we read in the full contents of the sync databases. Signed-off-by: Dan McGee <dan@archlinux.org>
* Improve splitname memory allocationDan McGee2011-01-21
| | | | | | | | We don't need to create a temporary copy of the string if we are smart with our pointer manipulation and string copying. This saves a bunch of string duplication during database parsing, both local and sync. Signed-off-by: Dan McGee <dan@archlinux.org>
* Improve depends string parsingDan McGee2011-01-21
| | | | | | | | | Remove the need for an unconditional string duplication by using pointer arithmetic instead, and strndup() instead of an unspecified-length strdup(). This should reduce memory churn a fair amount as this is called pretty frequently during database loads. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add strndup fallback function to libalpm utilDan McGee2011-01-21
| | | | | | The same fallback we are currently using in the pacman frontend. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix integrity check status when installing from fileDan McGee2011-01-18
| | | | | | | | When installing packages from a file, the integrity check count stays at (0/x) complete. This ensures it is bumped to (x/x) at the end of the process. Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'diskspace-fixes'Dan McGee2011-01-11
|\
| * Call archive_read_data_skip() while checking diskspaceDan McGee2011-01-11
| | | | | | | | | | | | | | libarchive eventually calls it anyway, but backtraces make a lot more sense if we call it, as well as matching our precedent from alpm_pkg_load(). Signed-off-by: Dan McGee <dan@archlinux.org>
| * Add error message stating which partition is fullDan McGee2011-01-11
| | | | | | | | | | | | | | | | | | This is helpful anyway to the user, and should also be helpful to us if we see problems cropping up in the check during development. Also add a missing ->used = 0 initialization in the code path less taken. Signed-off-by: Dan McGee <dan@archlinux.org>
| * Unify two free diskspace error messagesDan McGee2011-01-11
| | | | | | | | | | | | | | Although they won't be the same in the gettext catalog because of the '\n' we should still use the same text. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'fix-double-load'Dan McGee2011-01-11
|\ \ | |/ |/|
| * Fix double filelist issue when upgrading a packageDan McGee2011-01-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the way we funk around with package data loading, we had a condition where the filelist got doubled up because it was loaded twice. Packages are originally loaded with INFRQ_BASE. In an upgrade/sync, the package is checked for file conflicts next, leaving us in an "INFRQ_BASE | INFRQ_FILES" state. Later, when committing a single package, we have an explicit call to _alpm_local_db_read() with INFRQ_ALL as the level. Because the package's level did not match this, we skipped over our previous "does the incoming level match where I'm at" shortcut, and continued to load things again, because of a lack of fine-grained checking for each of DESC, FILES, and INSTALL. The end result is we loaded the filelist twice, causing our remove logic to iterate twice over the installed files, spewing a bunch of "cannot find file X" messages. Fix the problem by doing a bit more bitmasking logic throughout the load method, and also fix the sanity check at the beginning of the function- this should *only* be used for local packages as opposed to the "not a package" check that was there before. A debug log message was added to upgraderemove as well to match the one already in the normal remove codepath. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add a progressbar for package integrity checkingDan McGee2011-01-11
| | | | | | | | | | | | | | This can take a while too, and it is really easy to add the necessary callback stuff for adding a progressbar. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Small fix to download size lookup and a loggerDan McGee2011-01-11
|/ | | | | | | | These were just two small things I came across today and found could be fixed or helpful, so I've added them and I'm not sure what else to bundle them with. commit_count++ Signed-off-by: Dan McGee <dan@archlinux.org>
* Ensure we use local package when calculating removed sizeDan McGee2011-01-10
| | | | | | | | | | | We were checking if a package existed locally, but then using the incoming package to calculate removed size rather than the currently installed package. Also adjust the local variable in the replaces loop to make it more clear that we are always dealing with local packages here. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove need for floating point division in backendDan McGee2011-01-10
| | | | | | | | | | | All of these can be done with integer division; the only slightly interesting part is ensuring we round up like before with calling the ceil() function. We can also remove the math library from requirements; now that the only ceil() calls are gone, we don't need this anymore. Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm/be_package.c: fix small memleakXavier Chantry2011-01-07
| | | | | | | | | | file_pkg_ops can be a static struct like in other backends, we just need to initialize it at some point. Dan: add initialization flag. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix some more simple conversion "errors"Dan McGee2011-01-07
| | | | | | | | None of these warn at the normal "-Wall -Werror" level, but casts do occur that we are fine with. Make them explicit to silence some warnings when using "-Wconversion". Signed-off-by: Dan McGee <dan@archlinux.org>
* Use size_t for alpm_list sizesAllan McRae2011-01-07
| | | | | | | | | | | | | There is a lot of swtiching between size_t and int for alpm_list sizes in the codebase. Start converting these to all be size_t by adjusting the return type of alpm_list_count and fixing all additional warnings given by -Wconversion that are generated by this change. Dan: a few more small changes to ensure things compile, adjusting some printf format string characters to accommodate the larger size on x86_64. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Refactor old date parsing into single methodDan McGee2011-01-07
| | | | | | | We've managed to duplicate this four times at this point, so make it a method in util.c instead. Signed-off-by: Dan McGee <dan@archlinux.org>
* Update copyright years for 2011Allan McRae2011-01-07
| | | | | Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove FORCE reading from local DBDan McGee2011-01-05
| | | | | | We never wrote it here, so no need to read it in either. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix function indentationDan McGee2011-01-02
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2010-12-30
|\ | | | | | | | | | | Conflicts: lib/libalpm/sync.c test/pacman/tests/ignore007.py
| * Respect Ignore{Pkg,Group} for group membersJakob Gruber2010-12-30
| | | | | | | | | | | | Fixes FS#19854. Signed-off-by: Dan McGee <dan@archlinux.org>
| * Move group code to separate functionJakob Gruber2010-12-30
| | | | | | | | | | | | | | This makes the following commits more readable. No logic was changed in this commit. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Declare all local functions staticAllan McRae2010-12-30
| | | | | | | | | | | | | | | | | | | | | | | | All functions that are limited to the local translation unit are declared static. This exposed that the _pkg_get_deltas declaration in be_local.c was being satified by the function in packages.c which when declared static caused linker failures. Fixes all warnings with -Wmissing-{declarations,prototypes}. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add const to some ALPM function signaturesJakob Gruber2010-12-30
| | | | | | | | | | | | char * -> const char *. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use limits.h for PATH_MAXAllan McRae2010-12-29
| | | | | | | | | | | | | | | | | | | | | | | | We use PATH_MAX everywhere by including limits.h so there is no point in doing a check for it in a different header when dealing with FreeBSD's libfetch. Also, remove autoconf check for strings.h header as it is not used anywhere. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Detect undefined PATH_MAXAllan McRae2010-12-29
| | | | | | | | | | | | | | | | | | | | | | | | | | POSIX does not require PATH_MAX be defined when there is not actual limit to its value. This affects HURD based systems. Work around this by defining PATH_MAX to 4096 (as on Linux) when this is not defined. Also, clean up inclusions of limits.h and remove autoconf check for this header as we do not use macro shields for its inclusion anyway. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Correct type for hash value storageAllan McRae2010-12-29
| | | | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'depcmp-perf'Dan McGee2010-12-29
|\ \
| * | Use name hashes in depends to avoid strcmp callsDan McGee2010-12-21
| | | | | | | | | | | | | | | | | | | | | | | | Just like we did for package name comparsions, if we add a depend name_hash field on depend struct initialization, we can use it instead of doing a string name comparison, saving us a lot of checks in the depcmp code. Signed-off-by: Dan McGee <dan@archlinux.org>
| * | Remove need for memory allocation in _alpm_depcmpDan McGee2010-12-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Noticed when tweaking testdb, when we run _alpm_depcmp in loops and call it seven million times, the strdup()/free() combo can add up. Remove the need for any string duplication by some pointer manipulation and use of strncmp instead of strcmp. Also kill the function logger and add an escape so we don't needlessly retrieve the list of provides. Signed-off-by: Dan McGee <dan@archlinux.org>
* | | Overhaul archive fgets functionDan McGee2010-12-21
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old function was written in a time before we relied on it for nearly every operation. Since then, we have switched to the archive backend and now fast parsing is a big deal. The former function made a per-character call to the libarchive archive_read_data() function, which resulted in some 21 million calls in a typical "load all sync dbs" operation. If we instead do some buffering of our own and read the blocks directly, and then find our newlines from there, we can cut out the multiple layers of overhead and go from archive to parsed data much quicker. Both users of the former function are switched over to the new signature, made easier by the macros now in place in the sync backend parsing code. Performance: for a `pacman -Su` (no upgrades available), _alpm_archive_fgets() goes from being 29% of the total time to 12% The time spent on the libarchive function being called dropped from 24% to 6%. This pushes _alpm_pkg_find back to the title of slowest low-level function. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Only check diskspace availability if needs more than zeroAllan McRae2010-12-20
| | | | | | | | | | | | | | | | | | | | The amount of diskspace needed for a transaction can be less than zero. Only test this against the available disk space if it is positive, which avoids a comparison being made between signed and unsigned types (-Wsign-compare). Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Always specify arguement type in function delcarationsAllan McRae2010-12-20
| | | | | | | | | | | | | | | | Always declare a function with (void) rather than () when we expect no arguements. Fixes all warnings with -Wstrict-prototypes. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use macros in sync DB parsingDan McGee2010-12-20
| | | | | | | | | | | | | | | | | | | | This simplifies a lot of the repetative code and makes it obvious where the tricky or different ones are (e.g. depends, dates). It also makes it significantly easier to change the way this code works in the future. There should be no functional change with this patch. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add a cushion for diskspace checkingDan McGee2010-12-15
| | | | | | | | | | | | It is the minimum of 5% of disk capacity or 20 MiB on a per-partition basis. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Reorganize fields in package structDan McGee2010-12-14
| | | | | | | | | | | | | | Saves a few bytes due to padding (256 -> 248 bytes), especially on x86_64, so we get the overhead of our new hash field right back. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Used hashed package name in _alpm_pkg_findDan McGee2010-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This results in huge gains to a lot of our codepaths since this is the most frequent method of random access to packages in a list. The gains are seen in both profiling and real life. $ pacman -Sii zvbi real: 0.41 sec -> 0.32 sec strcmp: 16,669,760 calls -> 473,942 calls _alpm_pkg_find: 52.73% -> 26.31% of time $ pacman -Su (no upgrades found) real: 0.40 sec -> 0.50 sec strcmp: 19,497,226 calls -> 524,097 calls _alpm_pkg_find: 52.36% -> 26.15% of time There is some minor risk with this patch, but most of it should be avoided by falling back to strcmp() if we encounter a package with a '0' hash value (which we should not via any existing code path). We also do a strcmp once hash values match to ensure against hash collisions. The risk left is that a package name is modified once it was originally set, but the hash value is left alone. That would probably result in a lot of other problems anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* | When setting package name, set hash value as wellDan McGee2010-12-14
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add hash_sdbm functionDan McGee2010-12-14
| | | | | | | | | | | | | | | | This is prepping for the addition of a hash field to each package to greatly speed up the string comparisons we frequently do on package name in _alpm_pkg_find. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use _alpm_pkg_find in deps searchDan McGee2010-12-14
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Correctly force load of package reasonDan McGee2010-12-13
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Abstract has_scriptlet() to package ops structDan McGee2010-12-13
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove non-public functions from headerDan McGee2010-12-13
| | | | | | | | | | | | And rename accordingly. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Mark sync_db_read() as staticDan McGee2010-12-13
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Abort db_populate if dbpath is not setBruno Widmann2010-12-13
| | | | | | | | | | | | | | Rather than segfault. Fixes FS#21345. Signed-off-by: Bruno Widmann <bruno.widmann@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Create sync/ DB directory if it does not existDan McGee2010-12-12
| | | | | | | | | | | | | | Rather than error out, this is easy enough. Looks quite similar to the code in be_local for creating the local directory. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge desc and depends files in local dbAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | Whenever depends is needed from the local db, so is desc. The only disadvantage to merging them is the additional time taken to read the depends entries when they are not needed. As depends is in general relatively small, the additional time taken to read it in will be negligable. Also, merging these files will speed up local database access due to less file seeks. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>