Author: mlschroe
Date: Thu Oct 30 11:49:56 2008
New Revision: 11545
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11545&view=rev
Log:
- adapt to coding style
- log solver execution time
- replace some fprintf calls with sat_debug
Modified:
trunk/sat-solver/package/libsatsolver.spec.in
trunk/sat-solver/src/pool.c
trunk/sat-solver/src/poolid.c
trunk/sat-solver/src/repo.h
trunk/sat-solver/src/repo_helix.c
trunk/sat-solver/src/repo_solv.c
trunk/sat-solver/src/repodata.h
trunk/sat-solver/src/repopage.c
trunk/sat-solver/src/solver.c
trunk/sat-solver/src/strpool.c
trunk/sat-solver/src/util.c
trunk/sat-solver/src/util.h
trunk/sat-solver/tools/repo_content.c
trunk/sat-solver/tools/repo_deltainfoxml.c
trunk/sat-solver/tools/repo_products.c
trunk/sat-solver/tools/repo_susetags.c
Modified: trunk/sat-solver/package/libsatsolver.spec.in
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/package/libsatsolver.spec.in?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/package/libsatsolver.spec.in (original)
+++ trunk/sat-solver/package/libsatsolver.spec.in Thu Oct 30 11:49:56 2008
@@ -144,6 +144,11 @@
#%doc swig/python/examples/*.py
%{py_sitedir}/_satsolver.so
%{py_sitedir}/satsolver.py
+#see http://fedoraproject.org/wiki/Packaging/Python
+%if 0%{?fedora_version}
+%exclude %{py_sitedir}/satsolver.pyc
+%exclude %{py_sitedir}/satsolver.pyo
+%endif
%files -n perl-satsolver
%defattr(-,root,root,-)
Modified: trunk/sat-solver/src/pool.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.c (original)
+++ trunk/sat-solver/src/pool.c Thu Oct 30 11:49:56 2008
@@ -261,7 +261,9 @@
Offset *whatprovides;
Id *whatprovidesdata, *d;
Repo *installed = pool->installed;
+ unsigned int now;
+ now = sat_timems(0);
POOL_DEBUG(SAT_DEBUG_STATS, "number of solvables: %d\n", pool->nsolvables);
POOL_DEBUG(SAT_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
@@ -354,6 +356,7 @@
pool->whatprovidesdataoff = off;
pool->whatprovidesdataleft = extra;
pool_shrink_whatprovides(pool);
+ POOL_DEBUG(SAT_DEBUG_STATS, "createwhatprovides took %d ms\n", sat_timems(now));
}
/*
Modified: trunk/sat-solver/src/poolid.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/poolid.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/poolid.c (original)
+++ trunk/sat-solver/src/poolid.c Thu Oct 30 11:49:56 2008
@@ -27,7 +27,7 @@
str2id(Pool *pool, const char *str, int create)
{
int oldnstrings = pool->ss.nstrings;
- Id id = stringpool_str2id (&pool->ss, str, create);
+ Id id = stringpool_str2id(&pool->ss, str, create);
if (create && pool->whatprovides && oldnstrings != pool->ss.nstrings && (id & WHATPROVIDES_BLOCK) == 0)
{
/* grow whatprovides array */
@@ -41,7 +41,7 @@
strn2id(Pool *pool, const char *str, unsigned int len, int create)
{
int oldnstrings = pool->ss.nstrings;
- Id id = stringpool_strn2id (&pool->ss, str, len, create);
+ Id id = stringpool_strn2id(&pool->ss, str, len, create);
if (create && pool->whatprovides && oldnstrings != pool->ss.nstrings && (id & WHATPROVIDES_BLOCK) == 0)
{
/* grow whatprovides array */
Modified: trunk/sat-solver/src/repo.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.h?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/repo.h (original)
+++ trunk/sat-solver/src/repo.h Thu Oct 30 11:49:56 2008
@@ -17,17 +17,6 @@
#include "pool.h"
#include "repodata.h"
-typedef struct _Repokey {
- Id name;
- Id type; /* REPOKEY_TYPE_xxx */
- unsigned int size;
- unsigned int storage; /* KEY_STORAGE_xxx */
-} Repokey;
-
-#define KEY_STORAGE_DROPPED 0
-#define KEY_STORAGE_SOLVABLE 1
-#define KEY_STORAGE_INCORE 2
-#define KEY_STORAGE_VERTICAL_OFFSET 3
typedef struct _Repo {
@@ -197,31 +186,6 @@
int repo_lookup_void(Repo *repo, Id entry, Id keyid);
const unsigned char *repo_lookup_bin_checksum(Repo *repo, Id entry, Id keyid, Id *typep);
-
-#if 0
-typedef struct _Dataiterator
-{
- Repodata *data;
- Id *keyp;
- unsigned char *nextkeydp;
- unsigned char *dp;
- Repokey *key;
- Repo *repo;
- Id *idp;
- const char *match;
- Id solvid;
- Id keyname;
- unsigned flags;
- unsigned state;
- KeyValue kv;
- regex_t regex;
- int regex_err;
- Id *subkeyp;
- int subnum;
- Id subschema;
-} Dataiterator;
-#else
-
typedef struct _Datamatcher {
int flags;
void *match;
@@ -268,8 +232,6 @@
} Dataiterator;
-#endif
-
int datamatcher_init(Datamatcher *ma, const char *match, int flags);
void datamatcher_free(Datamatcher *ma);
int datamatcher_match(Datamatcher *ma, const char *str);
Modified: trunk/sat-solver/src/repo_helix.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_helix.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/repo_helix.c (original)
+++ trunk/sat-solver/src/repo_helix.c Thu Oct 30 11:49:56 2008
@@ -860,7 +860,7 @@
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- fprintf(stderr, "%s at line %u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser));
+ pool_debug(pool, SAT_FATAL, "%s at line %u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser));
exit(1);
}
if (l == 0)
Modified: trunk/sat-solver/src/repo_solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_solv.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/repo_solv.c (original)
+++ trunk/sat-solver/src/repo_solv.c Thu Oct 30 11:49:56 2008
@@ -955,10 +955,10 @@
schemadatap = read_idarray(&data, numid, 0, schemadatap, schemadataend);
#if 0
Id *sp = schemadata + schemata[i];
- fprintf (stderr, "schema %d:", i);
+ fprintf(stderr, "schema %d:", i);
for (; *sp; sp++)
- fprintf (stderr, " %d", *sp);
- fprintf (stderr, "\n");
+ fprintf(stderr, " %d", *sp);
+ fprintf(stderr, "\n");
#endif
}
data.schemata = schemata;
Modified: trunk/sat-solver/src/repodata.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repodata.h?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/repodata.h (original)
+++ trunk/sat-solver/src/repodata.h Thu Oct 30 11:49:56 2008
@@ -25,9 +25,21 @@
#define SIZEOF_SHA256 32
struct _Repo;
-struct _Repokey;
struct _KeyValue;
+typedef struct _Repokey {
+ Id name;
+ Id type; /* REPOKEY_TYPE_xxx */
+ unsigned int size;
+ unsigned int storage; /* KEY_STORAGE_xxx */
+} Repokey;
+
+#define KEY_STORAGE_DROPPED 0
+#define KEY_STORAGE_SOLVABLE 1
+#define KEY_STORAGE_INCORE 2
+#define KEY_STORAGE_VERTICAL_OFFSET 3
+
+
typedef struct _Repodata {
struct _Repo *repo; /* back pointer to repo */
@@ -45,8 +57,7 @@
FILE *fp; /* file pointer of solv file */
int error; /* corrupt solv file */
-
- struct _Repokey *keys; /* keys, first entry is always zero */
+ Repokey *keys; /* keys, first entry is always zero */
unsigned int nkeys; /* length of keys array */
unsigned char keybits[32]; /* keyname hash */
@@ -61,33 +72,33 @@
Dirpool dirpool; /* local dir pool */
- Id mainschema;
- Id *mainschemaoffsets;
-
- unsigned char *incoredata; /* in-core data (flat_attrs) */
- unsigned int incoredatalen; /* data len (attr_next_free) */
+ unsigned char *incoredata; /* in-core data */
+ unsigned int incoredatalen; /* in-core data used */
unsigned int incoredatafree; /* free data len */
- Id *incoreoffset; /* offset for all entries (ent2attr) */
+ Id mainschema; /* SOLVID_META schema */
+ Id *mainschemaoffsets; /* SOLVID_META offsets into incoredata */
+
+ Id *incoreoffset; /* offset for all entries */
Id *verticaloffset; /* offset for all verticals, nkeys elements */
Id lastverticaloffset; /* end of verticals */
Repopagestore store; /* our page store */
- unsigned char *vincore;
- unsigned int vincorelen;
+ unsigned char *vincore; /* internal vertical data */
+ unsigned int vincorelen; /* data size */
Id **attrs; /* un-internalized attributes */
Id **xattrs; /* anonymous handles */
- int nxattrs;
+ int nxattrs; /* number of handles */
unsigned char *attrdata; /* their string data space */
- unsigned int attrdatalen;
+ unsigned int attrdatalen; /* its len */
Id *attriddata; /* their id space */
- unsigned int attriddatalen;
+ unsigned int attriddatalen; /* its len */
- /* array cache */
+ /* array cache to speed up repodata_add functions*/
Id lasthandle;
Id lastkey;
Id lastdatalen;
@@ -98,20 +109,40 @@
#define SOLVID_POS -2
#define SOLVID_SUBSCHEMA -3 /* internal! */
+
/*-----
* management functions
*/
void repodata_init(Repodata *data, struct _Repo *repo, int localpool);
-void repodata_extend(Repodata *data, Id p);
-void repodata_extend_block(Repodata *data, Id p, int num);
void repodata_free(Repodata *data);
-/* internalize repodata into .solv, required before writing out a .solv file */
-void repodata_internalize(Repodata *data);
-Id repodata_key2id(Repodata *data, struct _Repokey *key, int create);
+/*
+ * key management functions
+ */
+Id repodata_key2id(Repodata *data, Repokey *key, int create);
+static inline Repokey *
+repodata_id2key(Repodata *data, Id keyid)
+{
+ return data->keys + keyid;
+}
+
+/*
+ * schema management functions
+ */
Id repodata_schema2id(Repodata *data, Id *schema, int create);
+static inline Id *
+repodata_id2schema(Repodata *data, Id schemaid)
+{
+ return data->schemadata + data->schemata[schemaid];
+}
+
+/*
+ * data search and access
+ */
+/* check if there is a chance that the repodata contains data for
+ * the specified keyname */
static inline int
repodata_precheck_keyname(Repodata *data, Id keyname)
{
@@ -119,15 +150,13 @@
return x && (x & (1 << (keyname & 7))) ? 1 : 0;
}
-/*----
- * access functions
- */
-
-/* Search key <keyname> (all keys, if keyname == 0) for Id <solvid>
- * Call <callback> for each match
- */
-void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, struct _Repokey *key, struct _KeyValue *kv), void *cbdata);
-int repodata_stringify(Pool *pool, Repodata *data, struct _Repokey *key, struct _KeyValue *kv, int flags);
+/* search key <keyname> (all keys, if keyname == 0) for Id <solvid>
+ * Call <callback> for each match */
+void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct _KeyValue *kv), void *cbdata);
+
+/* Make sure the found KeyValue has the "str" field set. Return false
+ * if not possible */
+int repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags);
/* lookup functions */
@@ -138,23 +167,32 @@
const unsigned char *repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep);
+
/*-----
* data assignment functions
*/
+/*
+ * extend the data so that it contains the specified solvables
+ * (no longer needed, as the repodata_set functions autoextend)
+ */
+void repodata_extend(Repodata *data, Id p);
+void repodata_extend_block(Repodata *data, Id p, int num);
+
+/* internalize freshly set data, so that it is found by the search
+ * functions and written out */
+void repodata_internalize(Repodata *data);
+
/* create an anonymous handle. useful for substructures like
* fixarray/flexarray */
Id repodata_new_handle(Repodata *data);
/* basic types: void, num, string, Id */
-
void repodata_set_void(Repodata *data, Id solvid, Id keyname);
void repodata_set_num(Repodata *data, Id solvid, Id keyname, unsigned int num);
-void repodata_set_str(Repodata *data, Id solvid, Id keyname, const char *str);
void repodata_set_id(Repodata *data, Id solvid, Id keyname, Id id);
-
-/* */
-
+void repodata_set_str(Repodata *data, Id solvid, Id keyname, const char *str);
+/* create id from string, then set_id */
void repodata_set_poolstr(Repodata *data, Id solvid, Id keyname, const char *str);
/* set numeric constant */
@@ -180,18 +218,15 @@
void repodata_add_fixarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
void repodata_add_flexarray(Repodata *data, Id solvid, Id keyname, Id ghandle);
-
-/*-----
- * data management
- */
-
/*
- merge attributes fro one solvable to another
+ merge attributes from one solvable to another
works only if the data is not yet internalized
*/
-void repodata_merge_attrs (Repodata *data, Id dest, Id src);
+void repodata_merge_attrs(Repodata *data, Id dest, Id src);
-/* */
+/*
+ * load all paged data, used to speed up copying in repo_rpmdb
+ */
void repodata_disable_paging(Repodata *data);
/* helper functions */
Modified: trunk/sat-solver/src/repopage.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repopage.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/repopage.c (original)
+++ trunk/sat-solver/src/repopage.c Thu Oct 30 11:49:56 2008
@@ -88,8 +88,8 @@
#define HS (65536)
Ref htab[HS];
Ref hnext[BLOCK_SIZE];
- memset (htab, -1, sizeof (htab));
- memset (hnext, -1, sizeof (hnext));
+ memset(htab, -1, sizeof (htab));
+ memset(hnext, -1, sizeof (hnext));
unsigned int litofs = 0;
while (io + 2 < in_len)
{
@@ -118,8 +118,8 @@
}
for (; try != -1 && tries < 12; tries++)
{
- //assert (mlen >= 2);
- //assert (io + mlen < in_len);
+ //assert(mlen >= 2);
+ //assert(io + mlen < in_len);
/* Try a match starting from [io] with the strings at [try].
That's only sensible if TRY actually is before IO (can happen
with uninit hash table). If we have a previous match already
@@ -128,7 +128,7 @@
if (try < io && in[try + mlen] == in[io + mlen])
{
unsigned int this_len, this_ofs;
- if (memcmp (in + try, in + io, mlen))
+ if (memcmp(in + try, in + io, mlen))
goto no_match;
this_len = mlen + 1;
/* Now try extending the match by more characters. */
@@ -139,15 +139,15 @@
#if 0
unsigned int testi;
for (testi = 0; testi < this_len; testi++)
- assert (in[try + testi] == in[io + testi]);
+ assert(in[try + testi] == in[io + testi]);
#endif
this_ofs = (io - try) - 1;
/*if (this_ofs > 65535)
goto no_match; */
#if 0
- assert (this_len >= 2);
- assert (this_len >= mlen);
- assert (this_len > mlen || (this_len == mlen && this_ofs > mofs));
+ assert(this_len >= 2);
+ assert(this_len >= mlen);
+ assert(this_len > mlen || (this_len == mlen && this_ofs > mofs));
#endif
mlen = this_len, mofs = this_ofs;
/* If our match extends up to the end of input, no next
@@ -166,7 +166,7 @@
match_done:
if (mlen)
{
- //fprintf (stderr, "%d %d\n", mlen, mofs);
+ /*fprintf(stderr, "%d %d\n", mlen, mofs);*/
if (mlen == 2 && (litofs || mofs >= 1024))
mlen = 0;
/*else if (mofs >= 65536)
@@ -223,7 +223,7 @@
{
litofs--;
unsigned litlen = io - litofs;
- //fprintf (stderr, "lit: %d\n", litlen);
+ //fprintf(stderr, "lit: %d\n", litlen);
while (litlen)
{
unsigned int easy_sz;
@@ -239,7 +239,7 @@
{
if (oo + easy_sz >= out_len)
return 0;
- memcpy (out + oo, in + litofs, easy_sz);
+ memcpy(out + oo, in + litofs, easy_sz);
litofs += easy_sz;
oo += easy_sz;
litlen -= easy_sz;
@@ -261,7 +261,7 @@
if (oo + 1 + 32 >= out_len)
return 0;
out[oo++] = 0x80 | 31;
- memcpy (out + oo, in + litofs, 32);
+ memcpy(out + oo, in + litofs, 32);
oo += 32;
litofs += 32;
litlen -= 32;
@@ -270,7 +270,7 @@
litofs = 0;
}
- //fprintf (stderr, "ref: %d @ %d\n", mlen, mofs);
+ //fprintf(stderr, "ref: %d @ %d\n", mlen, mofs);
if (mlen >= 2 && mlen <= 9 && mofs < 1024)
{
@@ -288,7 +288,7 @@
}
else if (mofs >= 65536)
{
- assert (mlen >= 5 && mlen < 2048 + 5);
+ assert(mlen >= 5 && mlen < 2048 + 5);
if (oo + 5 >= out_len)
return 0;
out[oo++] = 0xf8 | ((mlen - 5) >> 8);
@@ -299,7 +299,7 @@
}
else if (mlen >= 3 && mlen <= 18)
{
- assert (mofs < 65536);
+ assert(mofs < 65536);
if (oo + 3 >= out_len)
return 0;
out[oo++] = 0xe0 | (mlen - 3);
@@ -308,7 +308,7 @@
}
else
{
- assert (mlen >= 19 && mlen <= 4095 + 19 && mofs < 65536);
+ assert(mlen >= 19 && mlen <= 4095 + 19 && mofs < 65536);
if (oo + 4 >= out_len)
return 0;
out[oo++] = 0xf0 | ((mlen - 19) >> 8);
@@ -346,7 +346,7 @@
{
litofs--;
unsigned litlen = io - litofs;
- //fprintf (stderr, "lit: %d\n", litlen);
+ //fprintf(stderr, "lit: %d\n", litlen);
while (litlen)
{
unsigned int easy_sz;
@@ -361,7 +361,7 @@
{
if (oo + easy_sz >= out_len)
return 0;
- memcpy (out + oo, in + litofs, easy_sz);
+ memcpy(out + oo, in + litofs, easy_sz);
litofs += easy_sz;
oo += easy_sz;
litlen -= easy_sz;
@@ -383,7 +383,7 @@
if (oo + 1 + 32 >= out_len)
return 0;
out[oo++] = 0x80 | 31;
- memcpy (out + oo, in + litofs, 32);
+ memcpy(out + oo, in + litofs, 32);
oo += 32;
litofs += 32;
litlen -= 32;
@@ -476,7 +476,7 @@
break;
}
}
- //fprintf (stderr, "ref: %d @ %d\n", first, o);
+ //fprintf(stderr, "ref: %d @ %d\n", first, o);
o++;
o = -o;
#if 0
@@ -591,10 +591,10 @@
if (store->ncanmap < 4)
store->ncanmap = 4;
store->mapped = sat_realloc2(store->mapped, store->ncanmap, sizeof(store->mapped[0]));
- memset (store->mapped + oldcan, 0, (store->ncanmap - oldcan) * sizeof (store->mapped[0]));
+ memset(store->mapped + oldcan, 0, (store->ncanmap - oldcan) * sizeof (store->mapped[0]));
store->blob_store = sat_realloc2(store->blob_store, store->ncanmap, BLOB_PAGESIZE);
#ifdef DEBUG_PAGING
- fprintf (stderr, "PAGE: can map %d pages\n", store->ncanmap);
+ fprintf(stderr, "PAGE: can map %d pages\n", store->ncanmap);
#endif
}
@@ -612,7 +612,7 @@
{
pnum--;
Attrblobpage *p = store->pages + pnum;
- assert (p->mapped_at != -1);
+ assert(p->mapped_at != -1);
if (pnum >= pstart && pnum <= pend)
cost[i] = 1;
else
@@ -658,7 +658,7 @@
{
/* Evict this page. */
#ifdef DEBUG_PAGING
- fprintf (stderr, "PAGE: evict page %d from %d\n", pnum, i);
+ fprintf(stderr, "PAGE: evict page %d from %d\n", pnum, i);
#endif
cost[i] = 0;
store->mapped[i] = 0;
@@ -677,10 +677,10 @@
if (p->mapped_at != pnum * BLOB_PAGESIZE)
{
#ifdef DEBUG_PAGING
- fprintf (stderr, "PAGECOPY: %d to %d\n", i, pnum);
+ fprintf(stderr, "PAGECOPY: %d to %d\n", i, pnum);
#endif
/* Still mapped somewhere else, so just copy it from there. */
- memcpy (dest, store->blob_store + p->mapped_at, BLOB_PAGESIZE);
+ memcpy(dest, store->blob_store + p->mapped_at, BLOB_PAGESIZE);
store->mapped[p->mapped_at / BLOB_PAGESIZE] = 0;
}
}
@@ -690,11 +690,11 @@
unsigned int compressed = in_len & 1;
in_len >>= 1;
#ifdef DEBUG_PAGING
- fprintf (stderr, "PAGEIN: %d to %d", i, pnum);
+ fprintf(stderr, "PAGEIN: %d to %d", i, pnum);
#endif
if (pread(store->pagefd, compressed ? buf : dest, in_len, p->file_offset) != in_len)
{
- perror ("mapping pread");
+ perror("mapping pread");
return 0;
}
if (compressed)
@@ -710,11 +710,11 @@
return 0;
}
#ifdef DEBUG_PAGING
- fprintf (stderr, " (expand %d to %d)", in_len, out_len);
+ fprintf(stderr, " (expand %d to %d)", in_len, out_len);
#endif
}
#ifdef DEBUG_PAGING
- fprintf (stderr, "\n");
+ fprintf(stderr, "\n");
#endif
}
p->mapped_at = pnum * BLOB_PAGESIZE;
@@ -775,7 +775,7 @@
can_seek = 0;
#ifdef DEBUG_PAGING
- fprintf (stderr, "can %sseek\n", can_seek ? "" : "NOT ");
+ fprintf(stderr, "can %sseek\n", can_seek ? "" : "NOT ");
#endif
npages = (blobsz + BLOB_PAGESIZE - 1) / BLOB_PAGESIZE;
@@ -792,7 +792,7 @@
Attrblobpage *p = store->pages + i;
in_len >>= 1;
#ifdef DEBUG_PAGING
- fprintf (stderr, "page %d: len %d (%scompressed)\n",
+ fprintf(stderr, "page %d: len %d (%scompressed)\n",
i, in_len, compressed ? "" : "not ");
#endif
if (can_seek)
@@ -847,7 +847,7 @@
#ifdef STANDALONE
static void
-transfer_file (FILE * from, FILE * to, int compress)
+transfer_file(FILE * from, FILE * to, int compress)
{
unsigned char inb[BLOCK_SIZE];
unsigned char outb[BLOCK_SIZE];
@@ -856,45 +856,45 @@
unsigned int in_len, out_len;
if (compress)
{
- in_len = fread (inb, 1, BLOCK_SIZE, from);
+ in_len = fread(inb, 1, BLOCK_SIZE, from);
if (in_len)
{
unsigned char *b = outb;
- out_len = compress_buf (inb, in_len, outb, sizeof (outb));
+ out_len = compress_buf(inb, in_len, outb, sizeof (outb));
if (!out_len)
b = inb, out_len = in_len;
- if (fwrite (&out_len, sizeof (out_len), 1, to) != 1)
+ if (fwrite(&out_len, sizeof (out_len), 1, to) != 1)
{
- perror ("write size");
+ perror("write size");
exit (1);
}
- if (fwrite (b, out_len, 1, to) != 1)
+ if (fwrite(b, out_len, 1, to) != 1)
{
- perror ("write data");
+ perror("write data");
exit (1);
}
}
}
else
{
- if (fread (&in_len, sizeof (in_len), 1, from) != 1)
+ if (fread(&in_len, sizeof(in_len), 1, from) != 1)
{
- if (feof (from))
+ if (feof(from))
return;
- perror ("can't read size");
- exit (1);
+ perror("can't read size");
+ exit(1);
}
- if (fread (inb, in_len, 1, from) != 1)
+ if (fread(inb, in_len, 1, from) != 1)
{
- perror ("can't read data");
- exit (1);
+ perror("can't read data");
+ exit(1);
}
out_len =
- unchecked_decompress_buf (inb, in_len, outb, sizeof (outb));
- if (fwrite (outb, out_len, 1, to) != 1)
+ unchecked_decompress_buf(inb, in_len, outb, sizeof(outb));
+ if (fwrite(outb, out_len, 1, to) != 1)
{
- perror ("can't write output");
- exit (1);
+ perror("can't write output");
+ exit(1);
}
}
}
@@ -902,7 +902,7 @@
/* Just for benchmarking purposes. */
static void
-dumb_memcpy (void *dest, const void *src, unsigned int len)
+dumb_memcpy(void *dest, const void *src, unsigned int len)
{
char *d = dest;
const char *s = src;
@@ -911,16 +911,16 @@
}
static void
-benchmark (FILE * from)
+benchmark(FILE * from)
{
unsigned char inb[BLOCK_SIZE];
unsigned char outb[BLOCK_SIZE];
- unsigned int in_len = fread (inb, 1, BLOCK_SIZE, from);
+ unsigned int in_len = fread(inb, 1, BLOCK_SIZE, from);
unsigned int out_len;
if (!in_len)
{
- perror ("can't read from input");
- exit (1);
+ perror("can't read from input");
+ exit(1);
}
unsigned int calib_loop;
@@ -932,71 +932,71 @@
#if 0
calib_loop = 1;
per_loop = 0;
- start = clock ();
- while ((clock () - start) < CLOCKS_PER_SEC / 4)
+ start = clock();
+ while ((clock() - start) < CLOCKS_PER_SEC / 4)
{
calib_loop *= 2;
for (i = 0; i < calib_loop; i++)
- dumb_memcpy (outb, inb, in_len);
+ dumb_memcpy(outb, inb, in_len);
per_loop += calib_loop;
}
- fprintf (stderr, "memcpy:\nCalibrated to %d iterations per loop\n",
+ fprintf(stderr, "memcpy:\nCalibrated to %d iterations per loop\n",
per_loop);
- start = clock ();
+ start = clock();
for (i = 0; i < 10; i++)
for (j = 0; j < per_loop; j++)
- dumb_memcpy (outb, inb, in_len);
- end = clock ();
+ dumb_memcpy(outb, inb, in_len);
+ end = clock();
seconds = (end - start) / (float) CLOCKS_PER_SEC;
- fprintf (stderr, "%.2f seconds == %.2f MB/s\n", seconds,
+ fprintf(stderr, "%.2f seconds == %.2f MB/s\n", seconds,
((long long) in_len * per_loop * 10) / (1024 * 1024 * seconds));
#endif
calib_loop = 1;
per_loop = 0;
- start = clock ();
- while ((clock () - start) < CLOCKS_PER_SEC / 4)
+ start = clock();
+ while ((clock() - start) < CLOCKS_PER_SEC / 4)
{
calib_loop *= 2;
for (i = 0; i < calib_loop; i++)
- compress_buf(inb, in_len, outb, sizeof (outb));
+ compress_buf(inb, in_len, outb, sizeof(outb));
per_loop += calib_loop;
}
fprintf(stderr, "compression:\nCalibrated to %d iterations per loop\n",
per_loop);
- start = clock ();
+ start = clock();
for (i = 0; i < 10; i++)
for (j = 0; j < per_loop; j++)
- compress_buf (inb, in_len, outb, sizeof (outb));
- end = clock ();
+ compress_buf(inb, in_len, outb, sizeof(outb));
+ end = clock();
seconds = (end - start) / (float) CLOCKS_PER_SEC;
fprintf(stderr, "%.2f seconds == %.2f MB/s\n", seconds,
((long long) in_len * per_loop * 10) / (1024 * 1024 * seconds));
- out_len = compress_buf(inb, in_len, outb, sizeof (outb));
+ out_len = compress_buf(inb, in_len, outb, sizeof(outb));
calib_loop = 1;
per_loop = 0;
- start = clock ();
- while ((clock () - start) < CLOCKS_PER_SEC / 4)
+ start = clock();
+ while ((clock() - start) < CLOCKS_PER_SEC / 4)
{
calib_loop *= 2;
for (i = 0; i < calib_loop; i++)
- unchecked_decompress_buf(outb, out_len, inb, sizeof (inb));
+ unchecked_decompress_buf(outb, out_len, inb, sizeof(inb));
per_loop += calib_loop;
}
fprintf(stderr, "decompression:\nCalibrated to %d iterations per loop\n",
per_loop);
- start = clock ();
+ start = clock();
for (i = 0; i < 10; i++)
for (j = 0; j < per_loop; j++)
- unchecked_decompress_buf(outb, out_len, inb, sizeof (inb));
+ unchecked_decompress_buf(outb, out_len, inb, sizeof(inb));
end = clock();
seconds = (end - start) / (float) CLOCKS_PER_SEC;
fprintf(stderr, "%.2f seconds == %.2f MB/s\n", seconds,
@@ -1004,15 +1004,15 @@
}
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
int compress = 1;
- if (argc > 1 && !strcmp (argv[1], "-d"))
+ if (argc > 1 && !strcmp(argv[1], "-d"))
compress = 0;
- if (argc > 1 && !strcmp (argv[1], "-b"))
- benchmark (stdin);
+ if (argc > 1 && !strcmp(argv[1], "-b"))
+ benchmark(stdin);
else
- transfer_file (stdin, stdout, compress);
+ transfer_file(stdin, stdout, compress);
return 0;
}
Modified: trunk/sat-solver/src/solver.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.c (original)
+++ trunk/sat-solver/src/solver.c Thu Oct 30 11:49:56 2008
@@ -3149,9 +3149,11 @@
Id *problem;
Id why;
int i, j, nsol;
+ unsigned int now, refnow;
if (!solv->problems.count)
return;
+ now = sat_timems(0);
problems_sort(solv);
queue_clone(&problems, &solv->problems);
queue_init(&solution);
@@ -3159,6 +3161,7 @@
/* copy over proof index */
queue_push(&solutions, problems.elements[0]);
problem = problems.elements + 1;
+ refnow = sat_timems(0);
for (i = 1; i < problems.count; i++)
{
Id v = problems.elements[i];
@@ -3167,12 +3170,14 @@
/* mark end of this problem */
queue_push(&solutions, 0);
queue_push(&solutions, 0);
+ POOL_DEBUG(SAT_DEBUG_STATS, "refining took %d ms\n", sat_timems(refnow));
if (i + 1 == problems.count)
break;
/* copy over proof of next problem */
queue_push(&solutions, problems.elements[i + 1]);
i++;
problem = problems.elements + i + 1;
+ refnow = sat_timems(0);
continue;
}
refine_suggestion(solv, job, problem, v, &solution);
@@ -3261,6 +3266,7 @@
assert(solv->problems.count == solutions.count);
queue_free(&solutions);
+ POOL_DEBUG(SAT_DEBUG_STATS, "problems_to_solutions took %d ms\n", sat_timems(now));
}
@@ -3922,7 +3928,9 @@
Solvable *s;
int goterase;
Rule *r;
+ int now, solve_start;
+ solve_start = sat_timems(0);
POOL_DEBUG(SAT_DEBUG_STATS, "solver started\n");
POOL_DEBUG(SAT_DEBUG_STATS, "fixsystem=%d updatesystem=%d dosplitprovides=%d, noupdateprovide=%d\n", solv->fixsystem, solv->updatesystem, solv->dosplitprovides, solv->noupdateprovide);
POOL_DEBUG(SAT_DEBUG_STATS, "distupgrade=%d distupgrade_removeunsupported=%d\n", solv->distupgrade, solv->distupgrade_removeunsupported);
@@ -3969,6 +3977,7 @@
queue_push(&solv->decisionq_why, 0);
solv->decisionmap[SYSTEMSOLVABLE] = 1; /* installed at level '1' */
+ now = sat_timems(0);
/*
* create rules for all package that could be involved with the solving
* so called: rpm rules
@@ -4056,6 +4065,7 @@
solv->directdecisions = solv->decisionq.count;
POOL_DEBUG(SAT_DEBUG_STATS, "decisions so far: %d\n", solv->decisionq.count);
+ POOL_DEBUG(SAT_DEBUG_STATS, "rpm rule creation took %d ms\n", sat_timems(now));
/*
* create feature rules
@@ -4341,7 +4351,9 @@
* ********************************************
*/
+ now = sat_timems(0);
run_solver(solv, 1, solv->dontinstallrecommended ? 0 : 1);
+ POOL_DEBUG(SAT_DEBUG_STATS, "solver took %d ms\n", sat_timems(now));
queue_init(&redoq);
goterase = 0;
@@ -4527,8 +4539,9 @@
solv->recommendations.count = recocount;
}
- POOL_DEBUG(SAT_DEBUG_STATS, "final solver statistics: %d learned rules, %d unsolvable\n", solv->stats_learned, solv->stats_unsolvable);
queue_free(&redoq);
+ POOL_DEBUG(SAT_DEBUG_STATS, "final solver statistics: %d learned rules, %d unsolvable\n", solv->stats_learned, solv->stats_unsolvable);
+ POOL_DEBUG(SAT_DEBUG_STATS, "solver_solve took %d ms\n", sat_timems(solve_start));
}
/***********************************************************************/
Modified: trunk/sat-solver/src/strpool.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/strpool.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/strpool.c (original)
+++ trunk/sat-solver/src/strpool.c Thu Oct 30 11:49:56 2008
@@ -70,7 +70,7 @@
}
Id
-stringpool_strn2id (Stringpool *ss, const char *str, unsigned len, int create)
+stringpool_strn2id(Stringpool *ss, const char *str, unsigned len, int create)
{
Hashval h;
unsigned int hh;
@@ -148,18 +148,18 @@
}
Id
-stringpool_str2id (Stringpool *ss, const char *str, int create)
+stringpool_str2id(Stringpool *ss, const char *str, int create)
{
- if ( !str )
+ if (!str)
return STRID_NULL;
- if ( !*str )
+ if (!*str)
return STRID_EMPTY;
- unsigned len = strlen (str);
- return stringpool_strn2id (ss, str, len, create);
+ unsigned len = strlen(str);
+ return stringpool_strn2id(ss, str, len, create);
}
void
-stringpool_shrink (Stringpool *ss)
+stringpool_shrink(Stringpool *ss)
{
ss->stringspace = sat_extend_resize(ss->stringspace, ss->sstrings, 1, STRINGSPACE_BLOCK);
ss->strings = sat_extend_resize(ss->strings, ss->nstrings, sizeof(Offset), STRING_BLOCK);
Modified: trunk/sat-solver/src/util.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/util.c?rev=11545&r1=11544&r2=11545&view=diff
==============================================================================
--- trunk/sat-solver/src/util.c (original)
+++ trunk/sat-solver/src/util.c Thu Oct 30 11:49:56 2008
@@ -9,6 +9,7 @@
#include