Commit Graph

88 Commits

Author SHA1 Message Date
Juan RP
06c9891ae3 xbps_transaction_*: multiple performance improvements (v2).
This commit implements multiple performance improvements
to the transaction code:

- Don't process xbps_pkg_name() N times each time we access
  its package dictionary (via pkgdb or rpool), just do it once
  at xbps_pkgdb_init() time. At pkgdb init time, it just creates
  a property in pkgdb, "pkgname". At rpool time, each time a
  package is accessed, the "pkgname" string property is added.

- The package transaction dictionary contains the "transaction"
  object to know what's the pkg type. This has been changed to an
  uint8, this simplifies the logic and it's faster than checking
  a string object. See xbps_trans_type_t and xbps_transaction_pkg_type().

- Fixed the issue that was marked with XXX in transaction shlibs
  checking code. This has been fixed and improved and resources are
  now just freed as expected.

- Simplified random code all over the place, avoiding unnecessary
  allocations or operations.

- Rename some transaction files to have a better description.

This is my first rototill to the code in 2020.
2020-02-21 09:37:32 +01:00
Juan RP
3eed9bca59
xbps_array_foreach_cb_multi: use PTHREAD_MUTEX_INITIALIZER.
We use defaults, no need to use pthread_mutex_init().
2020-02-10 09:14:50 +01:00
Juan RP
c460df6011
xbps_array_foreach_cb_multi: switch to a mutex.
There's no reason to use a spin lock.
2020-02-10 09:08:33 +01:00
Juan RP
6010a24de6 libxbps: ABI/API break due to xbps_pkg{,pattern}_name changes.
The funcs xbps_pkg_name() and xbps_pkgpattern_name() were
using malloc(3) to return the result, until now.

They now have been changed to not allocate the result
via malloc, the caller is responsible to provide a buffer
at least of XBPS_NAME_SIZE (64).

If for whatever reason the pkgname can't be guessed,
returns false. This should avoid lots of small allocs
around libxbps.

New functions have the following prototype:

bool xbps_pkg_name(char *dst, size_t len, const char *pkg)
bool xbps_pkgpattern_name(char *dst, size_t len, const char *pkg)

as suggested by @duncaen.
2020-02-08 19:49:57 +01:00
Juan RP
66b07bb795
xbps_array_foreach_cb_multi: fix previous. 2019-12-27 16:22:40 +01:00
Juan RP
f5d93caf15
xbps_array_foreach_cb_multi: improve previous (v2).
As suggested by @CasperVector reuse the 'i' var to
wait for threads that were created successfully.
2019-12-27 15:47:43 +01:00
Juan RP
a3a1c372cb
xbps_array_foreach_cb_multi: improve previous.
Do not wait for the other threads to finish, just exit early.
2019-12-27 15:19:22 +01:00
Juan RP
08a1c61a4d
xbps_array_foreach_cb_multi: error out if pthread_create(3) fails.
We do not want to continue processing more threads
if pthread_create(3) fails, rather return an error.

This is for #182 but not yet fixed, there might be a
memleak somewhere.
2019-12-27 14:27:51 +01:00
Duncaen
66f66ab7a1 Revert "xbps_array_foreach_cb_multi: fix incorrect array counter."
This reverts commit 08aa44602f.

The element still has to be processed and ignored by one of the
threads, it is not the last entry this will make the actually last item
be ignored.
2019-06-23 11:14:37 +02:00
Duncaen
a4dd0221ac lib/plist.c: fix xbps_array_foreach_cb_multi processing entries multiple times
the first thread to finish will start again from 0 (`reserved`) until
0+slicecount, next thread will then start from the end of the previous
thread which is already wrong, resulting in processing the first
slicecount*maxthreads entries twice.

The first slicecount*maxthreads entries are accounted by the thread
creation loop and `reserved` has to start at the first unaccounted index.
2019-06-23 11:14:37 +02:00
Juan RP
08aa44602f xbps_array_foreach_cb_multi: fix incorrect array counter.
This fixes some races that could be seen when there's a
determined number of pkgs and CPU threads.
2019-04-19 22:57:42 +02:00
Enno Boland
bfd6b2e88e lib/plist.c: share workload more efficient between threads
Before this patch xbps had a constant slice count for every thread.
This resulted in unbalanced thread usage if the workload was
homogenous over the slices.

This patch replaces the naive slice count approach by spinlock based
reservation.
2018-07-02 13:18:23 +02:00
Juan RP
a9482027b2 xbps_array_foreach_cb_multi: handle the case of sysconf returning 0. 2015-11-26 07:18:14 +01:00
Juan RP
cb857dfc27 Alternatives framework for xbps (2/2).
See xbps-alternatives(1) for more information.

Thanks to all who helped to design this and for fixing grammar in
the manual page.
2015-10-30 12:24:46 +01:00
Juan RP
a6f128a578 lib/plist.c: CID 62704 (argument cannot be negative) 2014-10-05 13:22:28 +02:00
Juan RP
d95d5ba113 xbps_array_foreach_cb_multi: remove useless mutex. 2013-12-08 08:07:45 +01:00
Juan RP
023484ca0b Introduce xbps_{array,pkgdb}_foreach_cb_multi() and use it where appropiate.
In some tasks the single threaded implementation outperms the multithreaded
one. Use it where it really makes a difference. The _multi() routines do not
spawn any thread if _SC_NPROCESSORS_ONLN == 1.

Bump XBPS_API_VERSION.
2013-09-17 16:30:13 +02:00
Juan RP
4057e4961c Use C99 for loop initializers.
That means that a C99 compiler is now mandatory.
2013-09-15 10:06:49 +02:00
Juan RP
789165339a Drop useless/unused xbps_add_obj_to_{array,dict} functions. 2013-08-18 10:25:17 +02:00
Juan RP
49fa951836 xbps_array_foreach_cb: replace an assertion with a real test, for non working repos. 2013-07-27 20:01:23 +02:00
Juan RP
0c7701f2bc Introduce xbps_array_foreach_cb() and use it in random code.
This routine will spawn a thread per core to process N items stored
in the specified array, the last thread gets the remainder of items left.

Results have shown that xbps benefits if there is a considerable amount
of items and number of threads being spawned.

Use it in xbps_pkgdb_foreach_cb(), xbps-pkgdb(8), xbps-query(8)
and xbps-rindex(8).

On UP systems there's no overhead because pthread(3) is not used at all.

WIP! investigate if it can be used in libxbps (xbps_rpool_foreach()),
and finish conversion of xbps-rindex(8) -c.
2013-07-27 09:47:16 +02:00
Juan RP
432067de48 Remove three unused API functions. 2013-07-27 06:12:59 +02:00
Juan RP
42c0766c00 Get rid of libfetch and proplib external dependencies.
The list of required external deps is now confuse, libarchive and openssl.

libxbps now includes a wrapper for proplib prefixed with xbps_ rather than prop_.
2013-06-20 10:26:12 +02:00
Juan RP
9d80524a34 Minor optimization: no need to check if obj is NULL, prop_object_type() does that already. 2013-06-14 12:22:29 +02:00
Juan RP
db1efb3aa6 Relax memory requirements on 64bit platforms; fix two memleaks. 2013-06-12 10:04:10 +02:00
Juan RP
e844bc1ad5 xbps_callback_array_iter_reverse: initialize rv (fixes garbage return value). 2013-04-04 09:13:52 +02:00
Juan RP
7c1a0ac3e8 New pkgdb (0.21) and repo index (1.7) format, see NEWS for info. 2013-03-05 04:08:42 +01:00
Juan RP
63c1883201 Major API/ABI cleanup bringing performance improvements and fixes.
These are the core interfaces in the new API:

rpool - Interface to interact with the repository pool.
rindex - Interface to interact with repository indexes.
pkgdb - Interface to interact with local packages.
transaction - Interface to interact with a transaction.

This also brings new repository index format, making the index file
per architecture and being incompatible with previous versions.

The transaction frequency flush option has been removed, and due to
the nature of package states it was causing more harm than good.

More changes coming soon, but the API shall remain stable from now on.
2012-11-30 07:11:51 +01:00
Juan RP
b0fab7a3ee Implemented a cache to get pkg dicts from metadir.
This improves xbps-pkgdb -a marginally, but still seems to be a bit slow.
2012-11-16 21:50:52 +01:00
Juan RP
34bd49f85a New pkg metadata structure for 0.18. See the NEWS file for info. 2012-11-16 16:55:35 +01:00
Juan RP
d6735d5685 xbps_xasprintf: do not return NULL anymore; remove checks for this. 2012-11-11 09:37:27 +01:00
Juan RP
974b2fe8ad libxbps: simplify pkgdb_get_pkgd and find_pkg_dict_installed internals.
There's no need to prop_dictionary_copy the returned dictionary to
later have to free it again, just return directly the dictionary and
avoid the free(3)s.
2012-06-16 09:02:07 +02:00
Juan RP
3e9e87fc2a libxbps: require a pointer to xbps_handle in functions that need it.
This removes 2 global vars from lib/initend.c and easier to know
what functions require access to xbps_handle.
2012-06-14 08:22:11 +02:00
Juan RP
8b2c4ed47e xbps_dictionary_from_metadata_plist: if vpkg not found, look for a real pkg. 2012-04-13 09:23:35 +02:00
Juan RP
9bada162a1 New "metadir" member in xbps_handle to override default metadata dir. 2012-03-13 10:22:35 +01:00
Juan RP
6940505de9 regpkgdb rototill: renamed to pkgdb, improve the public API. 2012-01-20 11:10:52 +01:00
Juan RP
ffa48b2cf3 Fix xbps_configure_packages() by avoiding proplib iterators. 2012-01-16 14:41:16 +01:00
Juan RP
3b7491d29b Merged purge code in remove, configurable transaction regpkgdb flushing.
See the NEWS file for info.
2011-12-24 01:05:26 +01:00
Juan RP
b0ceeaa58e New configuration file via confuse: xbps.conf. 2011-12-15 11:19:20 +01:00
Juan RP
07d47ab09a libxbps: xbps_dictionary_from_metadata_plist: respect pkgname arg. 2011-10-30 08:01:25 +01:00
Juan RP
0a041cdd2e libxbps: new func xbps_array_replace_dict_by_name(array, dict, pkgname)
This function replaces a dictionary in an array matched by pkgname,
with the dictionary passed in as 2nd argument.
2011-10-19 00:37:36 +02:00
Juan RP
5642ffa86e New configuration scheme changes, round 1.
- Configuration file 'xbps-conf.plist' has been splitted off into
  two files: conf.plist and repositories.plist. By default they
  are stored in etc/xbps.
- Changed some members in xbps_handle struct, mostly to make it easy
  to change its value in {cache,root}dir and conffile.
- Made xbps_init() release proplib objects as soon as we don't need
  them, that way it uses 35% less of memory or in some cases even more.

There will be another commit that will implement to read new virtualpkg
settings by the user, as specified in:

	http://code.google.com/p/xbps/issues/detail?id=12
2011-10-17 12:37:15 +02:00
Juan RP
0f0c66fafb xbps_dictionary_from_metadata_plist: if pkgname not found try from a
virtual pkg.
2011-10-16 10:27:02 +02:00
Juan RP
508f119bc9 Moved install transaction code to libxbps, see NEWS file. 2011-07-27 17:13:54 +02:00
Juan RP
ce0b21a062 xbps_dictionary_from_metadata_plist: fix this with empty regpkgdb.plist.
If regpkgdb wasn't initialized it failed to properly internalize the
dictionary from the plist file.
2011-07-27 11:23:25 +02:00
Juan RP
e26b6e23e6 xbps-bin(8): make 'show{,-deps,-revdeps}' target work with virtual pkgs. 2011-07-25 16:40:34 +02:00
Juan RP
9673c4bd09 XBPS major changes in June 2011.
- A configuration file "xbps-conf.plist" replaces the (un)register target
  in xbps-repo(8) and (un)set-prop in xbps-bin(8). For now, you can set
  the repositories and prefered virtual packages.

- New package pattern matching code from NetBSD. Supports more ways of
  matching patterns in packages.

- Multiple bugs fixed in virtual packages related matching code.

--HG--
rename : LICENSE => COPYING
2011-06-04 13:37:53 +02:00
Juan RP
841c9e2d51 API/ABI break for June 2011.
Rename some functions to reflect its description a bit better.

--HG--
rename : lib/repository_plist.c => lib/plist_fetch.c
2011-06-01 09:37:32 +02:00
Juan RP
870ad18d58 xbps_init() now sets rootdir, cachedir and flags.
That means that the following functions were removed:
	- xbps_set_{cachedir,flags,rootdir}.
	- xbps_get_{cachedir,flags,rootdir}.

With this change fixed an obvious typo that made -c argument to not work,
and now the cache directory is an absolute path not relative to rootdir.
2011-02-21 17:42:47 +01:00
Juan RP
8803bfd7d8 Move plist find/remove functions into its own files. 2011-02-05 12:06:03 +01:00