Experimental: Revert r28647, r28646, r28645: DB store-to-load fwd --- apps/tagcache.c | 106 +++++++++++++++---------------------------------------- 1 files changed, 29 insertions(+), 77 deletions(-) diff --git a/apps/tagcache.c b/apps/tagcache.c index ae7199f..7f7a513 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -761,77 +761,31 @@ static bool retrieve(struct tagcache_search *tcs, struct index_entry *idx, return true; } -#define COMMAND_QUEUE_IS_EMPTY (command_queue_ridx == command_queue_widx) - -static long read_numeric_tag(int tag, int idx_id, const struct index_entry *idx) -{ -#ifndef __PCTOOL__ - if (! COMMAND_QUEUE_IS_EMPTY) - { - /* Attempt to find tag data through store-to-load forwarding in - command queue */ - long result = -1; - - mutex_lock(&command_queue_mutex); - - int ridx = command_queue_widx; - - while (ridx != command_queue_ridx) - { - if (--ridx < 0) - ridx = TAGCACHE_COMMAND_QUEUE_LENGTH - 1; - - if (command_queue[ridx].command == CMD_UPDATE_NUMERIC - && command_queue[ridx].idx_id == idx_id - && command_queue[ridx].tag == tag) - { - result = command_queue[ridx].data; - break; - } - } - - mutex_unlock(&command_queue_mutex); - - if (result >= 0) - { - logf("read_numeric_tag: " - "Recovered tag %d value %lX from write queue", - tag, result); - return result; - } - } -#endif - - return idx->tag_seek[tag]; -} - - -static long check_virtual_tags(int tag, int idx_id, - const struct index_entry *idx) +static long check_virtual_tags(int tag, const struct index_entry *idx) { long data = 0; switch (tag) { case tag_virt_length_sec: - data = (read_numeric_tag(tag_length, idx_id, idx)/1000) % 60; + data = (idx->tag_seek[tag_length]/1000) % 60; break; case tag_virt_length_min: - data = (read_numeric_tag(tag_length, idx_id, idx)/1000) / 60; + data = (idx->tag_seek[tag_length]/1000) / 60; break; case tag_virt_playtime_sec: - data = (read_numeric_tag(tag_playtime, idx_id, idx)/1000) % 60; + data = (idx->tag_seek[tag_playtime]/1000) % 60; break; case tag_virt_playtime_min: - data = (read_numeric_tag(tag_playtime, idx_id, idx)/1000) / 60; + data = (idx->tag_seek[tag_playtime]/1000) / 60; break; case tag_virt_autoscore: - if (read_numeric_tag(tag_length, idx_id, idx) == 0 - || read_numeric_tag(tag_playcount, idx_id, idx) == 0) + if (idx->tag_seek[tag_length] == 0 + || idx->tag_seek[tag_playcount] == 0) { data = 0; } @@ -847,23 +801,19 @@ static long check_virtual_tags(int tag, int idx_id, autoscore = 100 * (alpha / playcout + beta / length / playcount) Both terms should be small enough to avoid any overflow */ - data = 100 * (read_numeric_tag(tag_playtime, idx_id, idx) - / read_numeric_tag(tag_length, idx_id, idx)) - + (100 * (read_numeric_tag(tag_playtime, idx_id, idx) - % read_numeric_tag(tag_length, idx_id, idx))) - / read_numeric_tag(tag_length, idx_id, idx); - data /= read_numeric_tag(tag_playcount, idx_id, idx); + data = 100 * (idx->tag_seek[tag_playtime] / idx->tag_seek[tag_length]) + + (100 * (idx->tag_seek[tag_playtime] % idx->tag_seek[tag_length])) / idx->tag_seek[tag_length]; + data /= idx->tag_seek[tag_playcount]; } break; /* How many commits before the file has been added to the DB. */ case tag_virt_entryage: - data = current_tcmh.commitid - - read_numeric_tag(tag_commitid, idx_id, idx) - 1; + data = current_tcmh.commitid - idx->tag_seek[tag_commitid] - 1; break; default: - data = read_numeric_tag(tag, idx_id, idx); + data = idx->tag_seek[tag]; } return data; @@ -882,7 +832,7 @@ long tagcache_get_numeric(const struct tagcache_search *tcs, int tag) if (!get_index(tcs->masterfd, tcs->idx_id, &idx, true)) return -2; - return check_virtual_tags(tag, tcs->idx_id, &idx); + return check_virtual_tags(tag, &idx); } inline static bool str_ends_with(const char *str1, const char *str2) @@ -992,7 +942,7 @@ static bool check_clauses(struct tagcache_search *tcs, char buf[256]; char *str = NULL; - seek = check_virtual_tags(clause[i]->tag, tcs->idx_id, idx); + seek = check_virtual_tags(clause[i]->tag, idx); if (!TAGCACHE_IS_NUMERIC(clause[i]->tag)) { @@ -1022,7 +972,7 @@ static bool check_clauses(struct tagcache_search *tcs, int seek; char str[256]; - seek = check_virtual_tags(clause[i]->tag, tcs->idx_id, idx); + seek = check_virtual_tags(clause[i]->tag, idx); memset(str, 0, sizeof str); if (!TAGCACHE_IS_NUMERIC(clause[i]->tag)) @@ -1646,9 +1596,9 @@ static struct tagfile_entry *get_tag(const struct index_entry *entry, int tag) return (struct tagfile_entry *)&hdr->tags[tag][entry->tag_seek[tag]]; } -static long get_tag_numeric(const struct index_entry *entry, int tag, int idx_id) +static long get_tag_numeric(const struct index_entry *entry, int tag) { - return check_virtual_tags(tag, idx_id, entry); + return check_virtual_tags(tag, entry); } static char* get_tag_string(const struct index_entry *entry, int tag) @@ -1683,23 +1633,23 @@ bool tagcache_fill_tags(struct mp3entry *id3, const char *filename) id3->albumartist = get_tag_string(entry, tag_albumartist); id3->grouping = get_tag_string(entry, tag_grouping); - id3->length = get_tag_numeric(entry, tag_length, idx_id); - id3->playcount = get_tag_numeric(entry, tag_playcount, idx_id); - id3->rating = get_tag_numeric(entry, tag_rating, idx_id); - id3->lastplayed = get_tag_numeric(entry, tag_lastplayed, idx_id); - id3->score = get_tag_numeric(entry, tag_virt_autoscore, idx_id) / 10; - id3->year = get_tag_numeric(entry, tag_year, idx_id); + id3->length = get_tag_numeric(entry, tag_length); + id3->playcount = get_tag_numeric(entry, tag_playcount); + id3->rating = get_tag_numeric(entry, tag_rating); + id3->lastplayed = get_tag_numeric(entry, tag_lastplayed); + id3->score = get_tag_numeric(entry, tag_virt_autoscore) / 10; + id3->year = get_tag_numeric(entry, tag_year); - id3->discnum = get_tag_numeric(entry, tag_discnumber, idx_id); - id3->tracknum = get_tag_numeric(entry, tag_tracknumber, idx_id); - id3->bitrate = get_tag_numeric(entry, tag_bitrate, idx_id); + id3->discnum = get_tag_numeric(entry, tag_discnumber); + id3->tracknum = get_tag_numeric(entry, tag_tracknumber); + id3->bitrate = get_tag_numeric(entry, tag_bitrate); if (id3->bitrate == 0) id3->bitrate = 1; #if CONFIG_CODEC == SWCODEC if (global_settings.autoresume_enable) { - id3->offset = get_tag_numeric(entry, tag_lastoffset, idx_id); + id3->offset = get_tag_numeric(entry, tag_lastoffset); logf("tagcache_fill_tags: Set offset for %s to %lX\n", id3->title, id3->offset); } @@ -3145,6 +3095,8 @@ bool tagcache_modify_numeric_entry(struct tagcache_search *tcs, } #endif +#define COMMAND_QUEUE_IS_EMPTY (command_queue_ridx == command_queue_widx) + static bool command_queue_is_full(void) { int next; -- 1.7.1