forked from haiwan/sledge
Compare commits
14 Commits
main
...
sledge_gra
Author | SHA1 | Date |
---|---|---|
hwwang | 4b2a905e92 | 3 months ago |
hwwang | a056d25ff4 | 3 months ago |
hwwang | 46b4325dba | 4 months ago |
hwwang | 8eae02580f | 4 months ago |
hwwang | 5711145b3b | 4 months ago |
hwwang | 1854297530 | 4 months ago |
hwwang | bae018314f | 4 months ago |
hwwang | 0f9b75d784 | 4 months ago |
hwwang | 8ae955fbfc | 4 months ago |
hwwang | 702f5de60d | 4 months ago |
hwwang | 0b1fb6c5d7 | 4 months ago |
hwwang | 7abc07445d | 5 months ago |
hwwang | 3aeed6f94b | 5 months ago |
hwwang | 70fdbb348c | 5 months ago |
@ -1,3 +1,3 @@
|
||||
LD_LIBRARY_PATH=/home/hai/sledge-serverless-framework/runtime/bin
|
||||
LD_LIBRARY_PATH=/home/weihao/sledge/sledge_tree/runtime/bin
|
||||
SLEDGE_SCHEDULER=EDF
|
||||
SLEDGE_SANDBOX_PERF_LOG=/home/hai/sledge-serverless-framework/debuglog.txt
|
||||
SLEDGE_SANDBOX_PERF_LOG=/home/weihao/sledge/sledge_tree/runtime_sandbox_perf_log.log
|
||||
|
@ -1,52 +1,114 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Hyde",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/bin/sledgert",
|
||||
"args": [
|
||||
"${workspaceFolder}/runtime/experiments/applications/ocr/hyde/spec.json"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Preemption",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/bin/sledgert",
|
||||
"args": [
|
||||
"${workspaceFolder}/runtime/experiments/preemption/spec.json"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Hyde",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/bin/sledgert",
|
||||
"args": [
|
||||
"${workspaceFolder}/runtime/experiments/applications/ocr/hyde/spec.json"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Preemption",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/bin/sledgert",
|
||||
"args": [
|
||||
"${workspaceFolder}/runtime/experiments/preemption/spec.json"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "graph",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/bin/sledgert",
|
||||
"args": [
|
||||
"${workspaceFolder}/runtime/tests/graph.json"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"sourceFileMap": {
|
||||
"/sledge/runtime": "${workspaceFolder}/runtime"
|
||||
},
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "utest",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/runtime/utest/map",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"sourceFileMap": {},
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"envFile": "${workspaceFolder}/.env",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": false,
|
||||
"cwd": "/home/weihao/sledge/sledge_tree/runtime/tests/noop",
|
||||
"program": "/home/weihao/sledge/sledge_tree/runtime/tests/noop/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
|
||||
Summary:
|
||||
Total: 5.2029 secs
|
||||
Slowest: 0.2684 secs
|
||||
Fastest: 0.0281 secs
|
||||
Average: 0.2039 secs
|
||||
Requests/sec: 573.9092
|
||||
|
||||
Total data: 158614 bytes
|
||||
Size/request: 53 bytes
|
||||
|
||||
Response time histogram:
|
||||
0.028 [1] |
|
||||
0.052 [26] |■
|
||||
0.076 [15] |■
|
||||
0.100 [16] |■
|
||||
0.124 [11] |
|
||||
0.148 [16] |■
|
||||
0.172 [46] |■■
|
||||
0.196 [1042] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
||||
0.220 [968] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
||||
0.244 [702] |■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
||||
0.268 [143] |■■■■■
|
||||
|
||||
|
||||
Latency distribution:
|
||||
10% in 0.1811 secs
|
||||
25% in 0.1894 secs
|
||||
50% in 0.2028 secs
|
||||
75% in 0.2231 secs
|
||||
90% in 0.2385 secs
|
||||
95% in 0.2441 secs
|
||||
99% in 0.2531 secs
|
||||
|
||||
Details (average, fastest, slowest):
|
||||
DNS+dialup: 0.0004 secs, 0.0281 secs, 0.2684 secs
|
||||
DNS-lookup: 0.0000 secs, 0.0000 secs, 0.0000 secs
|
||||
req write: 0.0002 secs, 0.0000 secs, 0.0249 secs
|
||||
resp wait: 0.2026 secs, 0.0102 secs, 0.2680 secs
|
||||
resp read: 0.0001 secs, 0.0000 secs, 0.0012 secs
|
||||
|
||||
Status code distribution:
|
||||
[200] 2986 responses
|
||||
|
||||
|
||||
|
@ -0,0 +1,247 @@
|
||||
|
||||
Summary:
|
||||
Total: 10.0240 secs
|
||||
Slowest: 1.1570 secs
|
||||
Fastest: 0.0692 secs
|
||||
Average: 0.7488 secs
|
||||
Requests/sec: 3390.6720
|
||||
|
||||
Total data: 33168 bytes
|
||||
Size/request: 48 bytes
|
||||
|
||||
Response time histogram:
|
||||
0.069 [1] |
|
||||
0.178 [16] |■■
|
||||
0.287 [15] |■■
|
||||
0.396 [10] |■
|
||||
0.504 [8] |■
|
||||
0.613 [10] |■
|
||||
0.722 [391] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
|
||||
0.831 [43] |■■■■
|
||||
0.939 [26] |■■■
|
||||
1.048 [69] |■■■■■■■
|
||||
1.157 [102] |■■■■■■■■■■
|
||||
|
||||
|
||||
Latency distribution:
|
||||
10% in 0.6506 secs
|
||||
25% in 0.6649 secs
|
||||
50% in 0.6792 secs
|
||||
75% in 0.9356 secs
|
||||
90% in 1.0743 secs
|
||||
95% in 1.0935 secs
|
||||
99% in 1.1200 secs
|
||||
|
||||
Details (average, fastest, slowest):
|
||||
DNS+dialup: 0.0073 secs, 0.0692 secs, 1.1570 secs
|
||||
DNS-lookup: 0.0000 secs, 0.0000 secs, 0.0000 secs
|
||||
req write: 0.0016 secs, 0.0000 secs, 0.0855 secs
|
||||
resp wait: 0.7388 secs, 0.0480 secs, 1.1547 secs
|
||||
resp read: 0.0004 secs, 0.0001 secs, 0.0047 secs
|
||||
|
||||
Status code distribution:
|
||||
[200] 691 responses
|
||||
|
||||
Error distribution:
|
||||
[5] Post "http://127.0.0.1:10000": EOF
|
||||
[33093] Post "http://127.0.0.1:10000": dial tcp 127.0.0.1:10000: connect: connection refused
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57822->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57830->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57838->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57840->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57850->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57856->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57864->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57876->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57882->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57894->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57906->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57918->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57920->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57934->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57938->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57948->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57958->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57964->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57978->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:57986->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58000->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58008->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58022->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58036->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58052->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58056->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58068->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58082->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58084->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58098->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58104->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58116->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58120->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58134->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58148->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58154->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58170->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58178->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58186->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58190->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58192->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58194->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58198->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58212->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58220->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58230->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58232->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58242->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58246->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58250->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58266->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58270->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58278->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58288->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58300->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58314->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58326->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58332->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58346->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58356->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58366->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58374->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58382->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58392->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58400->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58414->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58416->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58426->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58438->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58450->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58464->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58478->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58492->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58494->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58498->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58508->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58522->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58532->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58546->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58562->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58576->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58588->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58590->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58592->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58594->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58610->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58618->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58634->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58638->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58642->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58648->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58658->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58672->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58688->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58700->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58714->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58730->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58734->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58738->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58744->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58754->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58768->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58780->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58786->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58802->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58816->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58830->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58840->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58848->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58856->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58864->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58876->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58890->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58892->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58908->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58910->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58922->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58928->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58940->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58942->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58948->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58950->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58958->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58966->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58978->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:58994->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59008->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59012->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59016->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59032->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59034->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59044->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59056->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59068->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59078->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59086->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59096->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59108->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59110->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59112->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59120->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59132->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59134->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59140->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59146->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59148->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59152->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59156->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59172->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59180->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59194->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59202->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59218->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59232->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59248->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59264->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59272->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59284->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59300->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59308->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59322->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59332->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59340->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59344->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59352->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59362->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59364->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59376->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59388->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59390->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59392->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59408->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59414->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59420->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59430->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59438->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59454->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59456->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59458->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59462->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59478->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59484->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59486->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59492->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59498->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59512->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59518->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59522->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59536->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59540->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59556->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59562->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59572->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59578->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59592->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59606->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59614->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59618->127.0.0.1:10000: read: connection reset by peer
|
||||
[1] Post "http://127.0.0.1:10000": read tcp 127.0.0.1:59622->127.0.0.1:10000: read: connection reset by peer
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,180 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Simple K-V store based on The Practice of Programming by Kernighan and Pike */
|
||||
|
||||
/* Bucket count is sized to be a prime that is approximately 20% larger than the desired capacity (6k keys) */
|
||||
#define MAP_BUCKET_COUNT 7907
|
||||
#define MAP_HASH jenkins_hash
|
||||
|
||||
struct map_node {
|
||||
struct map_node *next;
|
||||
char *key;
|
||||
void *value;
|
||||
uint32_t key_len;
|
||||
uint32_t value_len;
|
||||
uint32_t hash;
|
||||
bool manage_mvalue;
|
||||
};
|
||||
|
||||
struct map_bucket {
|
||||
struct map_node *head;
|
||||
};
|
||||
|
||||
struct hashmap {
|
||||
struct map_bucket buckets[MAP_BUCKET_COUNT];
|
||||
};
|
||||
|
||||
static inline void
|
||||
map_init(struct hashmap *restrict map)
|
||||
{
|
||||
for (int i = 0; i < MAP_BUCKET_COUNT; i++) {
|
||||
map->buckets[i].head = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* See https://en.wikipedia.org/wiki/Jenkins_hash_function */
|
||||
static inline uint32_t
|
||||
jenkins_hash(char *key, uint32_t key_len)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t hash = 0;
|
||||
while (i != key_len) {
|
||||
hash += key[i++];
|
||||
hash += hash << 10;
|
||||
hash ^= hash >> 6;
|
||||
}
|
||||
hash += hash << 3;
|
||||
hash ^= hash >> 11;
|
||||
hash += hash << 15;
|
||||
return hash;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
map_get(struct hashmap *map, char *key, uint32_t key_len, uint32_t *ret_value_len)
|
||||
{
|
||||
void *value = NULL;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
|
||||
value = node->value;
|
||||
*ret_value_len = node->value_len;
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == NULL) *ret_value_len = 0;
|
||||
|
||||
DONE:
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @manage_mvalue manage _ mvalue determines whether the hash table or the caller manages value memory, and true is managed by the hash.
|
||||
*/
|
||||
static inline bool
|
||||
map_set(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len, bool manage_mvalue)
|
||||
{
|
||||
bool did_set = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) goto DONE;
|
||||
}
|
||||
|
||||
struct map_node *new_node = (struct map_node *)xmalloc(sizeof(struct map_node));
|
||||
*(new_node) = (struct map_node){ .hash = hash,
|
||||
.key = xmalloc(key_len),
|
||||
.key_len = key_len,
|
||||
.value_len = value_len,
|
||||
.next = bucket->head };
|
||||
|
||||
// Copy Key and Value
|
||||
memcpy(new_node->key, key, key_len);
|
||||
if (manage_mvalue) {
|
||||
new_node->value = xmalloc(value_len);
|
||||
memcpy(new_node->value, value, value_len);
|
||||
} else {
|
||||
new_node->value = value;
|
||||
}
|
||||
new_node->manage_mvalue = manage_mvalue;
|
||||
bucket->head = new_node;
|
||||
did_set = true;
|
||||
|
||||
DONE:
|
||||
return did_set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns boolean if node was deleted or not
|
||||
*/
|
||||
static inline bool
|
||||
map_delete(struct hashmap *map, char *key, uint32_t key_len)
|
||||
{
|
||||
bool did_delete = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
struct map_node *prev = NULL;
|
||||
struct map_node *node = bucket->head;
|
||||
while (node != NULL) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
if (prev == NULL) {
|
||||
bucket->head = node->next;
|
||||
} else {
|
||||
prev->next = node->next;
|
||||
}
|
||||
free(node->key);
|
||||
node->key = NULL;
|
||||
if (node->manage_mvalue) {
|
||||
free(node->value);
|
||||
node->value = NULL;
|
||||
}
|
||||
free(node);
|
||||
node = NULL;
|
||||
did_delete = true;
|
||||
break;
|
||||
}
|
||||
prev = node;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
return did_delete;
|
||||
}
|
||||
|
||||
static inline void
|
||||
map_upsert(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len)
|
||||
{
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
node->value_len = value_len;
|
||||
node->value = realloc(node->value, value_len);
|
||||
assert(node->value);
|
||||
if (node->manage_mvalue)
|
||||
{
|
||||
memcpy(node->value, value, value_len);
|
||||
}else node->value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
panic("map_upsert: key not found");
|
||||
}
|
@ -0,0 +1,246 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
//#include "lock.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
typedef pthread_rwlock_t rwlock_t;
|
||||
#define LOCK_INIT_RW(lock) pthread_rwlock_init(lock, NULL)
|
||||
#define LOCK_RDLOCK_RW(lock) pthread_rwlock_rdlock(lock)
|
||||
#define LOCK_WRLOCK_RW(lock) pthread_rwlock_wrlock(lock)
|
||||
#define LOCK_UNLOCK_RW(lock) pthread_rwlock_unlock(lock)
|
||||
|
||||
/* Simple K-V store based on The Practice of Programming by Kernighan and Pike */
|
||||
|
||||
/* Bucket count is sized to be a prime that is approximately 20% larger than the desired capacity (6k keys) */
|
||||
#define MAP_BUCKET_COUNT 7907
|
||||
#define MAP_HASH jenkins_hash
|
||||
|
||||
struct map_node {
|
||||
struct map_node *next;
|
||||
char *key;
|
||||
void *value;
|
||||
uint32_t key_len;
|
||||
uint32_t value_len;
|
||||
uint32_t hash;
|
||||
bool manage_mvalue;
|
||||
};
|
||||
|
||||
struct map_bucket {
|
||||
rwlock_t lock;
|
||||
struct map_node *head;
|
||||
};
|
||||
|
||||
struct hashmap {
|
||||
struct map_bucket buckets[MAP_BUCKET_COUNT];
|
||||
};
|
||||
|
||||
static inline void
|
||||
map_init(struct hashmap *restrict map)
|
||||
{
|
||||
for (int i = 0; i < MAP_BUCKET_COUNT; i++) {
|
||||
map->buckets[i].head = NULL;
|
||||
LOCK_INIT_RW(&map->buckets[i].lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* See https://en.wikipedia.org/wiki/Jenkins_hash_function */
|
||||
static inline uint32_t
|
||||
jenkins_hash(char *key, uint32_t key_len)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
uint32_t hash = 0;
|
||||
while (i != key_len) {
|
||||
hash += key[i++];
|
||||
hash += hash << 10;
|
||||
hash ^= hash >> 6;
|
||||
}
|
||||
hash += hash << 3;
|
||||
hash ^= hash >> 11;
|
||||
hash += hash << 15;
|
||||
return hash;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
map_get(struct hashmap *map, char *key, uint32_t key_len, uint32_t *ret_value_len)
|
||||
{
|
||||
void *value = NULL;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
LOCK_RDLOCK_RW(&bucket->lock);
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
|
||||
value = node->value;
|
||||
*ret_value_len = node->value_len;
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == NULL) *ret_value_len = 0;
|
||||
|
||||
DONE:
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @manage_mvalue manage _ mvalue determines whether the hash table or the caller manages value memory, and true is managed by the hash.
|
||||
*/
|
||||
static inline bool
|
||||
map_set(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len, bool manage_mvalue)
|
||||
{
|
||||
bool did_set = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
|
||||
LOCK_WRLOCK_RW(&bucket->lock);
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) goto DONE;
|
||||
}
|
||||
|
||||
struct map_node *new_node = (struct map_node *)xmalloc(sizeof(struct map_node));
|
||||
*(new_node) = (struct map_node){ .hash = hash,
|
||||
.key = xmalloc(key_len),
|
||||
.key_len = key_len,
|
||||
.value_len = value_len,
|
||||
.next = bucket->head };
|
||||
|
||||
// Copy Key and Value
|
||||
memcpy(new_node->key, key, key_len);
|
||||
if (manage_mvalue) {
|
||||
new_node->value = xmalloc(value_len);
|
||||
memcpy(new_node->value, value, value_len);
|
||||
} else {
|
||||
new_node->value = value;
|
||||
}
|
||||
new_node->manage_mvalue = manage_mvalue;
|
||||
bucket->head = new_node;
|
||||
did_set = true;
|
||||
|
||||
DONE:
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
return did_set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns boolean if node was deleted or not
|
||||
*/
|
||||
static inline bool
|
||||
map_delete(struct hashmap *map, char *key, uint32_t key_len)
|
||||
{
|
||||
bool did_delete = false;
|
||||
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
LOCK_WRLOCK_RW(&bucket->lock);
|
||||
|
||||
struct map_node *prev = NULL;
|
||||
struct map_node *node = bucket->head;
|
||||
while (node != NULL) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
if (prev == NULL) {
|
||||
bucket->head = node->next;
|
||||
} else {
|
||||
prev->next = node->next;
|
||||
}
|
||||
free(node->key);
|
||||
node->key = NULL;
|
||||
if (node->manage_mvalue) {
|
||||
free(node->value);
|
||||
node->value = NULL;
|
||||
}
|
||||
free(node);
|
||||
node = NULL;
|
||||
did_delete = true;
|
||||
break;
|
||||
}
|
||||
prev = node;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
return did_delete;
|
||||
}
|
||||
|
||||
static inline void
|
||||
map_upsert(struct hashmap *map, char *key, uint32_t key_len, void *value, uint32_t value_len)
|
||||
{
|
||||
uint32_t hash = MAP_HASH(key, key_len);
|
||||
struct map_bucket *bucket = &map->buckets[hash % MAP_BUCKET_COUNT];
|
||||
LOCK_WRLOCK_RW(&bucket->lock);
|
||||
|
||||
for (struct map_node *node = bucket->head; node != NULL; node = node->next) {
|
||||
if (node->hash == hash && memcmp(node->key, key, key_len) == 0) {
|
||||
node->value_len = value_len;
|
||||
node->value = realloc(node->value, value_len);
|
||||
assert(node->value);
|
||||
if (node->manage_mvalue)
|
||||
{
|
||||
memcpy(node->value, value, value_len);
|
||||
}else node->value = value;
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
panic("map_upsert: key not found");
|
||||
/*struct map_node *new_node = (struct map_node *)xmalloc(sizeof(struct map_node));
|
||||
|
||||
*(new_node) = (struct map_node){ .hash = hash,
|
||||
.key = xmalloc(key_len),
|
||||
.key_len = key_len,
|
||||
.value = xmalloc(value_len),
|
||||
.value_len = value_len,
|
||||
.next = bucket->head };
|
||||
|
||||
assert(new_node->key);
|
||||
assert(new_node->value);
|
||||
|
||||
// Copy Key and Value
|
||||
memcpy(new_node->key, key, key_len);
|
||||
memcpy(new_node->value, value, value_len);
|
||||
|
||||
bucket->head = new_node;*/
|
||||
|
||||
DONE:
|
||||
LOCK_UNLOCK_RW(&bucket->lock);
|
||||
}
|
||||
|
||||
/*static inline void
|
||||
map_destroy(struct hashmap *map) {
|
||||
for (int i = 0; i < MAP_BUCKET_COUNT; i++) {
|
||||
LOCK_LOCK_RW(&map->buckets[i].lock);
|
||||
struct map_node *current = map->buckets[i].head;
|
||||
struct map_node *next;
|
||||
|
||||
while (current != NULL) {
|
||||
next = current->next;
|
||||
free(current->key);
|
||||
if (current->manage_mvalue && current->value != NULL) {
|
||||
free(current->value);
|
||||
}
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
|
||||
LOCK_UNLOCK_RW(&map->buckets[i].lock);
|
||||
|
||||
pthread_mutex_destroy(&map->buckets[i].lock);
|
||||
|
||||
// 确保头指针设置为 NULL
|
||||
map->buckets[i].head = NULL;
|
||||
}
|
||||
// 如果 hashmap 是动态分配的,这里还需要释放 hashmap 结构本身
|
||||
// free(map);
|
||||
}*/
|
||||
|
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "likely.h"
|
||||
#include "panic.h"
|
||||
|
||||
static inline void *
|
||||
xmalloc(size_t size)
|
||||
{
|
||||
void *allocation = malloc(size);
|
||||
if (unlikely(allocation == NULL)) panic("xmalloc failed!\n");
|
||||
return allocation;
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
a
|
@ -0,0 +1 @@
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "$0 [cpu-log]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
path="/home/hai/sledge-old/runtime/tests"
|
||||
|
||||
#test work1k 2000
|
||||
server_log_file="edf_1k.log"
|
||||
$path/compare/start_compare.sh $server_log_file >/dev/null 2>&1 &
|
||||
echo "sledge is running"
|
||||
./hey_test_compare.sh 60 22
|
||||
$path/kill_sledge.sh
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,24 @@
|
||||
function usage {
|
||||
echo "$0 [duration(s)] [concurrency]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 2 ] ; then
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
duration=$1
|
||||
concurrency=$2
|
||||
|
||||
f1="1byte_"$concurrency".txt"
|
||||
echo $f1
|
||||
f2="0.4k_"$concurrency".txt"
|
||||
|
||||
./test_8c.sh $f1 $duration $concurrency 1byte_file 10000 2>&1 &
|
||||
pid1=$!
|
||||
./test_8c.sh $f2 $duration $concurrency 410byte_file 10004 2>&1 &
|
||||
pid4=$!
|
||||
wait -f $pid1
|
||||
wait -f $pid2
|
||||
printf "[OK]\n"
|
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "$0 [perf output file, chain_function_perf.log or single_function_perf.log or opt_function_perf.log]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 1 ] ; then
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
output=$1
|
||||
|
||||
|
||||
declare project_path="$(
|
||||
cd "$(dirname "$0")/../../.."
|
||||
pwd
|
||||
)"
|
||||
echo $project_path
|
||||
path=`pwd`
|
||||
#export SLEDGE_DISABLE_PREEMPTION=true
|
||||
export SLEDGE_CPU_SPEED=2400
|
||||
export SLEDGE_SCHEDULER=EDF
|
||||
export SLEDGE_SIGALRM_HANDLER=BROADCAST
|
||||
export SLEDGE_SANDBOX_PERF_LOG=$path/$output
|
||||
echo $SLEDGE_SANDBOX_PERF_LOG
|
||||
cd $project_path/runtime/bin
|
||||
LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" ./sledgert ../tests/compare/test_work1k.json
|
@ -0,0 +1,22 @@
|
||||
function usage {
|
||||
echo "$0 [output file] [duration(s)] [concurrency] [image file] [port]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# != 5 ] ; then
|
||||
echo "input parameters are not 5"
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
output=$1
|
||||
duration=$2
|
||||
concurrency=$3
|
||||
image=$4
|
||||
port=$5
|
||||
|
||||
echo "hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://127.0.0.1:$port" > $output"
|
||||
|
||||
#hey -disable-compression -disable-keepalive -disable-redirects -c 1 -q $rps -z $duration\s -cpus 1 -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
|
||||
#hey -disable-compression -disable-keepalive -disable-redirects -c $concurrency -z 20s -t 0 -m GET -D "$image" "http://10.10.1.1:$port"
|
||||
hey -disable-compression -disable-keepalive -disable-redirects -n 5000 -c $concurrency -z $duration\s -t 0 -m GET -D "$image" "http://127.0.0.1:$port" > $output
|
@ -0,0 +1,136 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_1",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["work1k1_2", "work1k1_3"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_2",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10001,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k1_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_3",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10002,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 2,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k1_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k1_4",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10003,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 2,
|
||||
"next_modules": [],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain",
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_1",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10004,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["work1k2_2", "work1k2_3"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_2",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10005,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k2_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_3",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10006,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 2,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work1k2_4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k2_4",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10007,
|
||||
"relative-deadline-us": 90000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 2,
|
||||
"next_modules": [],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plaini",
|
||||
},
|
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct DataNode DataNode;
|
||||
|
||||
DataNode* splitData(char *buffer, uint32_t bufferSize);
|
||||
|
||||
void freeDataNodes(DataNode *head);
|
||||
|
||||
void printDataList(DataNode *head);
|
||||
|
||||
int getDataNodeCount(DataNode *head);
|
||||
|
||||
/**
|
||||
* @param index is form 1 to n
|
||||
*/
|
||||
const char* getDataNodeByIndex(DataNode *head, int index);
|
@ -0,0 +1,60 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "dag_data_split.h" // 包含数据处理的API
|
||||
|
||||
unsigned long int fib(unsigned long int n) {
|
||||
if (n <= 1) return n;
|
||||
return fib(n - 1) + fib(n - 2);
|
||||
}
|
||||
|
||||
int main() {
|
||||
char buffer[1024]; // Buffer to store input data
|
||||
|
||||
ssize_t bytes_read = read(0, buffer, sizeof(buffer));
|
||||
if (bytes_read < 0) {
|
||||
perror("Error reading input");
|
||||
return 1;
|
||||
}
|
||||
|
||||
DataNode *dataList = splitData(buffer, bytes_read);
|
||||
if (dataList == NULL) {
|
||||
fprintf(stderr, "Failed to split data.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 读取解析出的第一个和第二个数字
|
||||
unsigned long int num1, num2;
|
||||
const char *firstdata = getDataNodeByIndex(dataList, 1);
|
||||
const char *seconddata = getDataNodeByIndex(dataList, 2);
|
||||
|
||||
if (firstdata == NULL || seconddata == NULL) {
|
||||
fprintf(stderr, "Not enough data for two numbers.\n");
|
||||
freeDataNodes(dataList);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sscanf(firstdata, "%lu", &num1) != 1 || sscanf(seconddata, "%lu", &num2) != 1) {
|
||||
fprintf(stderr, "Failed to parse the numbers correctly.\n");
|
||||
freeDataNodes(dataList);
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned long int fib1 = fib(num1);
|
||||
unsigned long int fib2 = fib(num2);
|
||||
unsigned long int sum = fib1 + fib2;
|
||||
|
||||
// Prepare output string
|
||||
char output[1024];
|
||||
int len = snprintf(output, sizeof(output), "Fibonacci(%lu) + Fibonacci(%lu) = %lu + %lu = %lu\n", num1, num2, fib1, fib2, sum);
|
||||
|
||||
// Write to stdout
|
||||
write(1, output, len);
|
||||
|
||||
// 清理内存
|
||||
freeDataNodes(dataList);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "work",
|
||||
"path": "work_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 0,
|
||||
"next_modules": ["work2", "work3"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work2",
|
||||
"path": "work_wasm.so",
|
||||
"port": 10001,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work3",
|
||||
"path": "work_wasm.so",
|
||||
"port": 10002,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 1,
|
||||
"next_modules": ["work4"],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"name": "work4",
|
||||
"path": "fibonacciadd_wasm.so",
|
||||
"port": 10003,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"priority": 1,
|
||||
"pre_module_count": 2,
|
||||
"next_modules": [],
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1048776,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1048776,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#define OUTPUT_BUFFER_SIZE (1024 * 5) // 5KB
|
||||
|
||||
int main() {
|
||||
char *data = (char *)malloc(10 * 1024); // Allocate 10KB
|
||||
if (!data) {
|
||||
fprintf(stderr, "Failed to allocate memory.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ssize_t bytesRead = read(STDIN_FILENO, data, 10 * 1024);
|
||||
if (bytesRead == -1) {
|
||||
fprintf(stderr, "Failed to read data from file.\n");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create a combined buffer to hold the output
|
||||
char *combined_output = malloc(2 * OUTPUT_BUFFER_SIZE + 50); // 50 extra bytes for text and safety
|
||||
if (!combined_output) {
|
||||
fprintf(stderr, "Failed to allocate memory for combined output.\n");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Format the output in a single buffer
|
||||
int offset = sprintf(combined_output, "Buffer 1 (First 5KB): ");
|
||||
memcpy(combined_output + offset, data, OUTPUT_BUFFER_SIZE);
|
||||
offset += OUTPUT_BUFFER_SIZE;
|
||||
offset += sprintf(combined_output + offset, " Buffer 2 (Second 5KB): ");
|
||||
memcpy(combined_output + offset, data + OUTPUT_BUFFER_SIZE, OUTPUT_BUFFER_SIZE);
|
||||
|
||||
// Print everything in one go
|
||||
fwrite(combined_output, sizeof(char), offset + OUTPUT_BUFFER_SIZE, stdout);
|
||||
printf("\n");
|
||||
|
||||
// Clean up
|
||||
free(data);
|
||||
free(combined_output);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1 +1,2 @@
|
||||
sudo chsh -s /bin/bash xiaosuGW
|
||||
sudo chsh -s /bin/bash hai
|
||||
|
||||
|
@ -0,0 +1,368 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize1",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 78574,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp1",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10001,
|
||||
"relative-deadline-us": 78574,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_1",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10002,
|
||||
"relative-deadline-us": 78574,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize2",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10003,
|
||||
"relative-deadline-us": 192762,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp2",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10004,
|
||||
"relative-deadline-us": 192762,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_2",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10005,
|
||||
"relative-deadline-us": 192762,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize3",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10006,
|
||||
"relative-deadline-us": 16346,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp3",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10007,
|
||||
"relative-deadline-us": 16346,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_3",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10008,
|
||||
"relative-deadline-us": 16346,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize4",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10009,
|
||||
"relative-deadline-us": 47824,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp4",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10010,
|
||||
"relative-deadline-us": 47824,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_4",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10011,
|
||||
"relative-deadline-us": 47824,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize5",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10012,
|
||||
"relative-deadline-us": 392870,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp5",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10013,
|
||||
"relative-deadline-us": 392870,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_5",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10014,
|
||||
"relative-deadline-us": 392870,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize6",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10015,
|
||||
"relative-deadline-us": 963810,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp6",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10016,
|
||||
"relative-deadline-us": 963810,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_6",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10017,
|
||||
"relative-deadline-us": 963810,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize7",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10018,
|
||||
"relative-deadline-us": 81730,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp7",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10019,
|
||||
"relative-deadline-us": 81730,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_7",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10020,
|
||||
"relative-deadline-us": 81730,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "resize8",
|
||||
"path": "resize_wasm.so",
|
||||
"port": 10021,
|
||||
"relative-deadline-us": 239120,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/jpeg",
|
||||
"http-req-size": 1024000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024000,
|
||||
"http-resp-content-type": "image/png"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "png2bmp8",
|
||||
"path": "C-Image-Manip_wasm.so",
|
||||
"port": 10022,
|
||||
"relative-deadline-us": 239120,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/png",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 4096000,
|
||||
"http-resp-content-type": "image/bmp"
|
||||
},
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"name": "cifar10_8",
|
||||
"path": "cifar10_wasm.so",
|
||||
"port": 10023,
|
||||
"relative-deadline-us": 239120,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "image/bmp",
|
||||
"http-req-size": 4096000,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1024,
|
||||
"http-resp-content-type": "text/plain",
|
||||
"tail-module": true
|
||||
},
|
||||
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "work1k",
|
||||
"path": "work1k_wasm.so",
|
||||
"port": 10000,
|
||||
"relative-deadline-us": 50000,
|
||||
"argsize": 1,
|
||||
"http-req-headers": [],
|
||||
"http-req-content-type": "text/plain",
|
||||
"http-req-size": 1200,
|
||||
"http-resp-headers": [],
|
||||
"http-resp-size": 1200,
|
||||
"http-resp-content-type": "text/plain"
|
||||
}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
Subproject commit 1c139923fe08f36143ecc0ba37cd674684f87f9c
|
Binary file not shown.
@ -0,0 +1,70 @@
|
||||
#include "../include/map.h"
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
char name[100];
|
||||
float salary;
|
||||
} Employee;
|
||||
|
||||
|
||||
int main() {
|
||||
// 初始化哈希表
|
||||
struct hashmap myMap;
|
||||
map_init(&myMap);
|
||||
|
||||
// 创建并初始化一些 Employee 结构体
|
||||
Employee *alice = malloc(sizeof(Employee));
|
||||
alice->id = 1;
|
||||
strcpy(alice->name, "Alice");
|
||||
alice->salary = 50000.0;
|
||||
|
||||
Employee *bob = malloc(sizeof(Employee));
|
||||
bob->id = 2;
|
||||
strcpy(bob->name, "Bob");
|
||||
bob->salary = 52000.0;
|
||||
|
||||
// 将 Employee 结构体存入哈希表
|
||||
char *key1 = "employee1";
|
||||
map_set(&myMap, key1, strlen(key1), alice, sizeof(Employee*), false);
|
||||
|
||||
char *key2 = "employee2";
|
||||
map_set(&myMap, key2, strlen(key2), bob, sizeof(Employee*), true);
|
||||
|
||||
// 尝试从哈希表中检索 Employee
|
||||
uint32_t ret_value_len;
|
||||
Employee *retrieved_employee = (Employee *)map_get(&myMap, key1, strlen(key1), &ret_value_len);
|
||||
if (retrieved_employee) {
|
||||
printf("Retrieved Employee: %s, ID: %d, Salary: %.2f\n",
|
||||
retrieved_employee->name, retrieved_employee->id, retrieved_employee->salary);
|
||||
} else {
|
||||
printf("Employee not found.\n");
|
||||
}
|
||||
alice->id = 12;
|
||||
char *key = "employee1";
|
||||
strcat(alice->name, key);
|
||||
retrieved_employee = (Employee *)map_get(&myMap, key1, strlen(key1), &ret_value_len);
|
||||
if (retrieved_employee) {
|
||||
printf("Retrieved Employee: %s, ID: %d, Salary: %.2f\n",
|
||||
retrieved_employee->name, retrieved_employee->id, retrieved_employee->salary);
|
||||
} else {
|
||||
printf("Employee not found.\n");
|
||||
}
|
||||
uint64_t value1 = 20, value2 = 30;
|
||||
char *key3 = "test1";
|
||||
char *key4 = "test2";
|
||||
map_set(&myMap, key3, strlen(key3), &value1, sizeof(uint64_t), true);
|
||||
uint32_t *value = (uint32_t *)map_get(&myMap, key3, strlen(key3), &ret_value_len);
|
||||
if (value) printf("Retrieved value: %d\n", *value); else printf("Value not found.\n");
|
||||
value1 ++;
|
||||
value = (uint32_t *)map_get(&myMap, key3, strlen(key3), &ret_value_len);
|
||||
if (value) printf("Retrieved value: %d\n", *value); else printf("Value not found.\n");
|
||||
map_upsert(&myMap, key3, strlen(key3), &value1, sizeof(uint64_t));
|
||||
value = (uint32_t *)map_get(&myMap, key3, strlen(key3), &ret_value_len);
|
||||
if (value) printf("Retrieved value: %d\n", *value); else printf("Value not found.\n");
|
||||
|
||||
|
||||
free(alice);
|
||||
free(bob);
|
||||
return 0;
|
||||
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue