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

how to compile with nginx? #644

Open
osevan opened this issue Oct 12, 2023 · 5 comments
Open

how to compile with nginx? #644

osevan opened this issue Oct 12, 2023 · 5 comments

Comments

@osevan
Copy link

osevan commented Oct 12, 2023

I want compile with nginx source, but not with .so or .a file i want compile buildin directly in nginx source to get maximum performance.

I dont want configure --with-ld-opt="-lsnmalloc"

I want directly embedded inside nginx compile toolchain.
How i can do this?

Thanks and

best regards

@mjp41
Copy link
Member

mjp41 commented Oct 12, 2023

I haven't tried, but I would start by adding the .a but built with -DSNMALLOC_IPO=On. This should build a LTO/IPO enabled include, and then you can try that. This is not an option that is in the test harness, and I don't personally use it, so it might or might not work.

An alternative would be to add
src/snmalloc/override/malloc.cc

to the build, and enable LTO. If it is a C++ project, then you might want to override new/delete. So you can include:

src/snmalloc/override/new.cc

instead of the malloc.cc unit. The new.cc includes malloc.cc already.

Please, let us know how you get on.

@osevan
Copy link
Author

osevan commented Oct 12, 2023

Could you try make patch for nginx

And we could point snmalloc sources at configure level to solve this

@mjp41
Copy link
Member

mjp41 commented Oct 12, 2023

I suggest you benchmark with LD_PRELOAD, and if that demonstrates that there is a win in using snmalloc. Removing the PLT indirection will improve performance, but if the different allocators you try are all going via a PLT indirection then it should be a relatively fair comparison to then decide if you want to do additional work to remove the PLT indirection.

@osevan
Copy link
Author

osevan commented Oct 12, 2023

Snmalloc will be nice .

I know that very well

@mjp41
Copy link
Member

mjp41 commented Oct 12, 2023

So I quickly tried the IPO option it seems to work, but doesn't give any inline above using the .a in the application I used.

 cmake -DSNMALLOC_IPO=On .. -DCMAKE_CXX_COMPILER=clang++ -GNinja -DSNMALLOC_STATIC_LIBRARY_PREFIX=""

will build

libsnmallocshim-static.a

which you can add to your build like

clang++ -flto test.cc -O3 libsnmallocshim-static.a -O test

But I don't see any advantage in the disassembly over not using IPO.

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

No branches or pull requests

2 participants