[pacman-dev] [PATCH 3/6] Only compile delta regex once

Allan McRae allan at archlinux.org
Sun Jan 1 23:49:23 EST 2012


On 01/01/12 13:07, Dan McGee wrote:
> This reduces the number of regcomp() calls when parsing delta entries in
> the database from once per entry to once for the entire context handle
> by storing the compiled regex data on the handle itself. Just as we do
> with the cURL handle, we initialize it the first time it is needed and
> free it when releasing the handle.
> 
> A few other small tweaks to the parsing function also take place,
> including using the stack to store the transient and short file size
> string while parsing it.
> 
> When parsing a sync database with 1378 delta entries, this reduces the
> time of a `pacman -Sl deltas` operation by 50% from 0.22s to 0.12s.
> 
> Signed-off-by: Dan McGee <dan at archlinux.org>
> ---
> 
> Test database, built from my local cache that was used for above numbers:
>     https://dev.archlinux.org/~dan/deltas.db
> 
> Should be useful for delta-related code in general.
> 
>  lib/libalpm/delta.c  |   33 +++++++++++++++++++--------------
>  lib/libalpm/delta.h  |    2 +-
>  lib/libalpm/handle.c |    3 +++
>  lib/libalpm/handle.h |    5 +++++
>  4 files changed, 28 insertions(+), 15 deletions(-)
> 
> diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
> index 165cdef..726f03c 100644
> --- a/lib/libalpm/delta.c
> +++ b/lib/libalpm/delta.c
> @@ -273,29 +273,32 @@ alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(alpm_pkg_t *pkg)
>   * This function assumes that the string is in the correct format.
>   * This format is as follows:
>   * $deltafile $deltamd5 $deltasize $oldfile $newfile
> + * @param handle the context handle
>   * @param line the string to parse
>   * @return A pointer to the new alpm_delta_t object
>   */
> -/* TODO this does not really belong here, but in a parsing lib */
> -alpm_delta_t *_alpm_delta_parse(char *line)
> +alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)


Changed function prototype so should also change the one usage of this
function in the codebase...

Fixup patch on my patchqueue branch.

Allan





More information about the pacman-dev mailing list