diff options
author | Sven Tennie <sven.tennie@gmail.com> | 2021-05-13 15:26:32 +0200 |
---|---|---|
committer | Sven Tennie <sven.tennie@gmail.com> | 2021-08-11 10:54:39 +0200 |
commit | ce2046fc61fffa9deb2b1240eee66f182572ed48 (patch) | |
tree | c9ac086d67f087dd35854707fd6252438445eb05 /testsuite/tests/rts/ipeEventLog_lib.c | |
parent | 8b9acc4d58f51dcbae73c8226ef876218809fd79 (diff) | |
download | haskell-wip/IPE_hashmap.tar.gz |
Optimize Info Table Provenance Entries (IPEs) Map creation and lookupwip/IPE_hashmap
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_lib.c')
-rw-r--r-- | testsuite/tests/rts/ipeEventLog_lib.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testsuite/tests/rts/ipeEventLog_lib.c b/testsuite/tests/rts/ipeEventLog_lib.c new file mode 100644 index 0000000000..df54231fa7 --- /dev/null +++ b/testsuite/tests/rts/ipeEventLog_lib.c @@ -0,0 +1,42 @@ +#include "Rts.h" +#include "rts/IPE.h" +#include <string.h> + +InfoProvEnt *makeAnyProvEntry(Capability *cap, int i) { + HaskellObj fourtyTwo = rts_mkInt(cap, 42); + + InfoProvEnt *provEnt = malloc(sizeof(InfoProvEnt)); + provEnt->info = (StgInfoTable *)fourtyTwo->header.info; + + unsigned int tableNameLength = strlen("table_name_") + 3 /* digits */ + 1 /* null character */; + char *tableName = malloc(sizeof(char) * tableNameLength); + snprintf(tableName, tableNameLength, "table_name_%03i", i); + provEnt->prov.table_name = tableName; + + unsigned int closureDescLength = strlen("closure_desc_") + 3 /* digits */ + 1 /* null character */; + char *closureDesc = malloc(sizeof(char) * closureDescLength); + snprintf(closureDesc, closureDescLength, "closure_desc_%03i", i); + provEnt->prov.closure_desc = closureDesc; + + unsigned int tyDescLength = strlen("ty_desc_") + 3 /* digits */ + 1 /* null character */; + char *tyDesc = malloc(sizeof(char) * tyDescLength); + snprintf(tyDesc, tyDescLength, "ty_desc_%03i", i); + provEnt->prov.ty_desc = tyDesc; + + unsigned int labelLength = strlen("label_") + 3 /* digits */ + 1 /* null character */; + char *label = malloc(sizeof(char) * labelLength); + snprintf(label, labelLength, "label_%03i", i); + provEnt->prov.label = label; + + unsigned int moduleLength = strlen("module_") + 3 /* digits */ + 1 /* null character */; + char *module = malloc(sizeof(char) * labelLength); + snprintf(module, moduleLength, "module_%03i", i); + provEnt->prov.module = module; + + unsigned int srcLocLength = strlen("srcloc_") + 3 /* digits */ + 1 /* null character */; + char *srcLoc = malloc(sizeof(char) * srcLocLength); + snprintf(srcLoc, srcLocLength, "srcloc_%03i", i); + provEnt->prov.srcloc = srcLoc; + + return provEnt; +} |