Kaydet (Commit) df6ba650 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove "officially dead now" rtl_cache slab allocator mechanism

...after <https://gerrit.libreoffice.org/#/c/58263/> "the custom SAL allocator
is no longer used" got merged.  According to my July 31, 2018 comment there:

"However, [...] this change is effectively a final coffin nail for the
'rtl_cache' mechanism.  It could be argued that the alleged benefits of that
mechanism (if it were still working) might be real (at least on some platforms;
which would need measurements), and that it should be made working again (by
reverting the effects of both ce906b80 'skip
tricky allocators on G_SLICE=always-malloc' and
bc6a5d8e 'Disable custom allocator' on
rtl_cache_alloc/free again).  But it could just as well be argued that the
'rtl_cache' mechanism is effectively gone for long enough now (since end of
November, 2017, with bc6a5d8e 'Disable custom
allocator') without any (apparent) negative consequences, so that it can be
removed for good with this change."

Change-Id: I8c1e45d494fc22555a9e675ab27be9e6e404abde
Reviewed-on: https://gerrit.libreoffice.org/58369
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 74ea0faf
......@@ -3971,7 +3971,6 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
if (eStage == PRE_INIT)
{
comphelper::ThreadPool::getSharedOptimalPool().shutdown();
rtl_alloc_preInit(rtlAllocPostInit);
}
return bInitialized;
......
......@@ -220,7 +220,7 @@ typedef struct rtl_cache_st rtl_cache_type;
#define RTL_CACHE_NAME_LENGTH 31
#define RTL_CACHE_FLAG_BULKDESTROY 1
#define RTL_CACHE_FLAG_BULKDESTROY 1 /* obsolete */
/**
* @param[in] pName descriptive name; for debugging purposes.
......@@ -230,8 +230,8 @@ typedef struct rtl_cache_st rtl_cache_type;
* @param[in] destructor object destructor callback function.
* @param[in] reclaim reclaim callback function.
* @param[in] pUserArg opaque argument passed to callback functions.
* @param[in] pSource opaque argument passed to callback functions.
* @param[in] nFlags flags.
* @param[in] pSource unused argument (should be null).
* @param[in] nFlags flags (unused).
*
* @return pointer to rtl_cache_type, or NULL upon failure.
*
......@@ -299,16 +299,6 @@ SAL_DLLPUBLIC void SAL_CALL rtl_cache_free (
* spawning per-document instances. This is done
* by calling rtl_alloc_preInit with rtlAllocPreInitStart.
*
* However before forking we need to wind down
* all threads, which is required by design.
* This is done by calling rtl_alloc_preInit
* with rtlAllocPreInitEnd.
*
* And of course the stopped threads need restarting
* after forking to ensure correct cleanup of the
* caches and other memory allocations. This is done
* by calling rtl_alloc_preInit with rtlAllocPostInit.
*
* @since LibreOffice 6.1
*/
typedef enum
......@@ -317,7 +307,7 @@ typedef enum
rtlAllocPreInitStart,
// Finish phase I of pre-init (before forking).
rtlAllocPreInitEnd,
// Post pre-init and after forking.
// Post pre-init and after forking; no longer used.
rtlAllocPostInit
} rtl_alloc_preInit_phase_t;
......
......@@ -26,10 +26,6 @@ void rtl_cache_fini(void);
void ensureCacheSingleton(void);
void rtl_cache_stop_threads(void);
void rtl_cache_start_threads(void);
void rtl_locale_init(void);
void rtl_locale_fini(void);
......
This diff is collapsed.
......@@ -22,133 +22,17 @@
#include <sal/types.h>
#include <rtl/alloc.h>
#include "alloc_impl.hxx"
/**
@internal
*/
struct rtl_cache_stat_type
{
sal_uInt64 m_alloc;
sal_uInt64 m_free;
sal_Size m_mem_total;
sal_Size m_mem_alloc;
};
/**
@internal
*/
struct rtl_cache_bufctl_type
{
rtl_cache_bufctl_type * m_next; /* linkage */
sal_uIntPtr m_addr; /* buffer address */
sal_uIntPtr m_slab; /* parent slab address */
};
/**
@internal
*/
struct rtl_cache_slab_type
{
rtl_cache_slab_type * m_slab_next; /* slab linkage */
rtl_cache_slab_type * m_slab_prev; /* slab linkage */
sal_Size m_ntypes; /* number of buffers used */
sal_uIntPtr m_data; /* buffer start addr */
sal_uIntPtr m_bp; /* free buffer linkage 'base pointer' */
rtl_cache_bufctl_type * m_sp; /* free buffer linkage 'stack pointer' */
};
/**
@internal
*/
#define RTL_CACHE_MAGAZINE_SIZE 61
struct rtl_cache_magazine_type
{
rtl_cache_magazine_type * m_mag_next; /* depot linkage */
sal_Size m_mag_size;
sal_Size m_mag_used;
void * m_objects[RTL_CACHE_MAGAZINE_SIZE];
};
/**
@internal
*/
struct rtl_cache_depot_type
{
/* magazine list */
rtl_cache_magazine_type * m_mag_next; /* linkage */
sal_Size m_mag_count; /* count */
/* working set parameters */
sal_Size m_curr_min;
sal_Size m_prev_min;
};
/**
@internal
*/
#define RTL_CACHE_HASH_SIZE 8
#define RTL_CACHE_FEATURE_HASH 1
#define RTL_CACHE_FEATURE_BULKDESTROY 2
#define RTL_CACHE_FEATURE_RESCALE 4 /* within hash rescale operation */
struct rtl_cache_st
{
/* linkage */
rtl_cache_type * m_cache_next;
rtl_cache_type * m_cache_prev;
/* properties */
char m_name[RTL_CACHE_NAME_LENGTH + 1];
long m_features;
sal_Size m_type_size; /* const */
sal_Size m_type_align; /* const */
sal_Size m_type_shift; /* log2(m_type_size); const */
int (SAL_CALL * m_constructor)(void * obj, void * userarg); /* const */
void (SAL_CALL * m_destructor) (void * obj, void * userarg); /* const */
void * m_userarg;
/* slab layer */
rtl_memory_lock_type m_slab_lock;
rtl_cache_stat_type m_slab_stats;
rtl_arena_type * m_source; /* slab supplier; const */
sal_Size m_slab_size; /* const */
sal_Size m_ntypes; /* number of buffers per slab; const */
sal_Size m_ncolor; /* next slab color */
sal_Size m_ncolor_max; /* max. slab color */
rtl_cache_slab_type m_free_head;
rtl_cache_slab_type m_used_head;
rtl_cache_bufctl_type ** m_hash_table;
rtl_cache_bufctl_type * m_hash_table_0[RTL_CACHE_HASH_SIZE];
sal_Size m_hash_size; /* m_hash_mask + 1 */
sal_Size m_hash_shift; /* log2(m_hash_size) */
/* depot layer */
rtl_memory_lock_type m_depot_lock;
rtl_cache_depot_type m_depot_empty;
rtl_cache_depot_type m_depot_full;
rtl_cache_type * m_magazine_cache; /* magazine supplier; const */
/* cpu layer */
rtl_cache_magazine_type * m_cpu_curr;
rtl_cache_magazine_type * m_cpu_prev;
rtl_cache_stat_type m_cpu_stats;
};
#endif // INCLUDED_SAL_RTL_ALLOC_CACHE_HXX
......
......@@ -118,19 +118,11 @@ void SAL_CALL rtl_alloc_preInit (rtl_alloc_preInit_phase_t phase) SAL_THROW_EXTE
rtl_allocateString = rtl_allocateMemory;
rtl_freeString = rtl_freeMemory;
// Stop the rtl cache thread to have no extra threads while forking.
rtl_cache_stop_threads();
// TODO: also re-initialize main allocator as well.
}
break;
case rtlAllocPostInit:
{
// We have forked and need to restart threads and anything
// that must start after forking.
rtl_cache_start_threads();
}
case rtlAllocPostInit: // no longer used
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment