Skip to content

Commit d4dd4ad

Browse files
committed
Address further review comments
1. Remove proxy.config.io.max_buffer_size 2. Add docs for the new configs
1 parent ba3fb27 commit d4dd4ad

30 files changed

Lines changed: 102 additions & 93 deletions

doc/admin-guide/files/records.config.en.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4407,6 +4407,31 @@ Sockets
44074407
platforms. (Currently only linux). IO buffers are allocated with the MADV_DONTDUMP
44084408
with madvise() on linux platforms that support MADV_DONTDUMP. Enabled by default.
44094409

4410+
.. ts:cv:: CONFIG proxy.config.ssl.misc.io.max_buffer_index INT 8
4411+
4412+
Configures the max IOBuffer Block index used for various SSL Operations
4413+
such as Handshake or Protocol Probe. Default value is 8 which maps to a 32K buffer
4414+
4415+
.. ts:cv:: CONFIG proxy.config.hostdb.io.max_buffer_index INT 8
4416+
4417+
Configures the max IOBuffer Block index used for storing HostDB records.
4418+
Default value is 8 which maps to a 32K buffer
4419+
4420+
.. ts:cv:: CONFIG proxy.config.payload.io.max_buffer_index INT 8
4421+
4422+
Configures the max IOBuffer Block index used for storing request payload buffer
4423+
for a POST request. Default value is 8 which maps to a 32K buffer
4424+
4425+
.. ts:cv:: CONFIG proxy.config.msg.io.max_buffer_index INT 8
4426+
4427+
Configures the max IOBuffer Block index used for storing miscellaneous transactional
4428+
buffers such as error response body. Default value is 8 which maps to a 32K buffer
4429+
4430+
.. ts:cv:: CONFIG proxy.config.log.io.max_buffer_index INT 8
4431+
4432+
Configures the max IOBuffer Block index used for storing an access log entry.
4433+
Default value is 8 which maps to a 32K buffer
4434+
44104435
.. ts:cv:: CONFIG proxy.config.http.enabled INT 1
44114436
44124437
Turn on or off support for HTTP proxying. This is rarely used, the one

iocore/cache/CachePages.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ ShowCache::handleCacheEvent(int event, Event *e)
427427

428428
case VC_EVENT_READ_READY:
429429
if (!cvio) {
430-
buffer = new_empty_MIOBuffer();
430+
buffer = new_empty_MIOBuffer(BUFFER_SIZE_INDEX_32K);
431431
buffer_reader = buffer->alloc_reader();
432432
content_length = cache_vc->get_object_size();
433433
cvio = cache_vc->do_io_read(this, content_length, buffer);

iocore/cache/CacheTest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ CacheTestSM::event_handler(int event, void *data)
9595
cancel_timeout();
9696
cache_action = nullptr;
9797
cache_vc = static_cast<CacheVConnection *>(data);
98-
buffer = new_empty_MIOBuffer();
98+
buffer = new_empty_MIOBuffer(BUFFER_SIZE_INDEX_32K);
9999
buffer_reader = buffer->alloc_reader();
100100
if (open_read_callout() < 0) {
101101
goto Lclose_error_next;
@@ -129,7 +129,7 @@ CacheTestSM::event_handler(int event, void *data)
129129
cancel_timeout();
130130
cache_action = nullptr;
131131
cache_vc = static_cast<CacheVConnection *>(data);
132-
buffer = new_empty_MIOBuffer();
132+
buffer = new_empty_MIOBuffer(BUFFER_SIZE_INDEX_32K);
133133
buffer_reader = buffer->alloc_reader();
134134
if (open_write_callout() < 0) {
135135
goto Lclose_error_next;

iocore/eventsystem/EventSystem.cc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,14 @@ void
3434
ink_event_system_init(ts::ModuleVersion v)
3535
{
3636
ink_release_assert(v.check(EVENT_SYSTEM_MODULE_INTERNAL_VERSION));
37-
int config_max_iobuffer_size = DEFAULT_MAX_BUFFER_SIZE;
38-
int iobuffer_advice = 0;
37+
int iobuffer_advice = 0;
3938

4039
// For backwards compatibility make sure to allow thread_freelist_size
4140
// This needs to change in 6.0
4241
REC_EstablishStaticConfigInt32(thread_freelist_high_watermark, "proxy.config.allocator.thread_freelist_size");
4342

4443
REC_EstablishStaticConfigInt32(thread_freelist_low_watermark, "proxy.config.allocator.thread_freelist_low_watermark");
4544

46-
REC_ReadConfigInteger(config_max_iobuffer_size, "proxy.config.io.max_buffer_size");
47-
48-
max_iobuffer_size = buffer_size_to_index(config_max_iobuffer_size, DEFAULT_BUFFER_SIZES - 1);
49-
if (default_small_iobuffer_size > max_iobuffer_size) {
50-
default_small_iobuffer_size = max_iobuffer_size;
51-
}
52-
if (default_large_iobuffer_size > max_iobuffer_size) {
53-
default_large_iobuffer_size = max_iobuffer_size;
54-
}
55-
5645
#ifdef MADV_DONTDUMP // This should only exist on Linux 3.4 and higher.
5746
RecBool dont_dump_enabled = true;
5847
RecGetRecordBool("proxy.config.allocator.dontdump_iobuffers", &dont_dump_enabled, false);

iocore/eventsystem/I_IOBuffer.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ class MIOBuffer;
5252
class IOBufferReader;
5353
class VIO;
5454

55-
inkcoreapi extern int64_t max_iobuffer_size;
56-
extern int64_t default_small_iobuffer_size;
57-
extern int64_t default_large_iobuffer_size; // matched to size of OS buffers
58-
5955
enum AllocType {
6056
NO_ALLOC,
6157
MEMALIGNED,
@@ -417,7 +413,7 @@ class IOBufferBlock : public RefCountObj
417413
section in MIOBuffer.
418414
419415
*/
420-
void alloc(int64_t i = default_large_iobuffer_size);
416+
void alloc(int64_t i);
421417

422418
/**
423419
Clear the IOBufferData this IOBufferBlock handles. Clears this
@@ -1148,7 +1144,7 @@ class MIOBuffer
11481144
void dealloc_all_readers();
11491145

11501146
void set(void *b, int64_t len);
1151-
void alloc(int64_t i = default_large_iobuffer_size);
1147+
void alloc(int64_t i);
11521148
void append_block_internal(IOBufferBlock *b);
11531149
int64_t write(IOBufferBlock const *b, int64_t len, int64_t offset);
11541150

@@ -1290,7 +1286,7 @@ struct MIOBufferAccessor {
12901286
IOBufferReader *entry = nullptr;
12911287
};
12921288

1293-
extern MIOBuffer *new_MIOBuffer_internal(const char *loc, int64_t size_index = default_large_iobuffer_size);
1289+
extern MIOBuffer *new_MIOBuffer_internal(const char *loc, int64_t size_index);
12941290

12951291
class MIOBuffer_tracker
12961292
{
@@ -1299,13 +1295,13 @@ class MIOBuffer_tracker
12991295
public:
13001296
explicit MIOBuffer_tracker(const char *_loc) : loc(_loc) {}
13011297
MIOBuffer *
1302-
operator()(int64_t size_index = default_large_iobuffer_size)
1298+
operator()(int64_t size_index)
13031299
{
13041300
return new_MIOBuffer_internal(loc, size_index);
13051301
}
13061302
};
13071303

1308-
extern MIOBuffer *new_empty_MIOBuffer_internal(const char *loc, int64_t size_index = default_large_iobuffer_size);
1304+
extern MIOBuffer *new_empty_MIOBuffer_internal(const char *loc, int64_t size_index);
13091305

13101306
class Empty_MIOBuffer_tracker
13111307
{
@@ -1314,7 +1310,7 @@ class Empty_MIOBuffer_tracker
13141310
public:
13151311
explicit Empty_MIOBuffer_tracker(const char *_loc) : loc(_loc) {}
13161312
MIOBuffer *
1317-
operator()(int64_t size_index = default_large_iobuffer_size)
1313+
operator()(int64_t size_index)
13181314
{
13191315
return new_empty_MIOBuffer_internal(loc, size_index);
13201316
}
@@ -1352,8 +1348,7 @@ class IOBufferBlock_tracker
13521348
#define new_IOBufferBlock IOBufferBlock_tracker(RES_PATH("memory/IOBuffer/"))
13531349
////////////////////////////////////////////////////////////
13541350

1355-
extern IOBufferData *new_IOBufferData_internal(const char *location, int64_t size_index = default_large_iobuffer_size,
1356-
AllocType type = DEFAULT_ALLOC);
1351+
extern IOBufferData *new_IOBufferData_internal(const char *location, int64_t size_index, AllocType type = DEFAULT_ALLOC);
13571352

13581353
extern IOBufferData *new_xmalloc_IOBufferData_internal(const char *location, void *b, int64_t size);
13591354

@@ -1364,7 +1359,7 @@ class IOBufferData_tracker
13641359
public:
13651360
explicit IOBufferData_tracker(const char *_loc) : loc(_loc) {}
13661361
IOBufferData *
1367-
operator()(int64_t size_index = default_large_iobuffer_size, AllocType type = DEFAULT_ALLOC)
1362+
operator()(int64_t size_index, AllocType type = DEFAULT_ALLOC)
13681363
{
13691364
return new_IOBufferData_internal(loc, size_index, type);
13701365
}

iocore/eventsystem/unit_tests/test_IOBuffer.cc

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,19 @@
3535

3636
TEST_CASE("MIOBuffer", "[iocore]")
3737
{
38-
// These value could be tweaked by `ink_event_system_init()` using `proxy.config.io.max_buffer_size`
39-
REQUIRE(default_small_iobuffer_size == DEFAULT_SMALL_BUFFER_SIZE);
40-
REQUIRE(default_large_iobuffer_size == DEFAULT_LARGE_BUFFER_SIZE);
41-
42-
REQUIRE(BUFFER_SIZE_FOR_INDEX(default_small_iobuffer_size) == 512);
43-
REQUIRE(BUFFER_SIZE_FOR_INDEX(default_large_iobuffer_size) == 4096);
44-
4538
SECTION("new_MIOBuffer 100 times")
4639
{
4740
int64_t read_avail_len1 = 0;
4841
int64_t read_avail_len2 = 0;
4942

5043
for (unsigned i = 0; i < 100; ++i) {
51-
MIOBuffer *b1 = new_MIOBuffer(default_small_iobuffer_size);
44+
MIOBuffer *b1 = new_MIOBuffer(BUFFER_SIZE_INDEX_512);
5245
int64_t len1 = b1->write_avail();
5346
IOBufferReader *b1reader = b1->alloc_reader();
5447
b1->fill(len1);
5548
read_avail_len1 += b1reader->read_avail();
5649

57-
MIOBuffer *b2 = new_MIOBuffer(default_large_iobuffer_size);
50+
MIOBuffer *b2 = new_MIOBuffer(BUFFER_SIZE_INDEX_4K);
5851
int64_t len2 = b2->write_avail();
5952
IOBufferReader *b2reader = b2->alloc_reader();
6053
b2->fill(len2);
@@ -64,19 +57,19 @@ TEST_CASE("MIOBuffer", "[iocore]")
6457
free_MIOBuffer(b1);
6558
}
6659

67-
CHECK(read_avail_len1 == 100 * BUFFER_SIZE_FOR_INDEX(default_small_iobuffer_size));
68-
CHECK(read_avail_len2 == 100 * BUFFER_SIZE_FOR_INDEX(default_large_iobuffer_size));
60+
CHECK(read_avail_len1 == 100 * BUFFER_SIZE_FOR_INDEX(BUFFER_SIZE_INDEX_512));
61+
CHECK(read_avail_len2 == 100 * BUFFER_SIZE_FOR_INDEX(BUFFER_SIZE_INDEX_4K));
6962
}
7063

7164
SECTION("write")
7265
{
73-
MIOBuffer *miob = new_MIOBuffer();
66+
MIOBuffer *miob = new_MIOBuffer(BUFFER_SIZE_INDEX_4K);
7467
IOBufferReader *miob_r = miob->alloc_reader();
7568
const IOBufferBlock *block = miob->first_write_block();
7669

7770
SECTION("initial state")
7871
{
79-
CHECK(miob->size_index == default_large_iobuffer_size);
72+
CHECK(miob->size_index == BUFFER_SIZE_INDEX_4K);
8073
CHECK(miob->water_mark == 0);
8174
CHECK(miob->first_write_block() != nullptr);
8275
CHECK(miob->block_size() == 4096);
@@ -176,7 +169,7 @@ TEST_CASE("MIOBuffer", "[iocore]")
176169

177170
SECTION("write_avail")
178171
{
179-
MIOBuffer *miob = new_MIOBuffer();
172+
MIOBuffer *miob = new_MIOBuffer(BUFFER_SIZE_INDEX_4K);
180173
IOBufferReader *miob_r = miob->alloc_reader();
181174
uint8_t buf[8192];
182175
memset(buf, 0xAA, sizeof(buf));
@@ -347,7 +340,6 @@ struct EventProcessorListener : Catch::TestEventListenerBase {
347340
init_diags("", nullptr);
348341
RecProcessInit(RECM_STAND_ALONE);
349342

350-
// Initialize LibRecordsConfig for `proxy.config.io.max_buffer_size` (32K)
351343
LibRecordsConfigInit();
352344

353345
ink_event_system_init(EVENT_SYSTEM_MODULE_PUBLIC_VERSION);

iocore/net/NetVCTest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ NetVCTest::start_test()
138138
test_vc->set_inactivity_timeout(HRTIME_SECONDS(timeout));
139139
test_vc->set_active_timeout(HRTIME_SECONDS(timeout + 5));
140140

141-
read_buffer = new_MIOBuffer();
142-
write_buffer = new_MIOBuffer();
141+
read_buffer = new_MIOBuffer(BUFFER_SIZE_INDEX_32K);
142+
write_buffer = new_MIOBuffer(BUFFER_SIZE_INDEX_32K);
143143

144144
reader_for_rbuf = read_buffer->alloc_reader();
145145
reader_for_wbuf = write_buffer->alloc_reader();

iocore/net/P_SSLConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ struct SSLConfigParams : public ConfigInfo {
108108
static bool server_allow_early_data_params;
109109

110110
static int ssl_maxrecord;
111+
static int ssl_misc_max_iobuffer_size_index;
111112
static bool ssl_allow_client_renegotiation;
112113

113114
static bool ssl_ocsp_enabled;

iocore/net/P_SSLNetVConnection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "P_ALPNSupport.h"
5050
#include "TLSSessionResumptionSupport.h"
5151
#include "P_SSLUtils.h"
52+
#include "P_SSLConfig.h"
5253

5354
// These are included here because older OpenSSL libraries don't have them.
5455
// Don't copy these defines, or use their values directly, they are merely
@@ -186,7 +187,7 @@ class SSLNetVConnection : public UnixNetVConnection, public ALPNSupport, public
186187
void
187188
initialize_handshake_buffers()
188189
{
189-
this->handShakeBuffer = new_MIOBuffer();
190+
this->handShakeBuffer = new_MIOBuffer(SSLConfigParams::ssl_misc_max_iobuffer_size_index);
190191
this->handShakeReader = this->handShakeBuffer->alloc_reader();
191192
this->handShakeHolder = this->handShakeReader->clone();
192193
this->handShakeBioStored = 0;

iocore/net/SSLConfig.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int SSLConfig::configid = 0;
5252
int SSLCertificateConfig::configid = 0;
5353
int SSLTicketKeyConfig::configid = 0;
5454
int SSLConfigParams::ssl_maxrecord = 0;
55+
int SSLConfigParams::ssl_misc_max_iobuffer_size_index = 8;
5556
bool SSLConfigParams::ssl_allow_client_renegotiation = false;
5657
bool SSLConfigParams::ssl_ocsp_enabled = false;
5758
int SSLConfigParams::ssl_ocsp_cache_timeout = 3600;
@@ -454,6 +455,8 @@ SSLConfigParams::initialize()
454455

455456
REC_ReadConfigInt32(ssl_allow_client_renegotiation, "proxy.config.ssl.allow_client_renegotiation");
456457

458+
REC_ReadConfigInt32(ssl_misc_max_iobuffer_size_index, "proxy.config.ssl.misc.io.max_buffer_index");
459+
457460
// Enable client regardless of config file settings as remap file
458461
// can cause HTTP layer to connect using SSL. But only if SSL
459462
// initialization hasn't failed already.

0 commit comments

Comments
 (0)