summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoerg <joerg>2011-11-27 19:53:30 +0000
committerjoerg <joerg>2011-11-27 19:53:30 +0000
commit35e2f58907427443ae629d67fc504646874574d9 (patch)
treeb460c560e2c61bcdbb0e8e88ef5e40f5ab825e6d
parentc372c1c9e4673e6f2ea54efef1f29acd02a49992 (diff)
downloadpkgsrc-35e2f58907427443ae629d67fc504646874574d9.tar.gz
pbulk-base-0.44: Fix hash function to actually do proper hashing.
Do some further tweaking to improve matching by storing string size. While here, add the necessary .WAIT to allow parallel builds.
-rw-r--r--pkgtools/pbulk-base/Makefile4
-rw-r--r--pkgtools/pbulk/Makefile.common3
-rw-r--r--pkgtools/pbulk/files/pbulk/Makefile4
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/jobs.c50
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/pbuild.h3
5 files changed, 37 insertions, 27 deletions
diff --git a/pkgtools/pbulk-base/Makefile b/pkgtools/pbulk-base/Makefile
index cc233f6cb13..102b71cbaa6 100644
--- a/pkgtools/pbulk-base/Makefile
+++ b/pkgtools/pbulk-base/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.6 2011/09/21 11:55:15 joerg Exp $
+# $NetBSD: Makefile,v 1.7 2011/11/27 19:53:30 joerg Exp $
-DISTNAME= pbulk-base-0.43
+DISTNAME= pbulk-base-0.44
COMMENT= Core components of the modular bulk build framework
PKG_DESTDIR_SUPPORT= user-destdir
diff --git a/pkgtools/pbulk/Makefile.common b/pkgtools/pbulk/Makefile.common
index 071f4d437d6..e15976ae6bc 100644
--- a/pkgtools/pbulk/Makefile.common
+++ b/pkgtools/pbulk/Makefile.common
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.common,v 1.1 2009/06/08 15:37:50 joerg Exp $
+# $NetBSD: Makefile.common,v 1.2 2011/11/27 19:53:30 joerg Exp $
CATEGORIES= pkgtools
MASTER_SITES= # empty
@@ -10,4 +10,3 @@ HOMEPAGE= ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/doc/pkgsrc.html
FILESDIR= ${.CURDIR}/../../pkgtools/pbulk/files
WRKSRC= ${WRKDIR}/pbulk
-MAKE_JOBS_SAFE= no
diff --git a/pkgtools/pbulk/files/pbulk/Makefile b/pkgtools/pbulk/files/pbulk/Makefile
index 5e86689bdd6..91be992fc60 100644
--- a/pkgtools/pbulk/files/pbulk/Makefile
+++ b/pkgtools/pbulk/files/pbulk/Makefile
@@ -1,5 +1,5 @@
-# $NetBSD: Makefile,v 1.1.1.1 2007/06/19 19:49:55 joerg Exp $
+# $NetBSD: Makefile,v 1.2 2011/11/27 19:53:30 joerg Exp $
-SUBDIR= lib presolve pscan pbuild scripts
+SUBDIR= lib .WAIT presolve pscan pbuild scripts
.include <bsd.subdir.mk>
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/jobs.c b/pkgtools/pbulk/files/pbulk/pbuild/jobs.c
index 324bbc7a381..596894b1961 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/jobs.c
+++ b/pkgtools/pbulk/files/pbulk/pbuild/jobs.c
@@ -1,7 +1,7 @@
-/* $NetBSD: jobs.c,v 1.12 2010/05/05 00:07:07 joerg Exp $ */
+/* $NetBSD: jobs.c,v 1.13 2011/11/27 19:53:30 joerg Exp $ */
/*-
- * Copyright (c) 2007, 2009 Joerg Sonnenberger <joerg@NetBSD.org>.
+ * Copyright (c) 2007, 2009, 2011 Joerg Sonnenberger <joerg@NetBSD.org>.
* All rights reserved.
*
* This code was developed as part of Google's Summer of Code 2007 program.
@@ -56,7 +56,7 @@ SLIST_HEAD(buildhash, build_job);
static void build_tree(void);
static void mark_initial(void);
-static struct buildhash *get_hash_chain(const char *);
+static struct buildhash *get_hash_chain(const char *, size_t);
static void hash_entries(void);
static void add_to_build_list(struct build_job *);
@@ -109,22 +109,24 @@ find_content(struct build_job *job, const char *prefix)
return NULL;
}
-static char *
-pkgname_dup(const char *line)
+static int
+pkgname_dup(struct build_job *job, const char *line)
{
const char *pkgname;
char *pkgname_end;
size_t pkgname_len;
if (strncmp(line, "PKGNAME=", 8) != 0)
- return NULL;
+ return 0;
pkgname = line + 8;
pkgname_end = strchr(pkgname, '\n');
pkgname_len = pkgname_end - pkgname;
if (pkgname_end == NULL || pkgname_len < 4 ||
strcspn(pkgname, " \t\n") != pkgname_len)
- return NULL;
- return xstrndup(pkgname, pkgname_len);
+ return 0;
+ job->pkgname = xstrndup(pkgname, pkgname_len);
+ job->pkgname_len = pkgname_len;
+ return 1;
}
static const char *
@@ -215,7 +217,7 @@ init_jobs(const char *scan_output, const char *success_file, const char *error_f
}
input_iter = input;
- while ((jobs[len_jobs].pkgname = pkgname_dup(input_iter)) != NULL) {
+ while (pkgname_dup(&jobs[len_jobs], input_iter)) {
jobs[len_jobs].begin = input_iter;
jobs[len_jobs].end = pbulk_item_end(input_iter);
jobs[len_jobs].state = JOB_INIT;
@@ -262,9 +264,9 @@ mark_initial_state(int fd, enum job_state state, const char *type)
while (*input_iter != '\0') {
len = strcspn(input_iter, "\n");
- SLIST_FOREACH(iter, get_hash_chain(input_iter), hash_link) {
- if (strncmp(iter->pkgname, input_iter, len) == 0 &&
- iter->pkgname[len] == '\0')
+ SLIST_FOREACH(iter, get_hash_chain(input_iter, len), hash_link) {
+ if (iter->pkgname_len == len &&
+ strncmp(iter->pkgname, input_iter, len) == 0)
break;
}
if (iter == NULL)
@@ -274,7 +276,7 @@ mark_initial_state(int fd, enum job_state state, const char *type)
input_iter = strchr(input_iter, '\n');
if (input_iter == NULL)
- errx(1, "Invalid input");
+ errx(1, "Invalid input");
++input_iter;
}
free(input);
@@ -340,9 +342,9 @@ build_tree(void)
depends += strspn(depends, " \t");
while ((len = strcspn(depends, " \t\n")) != 0) {
- SLIST_FOREACH(iter, get_hash_chain(depends), hash_link) {
- if (strncmp(iter->pkgname, depends, len) == 0 &&
- iter->pkgname[len] == '\0')
+ SLIST_FOREACH(iter, get_hash_chain(depends, len), hash_link) {
+ if (iter->pkgname_len == len &&
+ strncmp(iter->pkgname, depends, len) == 0)
break;
}
if (iter == NULL)
@@ -530,7 +532,15 @@ finish_build(const char *report_file)
}
#define HASH_SIZE 4096
-#define HASH_ITEM(x) (((unsigned char)(x)[0] + (unsigned char)(x)[1] * 257 + (unsigned char)(x)[1] * 65537) & (HASH_SIZE - 1))
+
+static size_t
+hash_item(const char *s, size_t len)
+{
+ size_t h = 5381;
+ while (len--)
+ h = h * 33 + *s++;
+ return h & (HASH_SIZE - 1);
+}
static struct buildhash hash_table[HASH_SIZE];
@@ -543,13 +553,13 @@ hash_entries(void)
SLIST_INIT(&hash_table[i]);
for (i = 0; i < len_jobs; ++i) {
- hash = HASH_ITEM(jobs[i].pkgname);
+ hash = hash_item(jobs[i].pkgname, jobs[i].pkgname_len);
SLIST_INSERT_HEAD(&hash_table[hash], &jobs[i], hash_link);
}
}
static struct buildhash *
-get_hash_chain(const char *pkgname)
+get_hash_chain(const char *pkgname, size_t len)
{
- return &hash_table[HASH_ITEM(pkgname)];
+ return &hash_table[hash_item(pkgname, len)];
}
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h
index 2a9b2724121..052e884b4d2 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h
+++ b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pbuild.h,v 1.5 2008/09/14 18:59:02 joerg Exp $ */
+/* $NetBSD: pbuild.h,v 1.6 2011/11/27 19:53:30 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -82,6 +82,7 @@ struct dependency_list {
struct build_job {
/** The package name, including the version number. */
char *pkgname;
+ size_t pkgname_len;
/**
* Pointers into the output from pbulk-resolve. The lines