From: Michael Vrable Date: Sun, 13 Mar 2011 04:32:55 +0000 (-0800) Subject: Try to improve support for no-aggregation mode X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=89abfdf52a35cd78e921bc7b6f44c346ddde9bd4;p=bluesky.git Try to improve support for no-aggregation mode Make it at least a bit more performance-competitive by fetching objects when prefetching is requested. --- diff --git a/bluesky/bluesky-private.h b/bluesky/bluesky-private.h index 117f108..5a55b79 100644 --- a/bluesky/bluesky-private.h +++ b/bluesky/bluesky-private.h @@ -357,6 +357,7 @@ void bluesky_cloudlog_insert_locked(BlueSkyCloudLog *log); BlueSkyCloudLog *bluesky_cloudlog_get(BlueSkyFS *fs, BlueSkyCloudID id); void bluesky_cloudlog_prefetch(BlueSkyCloudLog *log); void bluesky_cloudlog_fetch(BlueSkyCloudLog *log); +void bluesky_cloudlog_background_fetch(BlueSkyCloudLog *item); BlueSkyCloudPointer bluesky_cloudlog_serialize(BlueSkyCloudLog *log, BlueSkyFS *fs); void bluesky_cloudlog_flush(BlueSkyFS *fs); diff --git a/bluesky/cleaner.c b/bluesky/cleaner.c index 0fc39df..5f241d4 100644 --- a/bluesky/cleaner.c +++ b/bluesky/cleaner.c @@ -244,8 +244,8 @@ static void merge_inode(BlueSkyFS *fs, BlueSkyCleanerItem *cleaner_inode) BlueSkyCloudLog *proxy_item = entry->item; g_mutex_lock(proxy_item->lock); - BlueSkyCloudPointer proxy_location = entry->item->location; - BlueSkyCloudID proxy_id = entry->item->id; + //BlueSkyCloudPointer proxy_location = entry->item->location; + //BlueSkyCloudID proxy_id = entry->item->id; g_mutex_unlock(proxy_item->lock); g_mutex_unlock(fs->lock); diff --git a/bluesky/cloudlog.c b/bluesky/cloudlog.c index 3e30f02..628fc97 100644 --- a/bluesky/cloudlog.c +++ b/bluesky/cloudlog.c @@ -192,12 +192,6 @@ void bluesky_cloudlog_unref_delayed(BlueSkyCloudLog *log) g_async_queue_push(log->fs->unref_queue, log); } -void bluesky_cloudlog_threads_init(BlueSkyFS *fs) -{ - fs->unref_queue = g_async_queue_new(); - g_thread_create(cloudlog_unref_thread, fs->unref_queue, FALSE, NULL); -} - /* Erase the information contained within the in-memory cloud log * representation. This does not free up the item itself, but frees the data * and references to other log items and resets the type back to unknown. If @@ -271,6 +265,25 @@ BlueSkyCloudLog *bluesky_cloudlog_get(BlueSkyFS *fs, BlueSkyCloudID id) return item; } +/* Work to fetch a cloudlog item in a background thread. The item will be + * locked while the fetch is in progress and unlocked when it completes. */ +static GThreadPool *fetch_pool; + +static void background_fetch_task(gpointer p, gpointer unused) +{ + BlueSkyCloudLog *item = (BlueSkyCloudLog *)p; + + g_mutex_lock(item->lock); + g_mutex_unlock(item->lock); + bluesky_cloudlog_unref(item); +} + +void bluesky_cloudlog_background_fetch(BlueSkyCloudLog *item) +{ + bluesky_cloudlog_ref(item); + g_thread_pool_push(fetch_pool, item, NULL); +} + /* Attempt to prefetch a cloud log item. This does not guarantee that it will * be made available, but does make it more likely that a future call to * bluesky_cloudlog_fetch will complete quickly. Item must be locked? */ @@ -279,6 +292,13 @@ void bluesky_cloudlog_prefetch(BlueSkyCloudLog *item) if (item->data != NULL) return; + /* When operating in a non log-structured mode, simply start a background + * fetch immediately when asked to prefetch. */ + if (bluesky_options.disable_aggregation) { + bluesky_cloudlog_background_fetch(item); + return; + } + /* TODO: Some of the code here is duplicated with bluesky_log_map_object. * Refactor to fix that. */ BlueSkyFS *fs = item->fs; @@ -635,3 +655,11 @@ void bluesky_cloudlog_decrypt(char *segment, size_t len, remaining_size -= item_size; } } + +void bluesky_cloudlog_threads_init(BlueSkyFS *fs) +{ + fs->unref_queue = g_async_queue_new(); + g_thread_create(cloudlog_unref_thread, fs->unref_queue, FALSE, NULL); + fetch_pool = g_thread_pool_new(background_fetch_task, NULL, 40, FALSE, + NULL); +} diff --git a/bluesky/init.c b/bluesky/init.c index 49ede3e..9ce20b9 100644 --- a/bluesky/init.c +++ b/bluesky/init.c @@ -45,6 +45,7 @@ static struct { const char *env; int *option; } option_table[] = { + {"BLUESKY_VERBOSE", &bluesky_verbose}, {"BLUESKY_OPT_SYNC_STORES", &bluesky_options.synchronous_stores}, {"BLUESKY_OPT_WRITETHROUGH", &bluesky_options.writethrough_cache}, {"BLUESKY_OPT_SYNC_INODE_FETCH", &bluesky_options.sync_inode_fetches},