Skip to content

Commit

Permalink
tune memory manager for BROTLI_EXPERIMENTAL
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 560703386
  • Loading branch information
eustas authored and Copybara-Service committed Aug 28, 2023
1 parent c1bd196 commit e7313b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 2 additions & 9 deletions c/enc/encode.c
Expand Up @@ -1836,15 +1836,8 @@ BROTLI_BOOL BrotliEncoderAttachPreparedDictionary(BrotliEncoderState* state,
size_t BrotliEncoderEstimatePeakMemoryUsage(int quality, int lgwin,
size_t input_size) {
BrotliEncoderParams params;
size_t memory_manager_slots = 0;
size_t memory_manager_size = 0;
#if !defined(BROTLI_ENCODER_EXIT_ON_OOM)
memory_manager_slots = 256;
#if defined(BROTLI_EXPERIMENTAL)
memory_manager_slots = 32768;
#endif /* BROTLI_EXPERIMENTAL */
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */
memory_manager_size = memory_manager_slots * sizeof(void*);
size_t memory_manager_slots = BROTLI_ENCODER_MEMORY_MANAGER_SLOTS;
size_t memory_manager_size = memory_manager_slots * sizeof(void*);
BrotliEncoderInitParams(&params);
params.quality = quality;
params.lgwin = lgwin;
Expand Down
4 changes: 3 additions & 1 deletion c/enc/memory.h
Expand Up @@ -26,10 +26,12 @@ extern "C" {

#if !defined(BROTLI_ENCODER_EXIT_ON_OOM)
#if defined(BROTLI_EXPERIMENTAL)
#define BROTLI_ENCODER_MEMORY_MANAGER_SLOTS 32768
#define BROTLI_ENCODER_MEMORY_MANAGER_SLOTS (48*1024)
#else /* BROTLI_EXPERIMENTAL */
#define BROTLI_ENCODER_MEMORY_MANAGER_SLOTS 256
#endif /* BROTLI_EXPERIMENTAL */
#else /* BROTLI_ENCODER_EXIT_ON_OOM */
#define BROTLI_ENCODER_MEMORY_MANAGER_SLOTS 0
#endif /* BROTLI_ENCODER_EXIT_ON_OOM */

typedef struct MemoryManager {
Expand Down

0 comments on commit e7313b0

Please sign in to comment.