Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions doc/admin-guide/files/volume.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,27 @@ volumes without deleting and clearing the existing volumes.
Changing this file to add, remove or modify volumes effectively invalidates
the cache.


Optional ramcache setting
-------------------------

You can also add an option ``ramcache=true/false`` to the volume configuration
line. True is the default setting and so not needed unless you want to explicitly
set it. Setting ``ramcache=false`` will disable the ramcache that normally
sits in front of a volume. This may be desirable if you are using something like
ramdisks, to avoid wasting RAM and cpu time on double caching objects.


Examples
========

The following example partitions the cache across 5 volumes to decreasing
single-lock pressure for a machine with few drives.::
single-lock pressure for a machine with few drives. The last volume being
an example of one that might be composed of purely ramdisks so that the
ramcache has been disabled.::

volume=1 scheme=http size=20%
volume=2 scheme=http size=20%
volume=3 scheme=http size=20%
volume=4 scheme=http size=20%
volume=5 scheme=http size=20%
volume=5 scheme=http size=20% ramcache=false
9 changes: 9 additions & 0 deletions doc/admin-guide/storage/index.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ To change the RAM cache size:
1GB or more, then restart with the :program:`trafficserver` command
(refer to :ref:`start-traffic-server`).

Disabling the RAM Cache
-----------------------

It is possible to disable the RAM cache. If you have configured your
storage using the :file:`volume.config` you can add an optional directive
of ``ramcache=false`` to whichever volumes you wish to have it disabled on.
This may be desirable for volumes composed of storage like RAM disks where
you may want to avoid double RAM caching.

Changing Cache Capacity
=======================

Expand Down
22 changes: 13 additions & 9 deletions iocore/cache/Cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -911,12 +911,14 @@ CacheProcessor::cacheInitialized()
Debug("cache_init", "CacheProcessor::cacheInitialized - cache_config_ram_cache_size == AUTO_SIZE_RAM_CACHE");
for (i = 0; i < gnvol; i++) {
vol = gvol[i];
gvol[i]->ram_cache->init(vol->dirlen() * DEFAULT_RAM_CACHE_MULTIPLIER, vol);
ram_cache_bytes += gvol[i]->dirlen();
Debug("cache_init", "CacheProcessor::cacheInitialized - ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", ram_cache_bytes,
ram_cache_bytes / (1024 * 1024));
CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)gvol[i]->dirlen());

if (gvol[i]->cache_vol->ramcache_enabled) {
gvol[i]->ram_cache->init(vol->dirlen() * DEFAULT_RAM_CACHE_MULTIPLIER, vol);
ram_cache_bytes += gvol[i]->dirlen();
Debug("cache_init", "CacheProcessor::cacheInitialized - ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", ram_cache_bytes,
ram_cache_bytes / (1024 * 1024));
CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)gvol[i]->dirlen());
}
vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen();
total_cache_bytes += vol_total_cache_bytes;
Debug("cache_init", "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb",
Expand Down Expand Up @@ -955,14 +957,14 @@ CacheProcessor::cacheInitialized()
for (i = 0; i < gnvol; i++) {
vol = gvol[i];
double factor;
if (gvol[i]->cache == theCache) {
if (gvol[i]->cache == theCache && gvol[i]->cache_vol->ramcache_enabled) {
ink_assert(gvol[i]->cache != nullptr);
factor = static_cast<double>(static_cast<int64_t>(gvol[i]->len >> STORE_BLOCK_SHIFT)) / theCache->cache_size;
Debug("cache_init", "CacheProcessor::cacheInitialized - factor = %f", factor);
gvol[i]->ram_cache->init(static_cast<int64_t>(http_ram_cache_size * factor), vol);
ram_cache_bytes += static_cast<int64_t>(http_ram_cache_size * factor);
CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)(http_ram_cache_size * factor));
} else {
} else if (gvol[i]->cache_vol->ramcache_enabled) {
ink_release_assert(!"Unexpected non-HTTP cache volume");
}
Debug("cache_init", "CacheProcessor::cacheInitialized[%d] - ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", i,
Expand Down Expand Up @@ -2541,7 +2543,8 @@ cplist_update()
for (config_vol = config_volumes.cp_queue.head; config_vol; config_vol = config_vol->link.next) {
if (config_vol->number == cp->vol_number) {
if (cp->scheme == config_vol->scheme) {
config_vol->cachep = cp;
cp->ramcache_enabled = config_vol->ramcache_enabled;
config_vol->cachep = cp;
} else {
/* delete this volume from all the disks */
int d_no;
Expand Down Expand Up @@ -2716,7 +2719,8 @@ cplist_reconfigure()
(int64_t)config_vol->size, 128);
Warning("volume %d is not created", config_vol->number);
}
Debug("cache_hosting", "Volume: %d Size: %" PRId64, config_vol->number, (int64_t)config_vol->size);
Debug("cache_hosting", "Volume: %d Size: %" PRId64 " Ramcache: %d", config_vol->number, (int64_t)config_vol->size,
config_vol->ramcache_enabled);
}
cplist_update();
/* go through volume config and grow and create volumes */
Expand Down
35 changes: 25 additions & 10 deletions iocore/cache/CacheHosting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,13 @@ ConfigVolumes::BuildListFromString(char *config_file_path, char *file_buf)
line_num++;

char *end;
char *line_end = nullptr;
const char *err = nullptr;
int volume_number = 0;
CacheType scheme = CACHE_NONE_TYPE;
int size = 0;
int in_percent = 0;
char *line_end = nullptr;
const char *err = nullptr;
int volume_number = 0;
CacheType scheme = CACHE_NONE_TYPE;
int size = 0;
int in_percent = 0;
bool ramcache_enabled = true;

while (true) {
// skip all blank spaces at beginning of line
Expand Down Expand Up @@ -743,6 +744,18 @@ ConfigVolumes::BuildListFromString(char *config_file_path, char *file_buf)
} else {
in_percent = 0;
}
} else if (strcasecmp(tmp, "ramcache") == 0) { // match ramcache
tmp += 9;
if (!strcasecmp(tmp, "false")) {
tmp += 5;
ramcache_enabled = false;
} else if (!strcasecmp(tmp, "true")) {
tmp += 4;
ramcache_enabled = true;
} else {
err = "Unexpected end of line";
break;
}
}

// ends here
Expand All @@ -765,17 +778,19 @@ ConfigVolumes::BuildListFromString(char *config_file_path, char *file_buf)
} else {
configp->in_percent = false;
}
configp->scheme = scheme;
configp->size = size;
configp->cachep = nullptr;
configp->scheme = scheme;
configp->size = size;
configp->cachep = nullptr;
configp->ramcache_enabled = ramcache_enabled;
cp_queue.enqueue(configp);
num_volumes++;
if (scheme == CACHE_HTTP_TYPE) {
num_http_volumes++;
} else {
ink_release_assert(!"Unexpected non-HTTP cache volume");
}
Debug("cache_hosting", "added volume=%d, scheme=%d, size=%d percent=%d", volume_number, scheme, size, in_percent);
Debug("cache_hosting", "added volume=%d, scheme=%d, size=%d percent=%d, ramcache enabled=%d", volume_number, scheme, size,
in_percent, ramcache_enabled);
}

tmp = bufTok.iterNext(&i_state);
Expand Down
1 change: 1 addition & 0 deletions iocore/cache/P_CacheHosting.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ struct ConfigVol {
CacheType scheme;
off_t size;
bool in_percent;
bool ramcache_enabled;
int percent;
CacheVol *cachep;
LINK(ConfigVol, link);
Expand Down
13 changes: 7 additions & 6 deletions iocore/cache/P_CacheVol.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,13 @@ struct AIO_Callback_handler : public Continuation {
};

struct CacheVol {
int vol_number = -1;
int scheme = 0;
off_t size = 0;
int num_vols = 0;
Vol **vols = nullptr;
DiskVol **disk_vols = nullptr;
int vol_number = -1;
int scheme = 0;
off_t size = 0;
int num_vols = 0;
bool ramcache_enabled = true;
Vol **vols = nullptr;
DiskVol **disk_vols = nullptr;
LINK(CacheVol, link);
// per volume stats
RecRawStatBlock *vol_rsb = nullptr;
Expand Down