i#2717 shrink static DR library: do not initialize dynamo_options sta…#2797
i#2717 shrink static DR library: do not initialize dynamo_options sta…#2797nilayvaish wants to merge 9 commits into
Conversation
…tically. We currently initialize dynamo_options at the time of declaration. This is not required since the initialization is same as default_options variable. Instead, we now copy the default_options to dynamo_options in the function options_init(). This saves about 27,020 bytes of space. Before: -r-xr-xr-x 1 nilayvaish eng 2594134 Nov 24 23:37 blaze-bin/third_party/dynamorio/libdynamorio.a After: -r-xr-xr-x 1 nilayvaish eng 2567114 Nov 25 12:32 blaze-bin/third_party/dynamorio/libdynamorio.a Issue: #2717
fhahn
left a comment
There was a problem hiding this comment.
Looks reasonable to me, thanks!
Could you please shorten the title of the PR a bit? It's too long and parts got spilled in the description.
| # ifdef DEBUG | ||
| /* FIXME: share code w/ main init routine? */ | ||
| nonshared_stats.logmask = LOG_ALL; | ||
| /* Why do we need this to options_init()? We did so above. */ |
There was a problem hiding this comment.
It does not look like options_init directly depends on anything set by the functions above, but maybe one of the functions it calls does. If this call is really needed, it might be problematic, as it replaces all options set previously by the default options. @derekbruening do you know if it would be safe to drop this call?
There was a problem hiding this comment.
Out sick, will try to take a look tomorrow
There was a problem hiding this comment.
The -stats_logmask option sets stats->logmask and stats == nonshared_stats so there is a connection. The default logmask has to be set before calling options_init(). I believe this was the original call, and the one above was added later. I think the logmask setting on line 890 needs to be moved up above the options_init() on line 869, and then the options_init() here can be removed.
| /* .lspdata pages start out writable so no unprotect needed here */ | ||
| write_lock(&options_lock); | ||
| ASSERT(sizeof(dynamo_options) == sizeof(options_t)); | ||
| /* Set to default options. */ |
There was a problem hiding this comment.
This changes the behavior of options_init. Maybe add a comment to the documentation of the function to make it clear that all previously set options will be overwritten by the default values?
| options_init(); | ||
| #if defined(INTERNAL) && defined(DEADLOCK_AVOIDANCE) | ||
| /* avoid issues w/ GLOBAL_DCONTEXT instead of thread dcontext */ | ||
| dynamo_options.deadlock_avoidance = false; |
There was a problem hiding this comment.
Hmm, this now clobbers the final value, so the user cannot override -- I don't think deadlock detection code works for standalone mode anyway, but this new behavior of silently ignoring a requested option is not ideal. Maybe the better solution is to move this into optionsx.h with IF_STANDALONE_ELSE or sthg.
| write_lock(&options_lock); | ||
| ASSERT(sizeof(dynamo_options) == sizeof(options_t)); | ||
| /* Set to default options. */ | ||
| dynamo_options = default_options; |
There was a problem hiding this comment.
Seems cleaner to use set_dynamo_options_defaults(), and then remove the call to adjust_defaults_for_page_size() below.
| # ifdef DEBUG | ||
| /* FIXME: share code w/ main init routine? */ | ||
| nonshared_stats.logmask = LOG_ALL; | ||
| /* Why do we need this to options_init()? We did so above. */ |
There was a problem hiding this comment.
The -stats_logmask option sets stats->logmask and stats == nonshared_stats so there is a connection. The default logmask has to be set before calling options_init(). I believe this was the original call, and the one above was added later. I think the logmask setting on line 890 needs to be moved up above the options_init() on line 869, and then the options_init() here can be removed.
…i2717-options-init
We currently initialize dynamo_options at the time of declaration. This is not required since the initialization is same as default_options variable. Instead, we now copy the default_options to dynamo_options in the function options_init(). This saves about 27,020 bytes of space. Before: -r-xr-xr-x 1 nilayvaish eng 2594134 Nov 24 23:37 dynamorio/libdynamorio.a After: -r-xr-xr-x 1 nilayvaish eng 2567114 Nov 25 12:32 dynamorio/libdynamorio.a Issue: #2717
| #endif | ||
|
|
||
| #ifdef DEADLOCK_AVOIDANCE | ||
| # ifdef STANDALONE_UNIT_TEST |
There was a problem hiding this comment.
Sorry, my suggestion of changing the default here will not work -- this define is only for unit tests, while this needs to be done for standalone mode in general which has no separate define.
…i2717-options-init
…i2717-options-init
Almost everything fails with PR when running on Windows. One of the errors reported was 'access violation'. Restoring the code that only releases the writer lock on options variable. Earlier we had made them readable as well.
|
Currently, with this patch exactly one (non-flaky) test fails: debug-internal-64: linux.execve64. Here is the reason for failure:
As can be seen above, the difference is the failure to pre-load libdrpreload.so. I don't know how this change affects the existence of this file. @derekbruening , can you take a look? What am I missing? |
|
The preload library shouldn't be used by default, so maybe the early inject option is being lost somewhere and it thinks the user requested late injection. You're not able to reproduce the failure locally? |
…i2717-options-init
|
No. I am not able to reproduce it locally. I'll try to figure out the control flow and see where inject option is being changed. Also, thanks for fixing the gcc6 build issues. Earlier, I had to comment out certain portions in the build files to make the build go through. Now, the everything compiles cleanly. |
…tically.
We currently initialize dynamo_options at the time of declaration. This
is not required since the initialization is same as default_options
variable. Instead, we now copy the default_options to dynamo_options in
the function options_init(). This saves about 27,020 bytes of space.
Before:
-r-xr-xr-x 1 nilayvaish eng 2594134 Nov 24 23:37
blaze-bin/third_party/dynamorio/libdynamorio.a
After:
-r-xr-xr-x 1 nilayvaish eng 2567114 Nov 25 12:32
blaze-bin/third_party/dynamorio/libdynamorio.a
Issue: #2717