mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
Add prefetching on strings before hashing
Turns out that the hotspots of nasm are mainly on string hashing when accessing memory. A simple performance improvement is to prefetch the first cacheline of a string to be hashed. Ran 50 tests on an i9-12900 building intel-ipsec-mb that heavily uses nasm and improved wall clock build times from 56.1 seconds to 53.2 seconds or around 5% speed improvement. Signed-off-by: Colin Ian King <colin.i.king@intel.com>
This commit is contained in:
committed by
H. Peter Anvin
parent
6f48f8f7b7
commit
d6dc97dfc0
@@ -80,6 +80,8 @@ void **hash_findb(struct hash_table *head, const void *key,
|
|||||||
void **hash_find(struct hash_table *head, const char *key,
|
void **hash_find(struct hash_table *head, const char *key,
|
||||||
struct hash_insert *insert)
|
struct hash_insert *insert)
|
||||||
{
|
{
|
||||||
|
__builtin_prefetch(key);
|
||||||
|
|
||||||
return hash_findb(head, key, strlen(key)+1, insert);
|
return hash_findb(head, key, strlen(key)+1, insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +126,8 @@ void **hash_findib(struct hash_table *head, const void *key, size_t keylen,
|
|||||||
void **hash_findi(struct hash_table *head, const char *key,
|
void **hash_findi(struct hash_table *head, const char *key,
|
||||||
struct hash_insert *insert)
|
struct hash_insert *insert)
|
||||||
{
|
{
|
||||||
|
__builtin_prefetch(key);
|
||||||
|
|
||||||
return hash_findib(head, key, strlen(key)+1, insert);
|
return hash_findib(head, key, strlen(key)+1, insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,6 +48,8 @@ strlist_add(struct strlist *list, const char *str)
|
|||||||
struct hash_insert hi;
|
struct hash_insert hi;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
|
__builtin_prefetch(str);
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user