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
Question: overriding jpeg_get_large #308
Comments
You don't need to re-implement all of I don't think it would be appropriate to enable huge pages in libjpeg-turbo by default. Presumably this would waste memory for smaller images (not good, given libjpeg-turbo's usage in popular web browsers), and given that Also, given that others in the community have encountered a need to override Long story short: your quickest and only free-as-in-beer solution is to clone the |
I did think of that, but this code uses structures from
Sure, my code snippet was a simple example, I didn't claim it was the code to use (otherwise I would have open a PR directly). I agree with all your points around small images and benchmarking.
ACK, thanks for the transparency. |
Good point. I suppose you could include the entirely of jmemmgr.c in your code and change just what you need, but I admit that that's yucky.
Yeah, sorry about that. :( Unfortunately the only way I get paid for my work on libjpeg-turbo is through funded development. I've spent thousands of hours of pro bono work getting the project to where it is now, but as a result, I've created a financial hardship for myself, so I can't do any pro bono work on it anymore. I'm really hoping some benevolent corporation or other organization will recognize the precarious nature of this project and step forward to fully fund it, which is why I keep mentioning the funding situation every chance I get. |
Request
I'm trying to swap the implementation of
jpeg_get_large
to not use the defaultmalloc
call. So far I see the following options:jmemnobs.c
and building a customizedlibjpeg-turbo
for my project.LD_PRELOAD
at runtime. Not very convenient to use.jpeg_memory_mgr
. I believe this would mean re-implementing all the pool logic. This seems unnecessary complicated just to changejpeg_get_large
.Is there another way? Should there be another way?
Background
For our workloads, we have determined it's better to run with
transparent_hugepage
set tomadvise
instead ofalways
. You can find multiple summaries on this topic through Google, and many projects recommend disabling it:https://alexandrnikitin.github.io/blog/transparent-hugepages-measuring-the-performance-impact/
For
libjpeg-turbo
, this has a significant impact on performance for (very) large images, since a regularmalloc
is used:As you can see, there is 200x more page faults without transparent huge pages, yielding an execution time slower by one second.
If I recompile
libjpeg-turbo
to usemadvise
, I get similar performance as with THP set toalways
.Solutions
@dcommander if you agree we should try to fix this besides the solutions a) b) and c) above, I see two options:
jpeg_get_large
could be modified to use eitherposix_memalign+madvise
ormmap+madvise
. Possibly behind aifdef
tied to a cmake configuration flag.jpeg_get_large
/jpeg_get_small
could be madeweak
symbols so that users can override them with their own implementation.The text was updated successfully, but these errors were encountered: