-
Notifications
You must be signed in to change notification settings - Fork 35
Add proxy library (for Linux only now) #226
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
Conversation
0485390
to
2e549bc
Compare
253de2c
to
cdb5445
Compare
81b5d11
to
0551c74
Compare
@igchor There is an issue with #229. I run ubench with proxy library in LD_PRELOAD:
|
0551c74
to
c3f349c
Compare
c3f349c
to
7090d5e
Compare
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
7090d5e
to
1837bc3
Compare
1837bc3
to
79c32f5
Compare
This seems to be caused by the fact that we include stdlib.h where malloc and others are defined (probably with dllimport). The fix is to not include stdlib.h in the file that implements proxy_lib |
79c32f5
to
5256637
Compare
fc609d5
to
8d15fb9
Compare
To be honest, I think it SHOULD work in this scenario. If both proxy_lib and app uses libumf.so (dynamic lib) then there should be only one base_alloc and tracker. I think there is some other issue that we should solve here. |
The occurring issues can be caused by the fact that there is only one base_alloc and one tracker in case of dynamic linking. I think that the proxy library should use a separate base_alloc and a separate tracker than an app. |
Did we discussed the scenarios that we are going to cover with this proxy library at our Memory WG? We also have not discussed the architecture and potential issues. Probably TBB malloc already solves such issues somehow, we have not investigated this. Furthermore, if we consider migrating TBB malloc and building it on top of UMF then there is a TBB malloc proxy that intercepts regular malloc/free flow- do we need to duplicate such functionality with umf_proxy? Why not to discuss this first and get feedback from our Memory WG attendees? Do we have any urgency with this proxy library? |
886c2ae
to
43f80ca
Compare
@bratpiorka @igchor The proxy library with scalable pool works well. |
43f80ca
to
cec6bd4
Compare
For now that's fine I think. But we should add some extra tests with a lot of mallocs/callocs/reallocs (even from multiple threads) as a next step. |
@bratpiorka @igchor Moreover, for the same reason we cannot destroy the UMF pool either! It turned out that in the phase of loading libraries, when allocations come from the UMF pool, the program loader (maybe _dl_init()) allocates new memory for the app's environment that is read at the very end after unloading most of libraries - |
16633ba
to
4b246b2
Compare
The proxy library works correctly with all following applications now: $ LD_PRELOAD=./lib/libumf_proxy.so ctest --output-on-failure
$ LD_PRELOAD=./lib/libumf_proxy.so ./benchmark/ubench
$ LD_PRELOAD=./lib/libumf_proxy.so ./test/umf_test-memoryPool
$ LD_PRELOAD=./lib/libumf_proxy.so /usr/bin/ls
$ LD_PRELOAD=./lib/libumf_proxy.so /usr/bin/date |
With the latest changes LGTM. We should make more improvements in separate PRs. |
#endif /* _WIN32 */ | ||
|
||
// check if we are running in the proxy library | ||
static inline int is_running_in_proxy_lib(void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work if someone links with proxy_lib? (I think we should support this scenario - from what I understand, this is how it will work on windows) Or is there no problem in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, it would be nice to have a test for such scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work if someone links with proxy_lib? (I think we should support this scenario - from what I understand, this is how it will work on windows) Or is there no problem in that case?
Do you mean the dynamic linking instead of LD_PRELOD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Add umf_ba_linear_pool_contains_pointer(). It returns: - 0 if ptr does not belong to the pool or - size (> 0) of the memory region from ptr to the end of the pool if ptr belongs to the pool. It will be useful to implement realloc() in the proxy library. Added also the baseAllocLinearPoolContainsPointer test. Signed-off-by: Lukasz Dorau <[email protected]>
4b246b2
to
a538b33
Compare
UMF proxy library is a library for intercepting user allocation requests. It intercepts following APIs: - aligned_alloc() - calloc() - free() - malloc() - malloc_usable_size() - realloc() Signed-off-by: Lukasz Dorau <[email protected]>
a538b33
to
47a98a4
Compare
Thx! LGTM |
Ref: #240