Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split user info #74

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Split user info #74

wants to merge 1 commit into from

Conversation

erthalion
Copy link
Collaborator

In order to make memory management more flexible, split user info stored in sinsp_threadinfo into essential and extended parts. This can have significant impact in case of process-heavy workloads, as in the example below:

mem

The memory usage breakdown shows that most of it goes to manage
sinsp_threadinfo (where _M_allocate_node is a part of threadinfo allocation
process, e.g. in get_thread_ref):

73.4  43.0%  43.0%     73.5  43.1% std::__detail::_Hashtable_alloc::_M_allocate_node
37.2  21.8%  64.8%     37.2  21.8% sinsp_parser::reserve_event_buffer
30.7  18.0%  82.8%    109.9  64.4% sinsp_thread_manager::new_threadinfo

@erthalion erthalion force-pushed the feature/split-user-info branch 4 times, most recently from 8c3f916 to b2120ec Compare April 2, 2024 13:08
@erthalion erthalion force-pushed the feature/split-user-info branch from 2b29682 to 15bed83 Compare April 8, 2024 08:55
sinsp_threadinfo contains two fields with user and login_user
information. Since those fields are of scap_userinfo type and statically
allocated, they take a lot of space:

    scap_userinfo              m_user;               /*   368  2312 */
    scap_userinfo              m_loginuser;          /*  2680  2312 */

which is 4624 bytes out of 5728 for the whole sinsp_threadinfo:

    /* size: 5728, cachelines: 90, members: 64 */

Most of this memory is coming from the fields name
(MAX_CREDENTIALS_STR_LEN), homedir and shell (both SCAP_MAX_PATH_SIZE).
For a process-heavy workload this can mean a lot of memory taken for
these purposes.

To make memory management more flexible, split m_user/m_loginuser into
two set of fields:
* one containing uid/gid, which are ubiquitous and generally used
everywhere
* one for the rest of heavy details, which are needed less often

The new sinsp_userinfo class is not supposed to use separately from
sinsp_threadinfo, thus it's defined inside the class.

Co-authored-by: Mauro Ezequiel Moltrasio <[email protected]>
@erthalion erthalion force-pushed the feature/split-user-info branch from 15bed83 to 947a2ff Compare April 23, 2024 14:43
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