diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2013-05-13 15:22:24 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-05-13 15:27:18 -0500 |
commit | 035873283b3f7514ad77d409870ccfd5f9680d9e (patch) | |
tree | c7b21f32c53e37dc7da2030debe1ecbaae98384a /include/qom | |
parent | b087143b4d010451208264b7c841436aafe1cbb1 (diff) | |
download | qemu-035873283b3f7514ad77d409870ccfd5f9680d9e.zip qemu-035873283b3f7514ad77d409870ccfd5f9680d9e.tar.gz qemu-035873283b3f7514ad77d409870ccfd5f9680d9e.tar.bz2 |
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>
Diffstat (limited to 'include/qom')
-rw-r--r-- | include/qom/object.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/qom/object.h b/include/qom/object.h index 63e2a40..23fc048 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -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; }; |