#%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,-)
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);
pool->whatprovidesdataoff = off;
pool->whatprovidesdataleft = extra;
pool_shrink_whatprovides(pool);
+ POOL_DEBUG(SAT_DEBUG_STATS, "createwhatprovides took %d ms\n", sat_timems(now));
}
/*
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 */
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 */
#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 {
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;
} 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);
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)
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;
#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 */
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 */
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;
#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)
{
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, Repokey *key, struct _KeyValue *kv), void *cbdata);
-/* 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);
+/* 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 */
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 */
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 */
#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)
{
}
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
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. */
#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
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)
{
litofs--;
unsigned litlen = io - litofs;
- //fprintf (stderr, "lit: %d\n", litlen);
+ //fprintf(stderr, "lit: %d\n", litlen);
while (litlen)
{
unsigned int easy_sz;
{
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;
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;
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)
{
}
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);
}
else if (mlen >= 3 && mlen <= 18)
{
- assert (mofs < 65536);
+ assert(mofs < 65536);
if (oo + 3 >= out_len)
return 0;
out[oo++] = 0xe0 | (mlen - 3);
}
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);
{
litofs--;
unsigned litlen = io - litofs;
- //fprintf (stderr, "lit: %d\n", litlen);
+ //fprintf(stderr, "lit: %d\n", litlen);
while (litlen)
{
unsigned int easy_sz;
{
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;
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;
break;
}
}
- //fprintf (stderr, "ref: %d @ %d\n", first, o);
+ //fprintf(stderr, "ref: %d @ %d\n", first, o);
o++;
o = -o;
#if 0
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
}
{
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
{
/* 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;
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;
}
}
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)
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;
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;
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)
#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];
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);
}
}
}
/* 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;
}
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;
#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,
}
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;
}
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);
/* 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];
/* 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);
assert(solv->problems.count == solutions.count);
queue_free(&solutions);
+ POOL_DEBUG(SAT_DEBUG_STATS, "problems_to_solutions took %d ms\n", sat_timems(now));
}
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);
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
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
* ********************************************
*/
+ 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;
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));
}
/***********************************************************************/
}
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;
}
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);
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <sys/time.h>
#include "util.h"
return 0;
}
+unsigned int
+sat_timems(unsigned int subtract)
+{
+ struct timeval tv;
+ unsigned int r;
+
+ if (gettimeofday(&tv, 0))
+ return 0;
+ r = (((unsigned int)tv.tv_sec >> 16) * 1000) << 16;
+ r += ((unsigned int)tv.tv_sec & 0xffff) * 1000;
+ r += (unsigned int)tv.tv_usec / 1000;
+ return r - subtract;
+}
+
extern void *sat_realloc2(void *, size_t, size_t);
extern void *sat_free(void *);
extern void sat_oom(size_t, size_t);
+extern unsigned int sat_timems(unsigned int subtract);
static inline void *sat_extend(void *buf, size_t len, size_t nmemb, size_t size, size_t block)
{
if (!rel || !evr)
{
- fprintf(stderr, "repo_content: bad relation '%s %s'\n", name, rel);
+ pool_debug(pool, SAT_FATAL, "repo_content: bad relation '%s %s'\n", name, rel);
exit(1);
}
for (flags = 0; flags < 6; flags++)
break;
if (flags == 6)
{
- fprintf(stderr, "repo_content: Unknown relation '%s'\n", rel);
+ pool_debug(pool, SAT_FATAL, "repo_content: unknown relation '%s'\n", rel);
exit(1);
}
id = rel2id(pool, id, str2id(pool, evr, 1), flags + 1, 1);
else if (code10 && istag ("CONTENTSTYLE"))
/* CONTENTSTYLE must be first line */
- fprintf(stderr, "repo_content: 'CONTENTSTYLE' must be first line of 'content'\n");
+ pool_debug(pool, SAT_ERROR, "repo_content: 'CONTENTSTYLE' must be first line of 'content'\n");
else if (code10 && istag ("DISTPRODUCT"))
/* DISTPRODUCT is for registration and Yast, not for the solver. */
repo_set_str(repo, s - pool->solvables, PRODUCT_DISTPRODUCT, value);
#undef istag
}
else
- fprintf (stderr, "repo_content: malformed line: %s\n", line);
+ pool_debug(pool, SAT_ERROR, "repo_content: malformed line: %s\n", line);
}
if (!s || !s->name)
{
- fprintf(stderr, "repo_content: 'content' incomplete, no product solvable created !\n");
+ pool_debug(pool, SAT_FATAL, "repo_content: 'content' incomplete, no product solvable created !\n");
exit(1);
}
const char *str;
#if 0
- fprintf(stderr, "start: [%d]%s\n", pd->state, name);
+ fprintf(stderr, "start: [%d]%s\n", pd->state, name);
#endif
if (pd->depth != pd->statedepth)
{
break;
if (sw->from != pd->state)
{
-#if 1
+#if 0
fprintf(stderr, "into unknown: [%d]%s (from: %d)\n", sw->to, name, sw->from);
exit( 1 );
#endif
else if (!strcasecmp(str, "md5"))
pd->delta.filechecksumtype = REPOKEY_TYPE_MD5;
else
- fprintf(stderr, "warning: unknown checksum type: '%s'\n", str);
+ pool_debug(pool, SAT_ERROR, "unknown checksum type: '%s'\n", str);
}
case STATE_SEQUENCE:
break;
const char *str;
#if 0
- fprintf(stderr, "end: %s\n", name);
+ fprintf(stderr, "end: %s\n", name);
#endif
if (pd->depth != pd->statedepth)
{
pd->depth--;
-#if 1
+#if 0
fprintf(stderr, "back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth);
#endif
return;
l = fread(buf, 1, sizeof(buf), fp);
if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- fprintf(stderr, "repo_updateinfoxml: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ pool_debug(pool, SAT_FATAL, "repo_updateinfoxml: %s at line %u:%u\n", XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
exit(1);
}
if (l == 0)
if (pd->ctime)
repodata_set_num(pd->data, pd->handle, SOLVABLE_INSTALLTIME, pd->ctime);
- if ( pd->basename )
+ if (pd->basename)
repodata_set_str(pd->data, pd->handle, PRODUCT_REFERENCEFILE, pd->basename);
/* this is where <productsdir>/baseproduct points to */
sat_free(pd.content);
join_freemem();
-
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
}
i = split(line + 5, sp, 4); /* name, <op>, evr, ? */
if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
{
- fprintf(stderr, "Bad dependency line: %d: %s\n", pd->lineno, line);
+ pool_debug(pool, SAT_FATAL, "susetags: bad dependency line: %d: %s\n", pd->lineno, line);
exit(1);
}
if (kind)
break;
if (flags == 6)
{
- fprintf(stderr, "Unknown relation %d: '%s'\n", pd->lineno, sp[1]);
+ pool_debug(pool, SAT_FATAL, "susetags: unknown relation in %d: '%s'\n", pd->lineno, sp[1]);
exit(1);
}
id = rel2id(pool, id, evrid, flags + 1, 1);
i = split(line, sp, 3);
if (i != 2 && i != 3)
{
- fprintf(stderr, "Bad location line: %d: %s\n", pd->lineno, line);
+ pool_debug(pool, SAT_FATAL, "susetags: bad location line: %d: %s\n", pd->lineno, line);
exit(1);
}
/* If we have a dirname, let's see if it's the same as arch. In that
if (split(line, sp, 5) != 4)
{
- fprintf(stderr, "Bad source line: %d: %s\n", pd->lineno, line);
+ pool_debug(pool, SAT_FATAL, "susetags: bad source line: %d: %s\n", pd->lineno, line);
exit(1);
}
Id type;
if (split(line, sp, 3) != 2)
{
- fprintf(stderr, "Bad source line: %d: %s\n", pd->lineno, line);
+ pool_debug(pd->repo->pool, SAT_FATAL, "susetags: bad checksum line: %d: %s\n", pd->lineno, line);
exit(1);
}
if (!strcasecmp (sp[0], "sha1"))
l = SIZEOF_MD5 * 2, type = REPOKEY_TYPE_MD5;
else
{
- fprintf(stderr, "Unknown checksum type: %d: %s\n", pd->lineno, sp[0]);
+ pool_debug(pd->repo->pool, SAT_FATAL, "susetags: unknown checksum type: %d: %s\n", pd->lineno, sp[0]);
exit(1);
}
if (strlen(sp[1]) != l)
{
- fprintf(stderr, "Invalid checksum length: %d: for %s: %s\n", pd->lineno, sp[0], sp[1]);
+ pool_debug(pd->repo->pool, SAT_FATAL, "susetags: bad checksum length: %d: for %s: %s\n", pd->lineno, sp[0], sp[1]);
exit(1);
}
repodata_set_checksum(data, handle, keyname, type, sp[1]);
if (is_end
&& strncmp(linep - 1 - intag, line + 1, intag))
{
- fprintf(stderr, "Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
+ pool_debug(pool, SAT_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
}
if (cummulate && !is_end)
{
char *tagend = strchr(line, ':');
if (!tagend)
{
- fprintf(stderr, "bad line: %d: %s\n", pd.lineno, line);
+ pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
exit(1);
}
intag = tagend - (line + 1);
if (split(line + 5, sp, 5) != 4)
{
- fprintf(stderr, "Bad line: %d: %s\n", pd.lineno, line);
+ pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
exit(1);
}
/* Lookup (but don't construct) the name and arch. */
break;
default:
- fprintf(stderr,"unknown line %s\n", line);
+ pool_debug(pool, SAT_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
break;
}
{
if (split(pd.share_with[i], sp, 5) != 4)
{
- fprintf(stderr, "Bad =Shr line: %s\n", pd.share_with[i]);
+ pool_debug(pool, SAT_FATAL, "susetags: bad =Shr line: %s\n", pd.share_with[i]);
exit(1);
}