[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/hash-table-perf e53398ab698 26/35: ; Reorder structs (hash and t
From: |
Mattias Engdegård |
Subject: |
scratch/hash-table-perf e53398ab698 26/35: ; Reorder structs (hash and test) |
Date: |
Thu, 4 Jan 2024 10:56:43 -0500 (EST) |
branch: scratch/hash-table-perf
commit e53398ab69889c1876fa5b511e254bde2c4d1fac
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
; Reorder structs (hash and test)
Mainly for efficiency, to keep frequently used fields together.
---
src/fns.c | 12 ++++++------
src/lisp.h | 38 +++++++++++++++++---------------------
2 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/src/fns.c b/src/fns.c
index 6b797b18e5e..1a73353b70d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4493,12 +4493,12 @@ hashfn_user_defined (Lisp_Object key, struct
Lisp_Hash_Table *h)
}
struct hash_table_test const
- hashtest_eq = { LISPSYM_INITIALLY (Qeq), LISPSYM_INITIALLY (Qnil),
- LISPSYM_INITIALLY (Qnil), 0, hashfn_eq },
- hashtest_eql = { LISPSYM_INITIALLY (Qeql), LISPSYM_INITIALLY (Qnil),
- LISPSYM_INITIALLY (Qnil), cmpfn_eql, hashfn_eql },
- hashtest_equal = { LISPSYM_INITIALLY (Qequal), LISPSYM_INITIALLY (Qnil),
- LISPSYM_INITIALLY (Qnil), cmpfn_equal, hashfn_equal };
+ hashtest_eq = { .name = LISPSYM_INITIALLY (Qeq),
+ .cmpfn = 0, .hashfn = hashfn_eq },
+ hashtest_eql = { .name = LISPSYM_INITIALLY (Qeql),
+ .cmpfn = cmpfn_eql, .hashfn = hashfn_eql },
+ hashtest_equal = { .name = LISPSYM_INITIALLY (Qequal),
+ .cmpfn = cmpfn_equal, .hashfn = hashfn_equal };
/* Allocate basically initialized hash table. */
diff --git a/src/lisp.h b/src/lisp.h
index 1cee9b5d427..00d03ccb9e5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2397,9 +2397,11 @@ typedef enum {
struct hash_table_test
{
- /* FIXME: reorder for efficiency */
- /* Function used to compare keys; always a bare symbol. */
- Lisp_Object name;
+ /* C function to compute hash code. */
+ hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
+
+ /* C function to compare two keys. */
+ Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *);
/* User-supplied hash function, or nil. */
Lisp_Object user_hash_function;
@@ -2407,11 +2409,8 @@ struct hash_table_test
/* User-supplied key comparison function, or nil. */
Lisp_Object user_cmp_function;
- /* C function to compare two keys. */
- Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *);
-
- /* C function to compute hash code. */
- hash_hash_t (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
+ /* Function used to compare keys; always a bare symbol. */
+ Lisp_Object name;
};
typedef enum {
@@ -2437,9 +2436,6 @@ typedef ptrdiff_t hash_idx_t;
struct Lisp_Hash_Table
{
- /* Change pdumper.c if you change the fields here. */
-
- /* This is for Lisp; the hash table code does not refer to it. */
union vectorlike_header header;
hash_idx_t index_size; /* Size of the index vector. */
@@ -2455,6 +2451,16 @@ struct Lisp_Hash_Table
This vector is table_size entries long. */
hash_hash_t *hash;
+ /* Vector of keys and values. The key of item I is found at index
+ 2 * I, the value is found at index 2 * I + 1.
+ If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
+ This is gc_marked specially if the table is weak.
+ This vector is 2 * table_size entries long. */
+ Lisp_Object *key_and_value;
+
+ /* The comparison and hash functions. */
+ const struct hash_table_test *test;
+
/* Vector used to chain entries. If entry I is free, next[I] is the
entry number of the next free item. If entry I is non-free,
next[I] is the index of the next entry in the collision chain,
@@ -2483,16 +2489,6 @@ struct Lisp_Hash_Table
immutable for recursive attempts to mutate it. */
bool mutable;
- /* Vector of keys and values. The key of item I is found at index
- 2 * I, the value is found at index 2 * I + 1.
- If the key is HASH_UNUSED_ENTRY_KEY, then this slot is unused.
- This is gc_marked specially if the table is weak.
- This vector is 2 * table_size entries long. */
- Lisp_Object *key_and_value;
-
- /* The comparison and hash functions. */
- const struct hash_table_test *test;
-
/* Next weak hash table if this is a weak hash table. The head of
the list is in weak_hash_tables. Used only during garbage
collection --- at other times, it is NULL. */
- scratch/hash-table-perf 31950946290 04/35: Refactor: less egregious layering violation in composite.h, (continued)
- scratch/hash-table-perf 31950946290 04/35: Refactor: less egregious layering violation in composite.h, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf e2a6ce36d83 03/35: Decouple profiler from Lisp hash table internals, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 9141966be51 09/35: ; * src/alloc.c (purecopy_hash_table): Simplify, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf fdc390f8dc0 10/35: Abstract predicate and constant for unused hash keys, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf c4df6041de8 12/35: * src/print.c (print_object): Don't print hash table test if `eql`., Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf f3e985a16ba 14/35: Don't print or read the hash table size parameter, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 1ebd00f6d0a 21/35: Retype hash interfaces to use EMACS_UINT instead of Lisp fixnum, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf fc68176120f 24/35: Use hash_hash_t for storing hash values, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 4b5d9f92abe 13/35: * src/print.c (print_object): Don't print empty hash-table data, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 310f6584ccb 18/35: Allow zero hash table size, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf e53398ab698 26/35: ; Reorder structs (hash and test),
Mattias Engdegård <=
- scratch/hash-table-perf 4e8d7725fd4 11/35: ; * src/fns.c (Fmake_hash_table): ensure `test` is a bare symbol, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 8335891387a 22/35: Inlined and specialised hash table look-up, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 54807fee4d0 23/35: Use hash_idx_t for storing hash indices, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 8cd35079f4c 34/35: Don't pretend that hash-table-size is useful, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf e6defe82569 27/35: Change default hash table size to 8 (from 65), Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 422c91a822a 02/35: ; * src/pdumper.c (dump_hash_table): Remove unused argument., Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 3d2042c48a6 07/35: Refactor: extract hash index computation to a function, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf c188b9f2bf5 08/35: Refactor hash table vector reallocation, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 6ffbccbf1dd 15/35: Represent hash table weakness as an enum internally, Mattias Engdegård, 2024/01/04
- scratch/hash-table-perf 3e9e68333ae 16/35: Remove rehash-threshold and rehash-size struct members, Mattias Engdegård, 2024/01/04