Skip to content

Commit

Permalink
Reduce number of sections GC-ed at strip phase for jxl_dec (#3990)
Browse files Browse the repository at this point in the history
(cherry picked from commit fcab7df75647bb96da3469e3b20e8ce47b622203)
  • Loading branch information
eustas committed Dec 6, 2024
1 parent 58dcb76 commit 008f671
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/base/data_parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

namespace jxl {

struct ThreadPoolNoInit {};

class ThreadPool {
public:
ThreadPool(JxlParallelRunner runner, void* runner_opaque)
Expand Down Expand Up @@ -77,7 +79,7 @@ class ThreadPool {
}

// Use this as init_func when no initialization is needed.
static Status NoInit(size_t num_threads) { return true; }
static constexpr ThreadPoolNoInit NoInit{};

private:
// class holding the state of a Run() call to pass to the runner_ as an
Expand Down Expand Up @@ -137,6 +139,14 @@ Status RunOnPool(ThreadPool* pool, const uint32_t begin, const uint32_t end,
}
}

template <class DataFunc>
Status RunOnPool(ThreadPool* pool, const uint32_t begin, const uint32_t end,
const ThreadPoolNoInit& no_init_func,
const DataFunc& data_func, const char* caller) {
const auto init_func = [](size_t num_threads) -> Status { return true; };
return RunOnPool(pool, begin, end, init_func, data_func, caller);
}

} // namespace jxl
#if JXL_COMPILER_MSVC
#pragma warning(default : 4180)
Expand Down
4 changes: 4 additions & 0 deletions lib/jxl_lists.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ libjxl_dec_sources = [
"jxl/dct_util.h",
"jxl/dec_ans.cc",
"jxl/dec_ans.h",
"jxl/dec_bit_reader.cc",
"jxl/dec_bit_reader.h",
"jxl/dec_cache.cc",
"jxl/dec_cache.h",
Expand Down Expand Up @@ -227,6 +228,8 @@ libjxl_dec_sources = [
"jxl/modular/transform/rct.h",
"jxl/modular/transform/squeeze.cc",
"jxl/modular/transform/squeeze.h",
"jxl/modular/transform/squeeze_params.cc",
"jxl/modular/transform/squeeze_params.h",
"jxl/modular/transform/transform.cc",
"jxl/modular/transform/transform.h",
"jxl/noise.h",
Expand All @@ -246,6 +249,7 @@ libjxl_dec_sources = [
"jxl/render_pipeline/low_memory_render_pipeline.h",
"jxl/render_pipeline/render_pipeline.cc",
"jxl/render_pipeline/render_pipeline.h",
"jxl/render_pipeline/render_pipeline_stage.cc",
"jxl/render_pipeline/render_pipeline_stage.h",
"jxl/render_pipeline/simple_render_pipeline.cc",
"jxl/render_pipeline/simple_render_pipeline.h",
Expand Down
4 changes: 4 additions & 0 deletions lib/jxl_lists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ set(JPEGXL_INTERNAL_DEC_SOURCES
jxl/dct_util.h
jxl/dec_ans.cc
jxl/dec_ans.h
jxl/dec_bit_reader.cc
jxl/dec_bit_reader.h
jxl/dec_cache.cc
jxl/dec_cache.h
Expand Down Expand Up @@ -227,6 +228,8 @@ set(JPEGXL_INTERNAL_DEC_SOURCES
jxl/modular/transform/rct.h
jxl/modular/transform/squeeze.cc
jxl/modular/transform/squeeze.h
jxl/modular/transform/squeeze_params.cc
jxl/modular/transform/squeeze_params.h
jxl/modular/transform/transform.cc
jxl/modular/transform/transform.h
jxl/noise.h
Expand All @@ -246,6 +249,7 @@ set(JPEGXL_INTERNAL_DEC_SOURCES
jxl/render_pipeline/low_memory_render_pipeline.h
jxl/render_pipeline/render_pipeline.cc
jxl/render_pipeline/render_pipeline.h
jxl/render_pipeline/render_pipeline_stage.cc
jxl/render_pipeline/render_pipeline_stage.h
jxl/render_pipeline/simple_render_pipeline.cc
jxl/render_pipeline/simple_render_pipeline.h
Expand Down
4 changes: 4 additions & 0 deletions lib/lib.gni
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ libjxl_dec_sources = [
"jxl/dct_util.h",
"jxl/dec_ans.cc",
"jxl/dec_ans.h",
"jxl/dec_bit_reader.cc",
"jxl/dec_bit_reader.h",
"jxl/dec_cache.cc",
"jxl/dec_cache.h",
Expand Down Expand Up @@ -230,6 +231,8 @@ libjxl_dec_sources = [
"jxl/modular/transform/rct.h",
"jxl/modular/transform/squeeze.cc",
"jxl/modular/transform/squeeze.h",
"jxl/modular/transform/squeeze_params.cc",
"jxl/modular/transform/squeeze_params.h",
"jxl/modular/transform/transform.cc",
"jxl/modular/transform/transform.h",
"jxl/noise.h",
Expand All @@ -249,6 +252,7 @@ libjxl_dec_sources = [
"jxl/render_pipeline/low_memory_render_pipeline.h",
"jxl/render_pipeline/render_pipeline.cc",
"jxl/render_pipeline/render_pipeline.h",
"jxl/render_pipeline/render_pipeline_stage.cc",
"jxl/render_pipeline/render_pipeline_stage.h",
"jxl/render_pipeline/simple_render_pipeline.cc",
"jxl/render_pipeline/simple_render_pipeline.h",
Expand Down

0 comments on commit 008f671

Please sign in to comment.