Skip to content

Commit 6f63b97

Browse files
committed
optimize: fixed padding holes in our struct memory layouts for 64-bit systems to save a little memory.
1 parent 31265f7 commit 6f63b97

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/ngx_http_lua_common.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,6 @@ struct ngx_http_lua_co_ctx_s {
287287

288288
ngx_http_cleanup_pt cleanup;
289289

290-
unsigned nsubreqs; /* number of subrequests of the
291-
* current request */
292-
293290
ngx_int_t *sr_statuses; /* all capture subrequest statuses */
294291

295292
ngx_http_headers_out_t **sr_headers;
@@ -298,6 +295,9 @@ struct ngx_http_lua_co_ctx_s {
298295

299296
uint8_t *sr_flags;
300297

298+
unsigned nsubreqs; /* number of subrequests of the
299+
* current request */
300+
301301
unsigned pending_subreqs; /* number of subrequests being
302302
waited */
303303

@@ -365,8 +365,6 @@ typedef struct ngx_http_lua_ctx_s {
365365
unsigned flushing_coros; /* number of coroutines waiting on
366366
ngx.flush(true) */
367367

368-
int uthreads; /* number of active user threads */
369-
370368
ngx_chain_t *out; /* buffered output chain for HTTP 1.0 */
371369
ngx_chain_t *free_bufs;
372370
ngx_chain_t *busy_bufs;
@@ -393,6 +391,8 @@ typedef struct ngx_http_lua_ctx_s {
393391

394392
ngx_http_lua_posted_thread_t *posted_threads;
395393

394+
int uthreads; /* number of active user threads */
395+
396396
uint16_t context; /* the current running directive context
397397
(or running phase) for the current
398398
Lua chunk */

src/ngx_http_lua_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef NGX_LUA_NO_FFI_API
2121
typedef struct {
2222
int len;
23+
/* this padding hole on 64-bit systems is expected */
2324
u_char *data;
2425
} ngx_http_lua_ffi_str_t;
2526

0 commit comments

Comments
 (0)