Skip to content

Malloc conf cleanup#78

Merged
lexprfuncall merged 2 commits intofacebook:devfrom
lexprfuncall:malloc-conf-cleanup
Mar 10, 2026
Merged

Malloc conf cleanup#78
lexprfuncall merged 2 commits intofacebook:devfrom
lexprfuncall:malloc-conf-cleanup

Conversation

@lexprfuncall
Copy link

This change moves the configuration code out of the initialization
code and into its own source code module that can be tested in
isolation. In addition to extracting the code, tests for the option
parsing have been added.

@meta-cla meta-cla bot added the cla signed label Feb 28, 2026
@lexprfuncall lexprfuncall force-pushed the malloc-conf-cleanup branch 2 times, most recently from 0011bbe to 9ae3e7d Compare March 2, 2026 21:20
}

void
malloc_conf_init(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
Copy link

@guangli-dai guangli-dai Mar 3, 2026

Choose a reason for hiding this comment

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

As the only public interface of conf.h, maybe we can add a unit test for it as well? While most underneath logic is already covered by the current unit tests, the only one left would be to check if the two ordered calls to malloc_conf_init_helper is working properly, i.e., some options should be checked first before others.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, test coverage has now been added.

@guangli-dai
Copy link

Two more general questions: 1. regarding the naming, would it be better if we call the new files jemalloc_opts.h/c? Is that easier to understand at first glance since we have similar hpa_opts.h; 2. Maybe not in this PR, but just thinking if we can abstract the list of options out for easier checking instead of having them scattered?

@lexprfuncall lexprfuncall force-pushed the malloc-conf-cleanup branch from 9ae3e7d to 33f4441 Compare March 5, 2026 23:56
#include "test/jemalloc_test.h"

const char *malloc_conf = "dirty_decay_ms:1234,muzzy_decay_ms:2000";
const char *malloc_conf_2_conf_harder = "dirty_decay_ms:5678";

Choose a reason for hiding this comment

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

Other tests, especially conf_init_confirm, test are good. This test seems to serve the same purpose as malloc_conf_2.c but this new one is more extended. Keeping only one of them is good?

Copy link
Author

Choose a reason for hiding this comment

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

The difference is that the malloc_conf test uses the environment variable and my tests do not. But it was my intention to carry over that functionality, I just forgot about that detail. Let me fix that.

Copy link
Author

Choose a reason for hiding this comment

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

I opted to delete the new test and expand the coverage of the existing malloc_conf_2 test that test the environment variable.

@lexprfuncall
Copy link
Author

Two more general questions: 1. regarding the naming, would it be better if we call the new files jemalloc_opts.h/c? Is that easier to understand at first glance since we have similar hpa_opts.h; 2. Maybe not in this PR, but just thinking if we can abstract the list of options out for easier checking instead of having them scattered?

I'd hope that HPA opts goes away through a rationalization of our implementation. That said, along the lines of what you suggest, I think there is a need for a bigger rationalization of the configuration support. Let's make it a topic for discussion in the near future.

@lexprfuncall lexprfuncall merged commit 6642deb into facebook:dev Mar 10, 2026
155 of 156 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants