summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/ipeEventLog_fromMap.c
diff options
context:
space:
mode:
authorSven Tennie <sven.tennie@gmail.com>2021-05-13 15:26:32 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-08-11 18:14:30 -0400
commitf5fdace5613914724eb00bcf7547c82f3ad12686 (patch)
treeeeaeb36a5b79192c19eed847a2663e13fbf8b1f8 /testsuite/tests/rts/ipeEventLog_fromMap.c
parentc65a7ffa7d8962f769bfe1dfbad20e32e1709c20 (diff)
downloadhaskell-f5fdace5613914724eb00bcf7547c82f3ad12686.tar.gz
Optimize Info Table Provenance Entries (IPEs) Map creation and lookup
Using a hash map reduces the complexity of lookupIPE(), making it non linear. On registration each IPE list is added to a temporary IPE lists buffer, reducing registration time. The hash map is built lazily on first lookup. IPE event output to stderr is added with tests. For details, please see Note [The Info Table Provenance Entry (IPE) Map]. A performance test for IPE registration and lookup can be found here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5724#note_370806
Diffstat (limited to 'testsuite/tests/rts/ipeEventLog_fromMap.c')
-rw-r--r--testsuite/tests/rts/ipeEventLog_fromMap.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/testsuite/tests/rts/ipeEventLog_fromMap.c b/testsuite/tests/rts/ipeEventLog_fromMap.c
new file mode 100644
index 0000000000..5bd9e4d034
--- /dev/null
+++ b/testsuite/tests/rts/ipeEventLog_fromMap.c
@@ -0,0 +1,35 @@
+#include "Rts.h"
+#include "RtsAPI.h"
+#include "rts/IPE.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern void dumpIPEToEventLog(void);
+InfoProvEnt *makeAnyProvEntry(Capability *cap, int i);
+
+int main(int argc, char *argv[]) {
+ hs_init(&argc, &argv);
+ Capability *cap = rts_lock();
+
+ HaskellObj one = rts_mkInt(cap, 1);
+
+ InfoProvEnt *provEnt_0 = makeAnyProvEntry(cap, 0);
+ InfoProvEnt *provEnt_1 = makeAnyProvEntry(cap, 1);
+
+ InfoProvEnt **ipeList_1 = malloc(sizeof(InfoProvEnt *) * 3);
+ ipeList_1[0] = provEnt_0;
+ ipeList_1[1] = provEnt_1;
+ ipeList_1[2] = NULL;
+
+ registerInfoProvList(ipeList_1);
+
+ // Query an IPE to initialize the underlying hash map.
+ lookupIPE(ipeList_1[0]->info);
+
+ // Trace all IPE events.
+ dumpIPEToEventLog();
+
+ rts_unlock(cap);
+ hs_exit();
+}