mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
qom: aggressively optimize qom casting
This patch adds a small typename cache to ObjectClass. This allows caching positive casts within each ObjectClass. Benchmarking a PPC workload provided by Aurelien, this patch eliminates every single g_hash_table_lookup() happening during the benchmark (which was about 2 million per-second). With this patch applied, I get exactly the same performance (within the margin of error) as with --disable-qom-cast-debug. N.B. it's safe to cache typenames only from the _assert() macros because they are always called with string literals. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
b087143b4d
commit
035873283b
2 changed files with 42 additions and 2 deletions
|
@ -344,6 +344,8 @@ typedef void (ObjectUnparent)(Object *obj);
|
|||
*/
|
||||
typedef void (ObjectFree)(void *obj);
|
||||
|
||||
#define OBJECT_CLASS_CAST_CACHE 4
|
||||
|
||||
/**
|
||||
* ObjectClass:
|
||||
*
|
||||
|
@ -356,6 +358,8 @@ struct ObjectClass
|
|||
Type type;
|
||||
GSList *interfaces;
|
||||
|
||||
const char *cast_cache[OBJECT_CLASS_CAST_CACHE];
|
||||
|
||||
ObjectUnparent *unparent;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue