Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@toru
Copy link
Collaborator

@toru toru commented Jun 4, 2019

Objective

Maintain a count of mmap failures, and make it accessible through the H2O Status API.

How

Declare a global size_t and operate on it using the __sync_add_and_fetch atomic built-in function. Code is added to a hot function but given that the error is rare, there should be no performance impact.

Demonstration

Native Response:

$ curl -s localhost:8080/status/json | grep mmap
 "memory.mmap_errors": 0

Prometheus Response via mruby:

$ curl -s localhost:8080/metrics | grep mmap
# HELP h2o_memory_mmap_errors memory.mmap_errors
# TYPE h2o_memory_mmap_errors counter
h2o_memory_mmap_errors{version="2.3.0-DEV@3aa238b1"} 0

Copy link
Member

@kazuho kazuho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo my comment below.

" \"http2.write-closed\": %" PRIu64 ", \n"
" \"ssl.errors\": %" PRIu64 "\n",
" \"ssl.errors\": %" PRIu64 ", \n"
" \"memory.mmap_errors\": %" PRIu64 "\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use %zu instead of casting to uint64_t and using PRIu64.

The alternative is to change the type of mmap_errors to uint64_t, though I'd prefer not doing that because some 32-bit platforms might not provide atomic operation support for uint64_t.

void h2o_append_to_null_terminated_list(void ***list, void *element);

extern __thread h2o_mem_recycle_t h2o_mem_pool_allocator;
extern size_t mmap_errors;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh my bad, we need h2o_ prefix. LGTM other than that.

@kazuho kazuho merged commit b1eb37c into h2o:master Jun 5, 2019
@kazuho
Copy link
Member

kazuho commented Jun 5, 2019

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants