Skip to content

plug memory profiling into make test target #1141

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

Open
Sashan opened this issue Mar 18, 2025 · 1 comment
Open

plug memory profiling into make test target #1141

Sashan opened this issue Mar 18, 2025 · 1 comment
Assignees

Comments

@Sashan
Copy link

Sashan commented Mar 18, 2025

the libmprofile currently lives in sashan's junk repository (https://github.com/sashan/ossl-scripts/ in folder mprofile) it will be moved. however the library is not needed.

The libmprofile.so is supposed to be loaded via LD_PRELOAD env. variable. Also to produce json output one must also specify MPROFILE_OUTF env. variable which defines path to file where json output will be saved. For example running commands:

export MPROFILE_OUTF=/tmp/openssl-speed-sha256.json
LD_PRELOAD=/path/to/mprofile/libmprofile.so openssl speed -evp sha256

will create .json file with memory profile for openssl speed ... command. To calculate maximum heap size took by process one runs command:

/path/to/mprofile/scripts/mprofile.py -m /tmp/openssl-spped-sha256.json

Keep in mind the resulting .json file is almost 1GB long (it's ~70MB when gziped). So the .json output can take a lot of space.

The plan is to use unit tests we have in openssl/test directory. To obtain memory profile data one would run for example tests like this:

DO_MPROFILE=1 make test

When DO_MPROFILE is 1 the test execution then arranges things such json files are obtained (and perhaps processed too). Perhaps path to libmprofile.so should be also specified in dedicated env. var (for example LIBMPROFILE=/path/to/mprofile/libmprofile.so)

The test binaries are executed by perl test runner found here: util/perl/OpenSSL/Test.pm. There you will find function sub(), app(), test(), ... I think this is the place where to arrange environment so mprofile json data can be obtained.

perhaps the test when running in mprofile mode should process the .json data and delete them after saving results. We are currently interested in mprofile.py -m output only. The result should be saved to test-runs directory. The file with result should be derived from test name for example test_evp.mprofile

We can also expect some hurdles on the way, for example there might be tests which are not libmprofile friendly. So perhaps we should mark such tests in test recipe the profiling should not be performed.

@Sashan Sashan self-assigned this Mar 18, 2025
@github-project-automation github-project-automation bot moved this to Pre-Refinement in Development Board Mar 18, 2025
@andrewkdinh andrewkdinh moved this from Pre-Refinement to In Progress in Development Board Mar 19, 2025
@Sashan
Copy link
Author

Sashan commented Mar 21, 2025

There are actually two kinds of tests in opensl/test directory:

  • tests which are linked with static libcrypto (this seems fairly common)
  • tests which are linked with shared libcrypto (.so), just some tests.

the tests which use dynamic libcrypto can use LD_PRELOAD to start building memory profile using libmprofile.so

for tests which are linked with static version of libcrypto we need to extend libtestutil. However this requires to add compile time option to Configure script (./Configure enable-mprofile).

@nhorman nhorman moved this from In Progress to Blocked in Development Board Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Blocked
Development

No branches or pull requests

2 participants