Skip to content

Commit

Permalink
Make more of the dir entry sync configurable (#11832)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwoop authored Oct 25, 2024
1 parent df63f54 commit 7e2ff2c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
19 changes: 19 additions & 0 deletions doc/admin-guide/files/records.yaml.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,25 @@ Cache Control

Objects larger than the limit are not hit evacuated. A value of 0 disables the limit.

.. ts:cv:: CONFIG proxy.config.cache.dir.sync_frequency INT 60
:units: seconds

How often we will sync the cache directory entries to disk. Note that this is
a minimum time, and the actual sync may be delayed if the disks are larger than
how fast we allow it to write to disk (see next options).

.. ts:cv:: CONFIG proxy.config.cache.dir.sync_max_writes INT 2097152
:units: bytes

How much of a stripes cache directory we will write to disk in each write cycle.
Together with the sync_delay, this controls how fast we can sync the entire directory
structure to disk. The default is 2MB.

.. ts:cv:: CONFIG proxy.config.cache.dir.sync_delay INT 500
:units: millisecond

How long to wait between each write cycle when syncing the cache directory to disk.

.. ts:cv:: CONFIG proxy.config.cache.limits.http.max_alts INT 5
The maximum number of alternates that are allowed for any given URL.
Expand Down
8 changes: 8 additions & 0 deletions src/iocore/cache/Cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ int cache_config_ram_cache_use_seen_filter = 1;
int cache_config_http_max_alts = 3;
int cache_config_log_alternate_eviction = 0;
int cache_config_dir_sync_frequency = 60;
int cache_config_dir_sync_delay = 500;
int cache_config_dir_sync_max_write = (2 * 1024 * 1024);
int cache_config_permit_pinning = 0;
int cache_config_select_alternate = 1;
int cache_config_max_doc_size = 0;
Expand Down Expand Up @@ -824,6 +826,12 @@ ink_cache_init(ts::ModuleVersion v)
REC_EstablishStaticConfigInt32(cache_config_dir_sync_frequency, "proxy.config.cache.dir.sync_frequency");
Dbg(dbg_ctl_cache_init, "proxy.config.cache.dir.sync_frequency = %d", cache_config_dir_sync_frequency);

REC_EstablishStaticConfigInt32(cache_config_dir_sync_delay, "proxy.config.cache.dir.sync_delay");
Dbg(dbg_ctl_cache_init, "proxy.config.cache.dir.sync_delay = %d", cache_config_dir_sync_delay);

REC_EstablishStaticConfigInt32(cache_config_dir_sync_max_write, "proxy.config.cache.dir.sync_max_write");
Dbg(dbg_ctl_cache_init, "proxy.config.cache.dir.sync_max_write = %d", cache_config_dir_sync_max_write);

REC_EstablishStaticConfigInt32(cache_config_select_alternate, "proxy.config.cache.select_alternate");
Dbg(dbg_ctl_cache_init, "proxy.config.cache.select_alternate = %d", cache_config_select_alternate);

Expand Down
4 changes: 2 additions & 2 deletions src/iocore/cache/CacheDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ CacheSync::mainEvent(int event, Event *e)
}
Metrics::Counter::increment(cache_rsb.directory_sync_bytes, io.aio_result);
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.directory_sync_bytes, io.aio_result);
trigger = eventProcessor.schedule_in(this, SYNC_DELAY);
trigger = eventProcessor.schedule_in(this, HRTIME_MSECONDS(cache_config_dir_sync_delay));
return EVENT_CONT;
}
{
Expand Down Expand Up @@ -1046,7 +1046,7 @@ CacheSync::mainEvent(int event, Event *e)
writepos += headerlen;
} else if (writepos < static_cast<off_t>(dirlen) - headerlen) {
// write part of body
int l = SYNC_MAX_WRITE;
int l = cache_config_dir_sync_max_write;
if (writepos + l > static_cast<off_t>(dirlen) - headerlen) {
l = dirlen - headerlen - writepos;
}
Expand Down
2 changes: 0 additions & 2 deletions src/iocore/cache/P_CacheDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class CacheEvacuateDocVC;
#define DIR_OFFSET_BITS 40
#define DIR_OFFSET_MAX ((((off_t)1) << DIR_OFFSET_BITS) - 1)

#define SYNC_MAX_WRITE (2 * 1024 * 1024)
#define SYNC_DELAY HRTIME_MSECONDS(500)
#define DO_NOT_REMOVE_THIS 0

// Debugging Options
Expand Down
2 changes: 2 additions & 0 deletions src/iocore/cache/P_CacheInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ extern CacheStatsBlock cache_rsb;

// Configuration
extern int cache_config_dir_sync_frequency;
extern int cache_config_dir_sync_delay;
extern int cache_config_dir_sync_max_write;
extern int cache_config_http_max_alts;
extern int cache_config_log_alternate_eviction;
extern int cache_config_permit_pinning;
Expand Down
4 changes: 4 additions & 0 deletions src/records/RecordsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,10 @@ static const RecordElement RecordsConfig[] =
// # how often should the directory be synced (seconds)
{RECT_CONFIG, "proxy.config.cache.dir.sync_frequency", RECD_INT, "60", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.cache.dir.sync_delay", RECD_INT, "500", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.cache.dir.sync_max_write", RECD_INT, "2097152", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.cache.hostdb.disable_reverse_lookup", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.cache.select_alternate", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
Expand Down

0 comments on commit 7e2ff2c

Please sign in to comment.