Skip to content

Commit 8723b89

Browse files
author
hp23 Server
committed
Small updates
1 parent 809f2a2 commit 8723b89

File tree

2 files changed

+130
-27
lines changed

2 files changed

+130
-27
lines changed

_hp/hp/tools/analysis/analysis_december_2024.ipynb

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@
116116
{
117117
"cell_type": "markdown",
118118
"id": "4d838597-a856-47fd-b0e2-42005c0c5e95",
119-
"metadata": {
120-
"jp-MarkdownHeadingCollapsed": true
121-
},
119+
"metadata": {},
122120
"source": [
123121
"# Overview\n",
124122
"- Collected between 885730 and 1558656 results for 12 browsers (original)\n",
@@ -579,9 +577,7 @@
579577
{
580578
"cell_type": "markdown",
581579
"id": "10825cc1-7b5c-4d02-9217-6201ce117d21",
582-
"metadata": {
583-
"jp-MarkdownHeadingCollapsed": true
584-
},
580+
"metadata": {},
585581
"source": [
586582
"## Error + Timeout Analysis\n",
587583
"- Small number of random timeouts in both parsing/basic mode\n",
@@ -2668,9 +2664,7 @@
26682664
{
26692665
"cell_type": "markdown",
26702666
"id": "12f42fc8-2f18-48a7-be7a-ba913fa915e5",
2671-
"metadata": {
2672-
"jp-MarkdownHeadingCollapsed": true
2673-
},
2667+
"metadata": {},
26742668
"source": [
26752669
"### General\n",
26762670
"- Basic:\n",
@@ -2777,7 +2771,7 @@
27772771
},
27782772
{
27792773
"cell_type": "code",
2780-
"execution_count": 34,
2774+
"execution_count": 317,
27812775
"id": "5d65806b-5ca1-4123-a9da-51178e1063ea",
27822776
"metadata": {},
27832777
"outputs": [
@@ -2786,13 +2780,15 @@
27862780
"output_type": "stream",
27872781
"text": [
27882782
"Original run tests with more than one outcome: total 0.07206861383642119, basic 0.1884841206298372, parsing 0.06510961947266193\n",
2789-
"Updated run tests with more than one outcome: total 0.076490578392964, basic 0.2752201761409127, parsing 0.06461107721023727\n"
2783+
"Updated run tests with more than one outcome: total 0.076490578392964, basic 0.2752201761409127, parsing 0.06461107721023727\n",
2784+
"Combined run tests with more than one outcome: total 0.07317410497555689\n"
27902785
]
27912786
}
27922787
],
27932788
"source": [
27942789
"print(f\"Original run tests with more than one outcome: total {(226+1306)/(9992*12+167154*12)*100}, basic {226/(9992*12)*100}, parsing {1306/(167154*12)*100}\")\n",
2795-
"print(f\"Updated run tests with more than one outcome: total {(110+432)/(9992*4+167154*4)*100}, basic {110/(9992*4)*100}, parsing {432/(167154*4)*100}\")"
2790+
"print(f\"Updated run tests with more than one outcome: total {(110+432)/(9992*4+167154*4)*100}, basic {110/(9992*4)*100}, parsing {432/(167154*4)*100}\")\n",
2791+
"print(f\"Combined run tests with more than one outcome: total {(336+1738)/(9992*16+167154*16)*100}\")"
27962792
]
27972793
},
27982794
{
@@ -5101,9 +5097,7 @@
51015097
{
51025098
"cell_type": "markdown",
51035099
"id": "45c8c774-4bbc-4d8b-beb6-03a820dc8cd8",
5104-
"metadata": {
5105-
"jp-MarkdownHeadingCollapsed": true
5106-
},
5100+
"metadata": {},
51075101
"source": [
51085102
"### Majority Voting\n",
51095103
"- Perform majority voting\n",
@@ -5413,7 +5407,7 @@
54135407
"- 4374 tests have two outcomes, 58 tests have three outcomes\n",
54145408
"- All test rows: 2125752, should be: 2125752, Rows with more than one outcome: 53184, Tests with more than one outcome: 4432\n",
54155409
"- **Update December: 4950 have two outcomes, 92 have three outcomes**\n",
5416-
"- Combined: 5491 have two outcomes, 121 have three outcomes"
5410+
"- Combined: 5485 have two outcomes, 121 have three outcomes"
54175411
]
54185412
},
54195413
{
@@ -5634,9 +5628,7 @@
56345628
{
56355629
"cell_type": "markdown",
56365630
"id": "940c0cd8-08da-4034-8c9a-d634afa3c777",
5637-
"metadata": {
5638-
"jp-MarkdownHeadingCollapsed": true
5639-
},
5631+
"metadata": {},
56405632
"source": [
56415633
"## Differences per test group\n",
56425634
"- Basic:\n",
@@ -5650,7 +5642,7 @@
56505642
},
56515643
{
56525644
"cell_type": "code",
5653-
"execution_count": 55,
5645+
"execution_count": 313,
56545646
"id": "7eecaa8e-644a-4fa5-b44d-6ca25bc18b5c",
56555647
"metadata": {},
56565648
"outputs": [
@@ -6286,6 +6278,61 @@
62866278
"display(r.groupby([\"test_name\", \"relation_info\"])[\"diff\"].agg([\"mean\"]).describe())"
62876279
]
62886280
},
6281+
{
6282+
"cell_type": "code",
6283+
"execution_count": 314,
6284+
"id": "98cd2ebf-f593-401f-bcf6-0bb5e219cd09",
6285+
"metadata": {},
6286+
"outputs": [
6287+
{
6288+
"data": {
6289+
"text/plain": [
6290+
"test_name relation_info \n",
6291+
"accesswindow_direct direct 76\n",
6292+
"fetch_GET credentials 114\n",
6293+
" custom_headers 126\n",
6294+
" simple 137\n",
6295+
"fetch_TEST custom_method 126\n",
6296+
"framing_embed direct 186\n",
6297+
" nested 120\n",
6298+
" sandbox 120\n",
6299+
"framing_iframe direct 421\n",
6300+
" nested 172\n",
6301+
" sandbox 8\n",
6302+
"framing_object direct 186\n",
6303+
" nested 120\n",
6304+
" sandbox 120\n",
6305+
"fullscreen_iframe child 23\n",
6306+
" child_allow 481\n",
6307+
" child_sandbox 0\n",
6308+
" direct 442\n",
6309+
"imgloading_iframe direct 270\n",
6310+
"perfAPI_img direct 104\n",
6311+
"referrer_iframe iframe 131\n",
6312+
" window.open 117\n",
6313+
"script_execution_iframe direct 242\n",
6314+
" sandbox 21\n",
6315+
"sniffing_script direct 42\n",
6316+
"subresourceloadingCOEP_img direct 236\n",
6317+
" sandbox 4\n",
6318+
"subresourceloadingCORP_img direct 103\n",
6319+
" nested 0\n",
6320+
" sandbox 0\n",
6321+
"subresourceloadingCORP_object direct 176\n",
6322+
"upgradeHSTS_direct direct 859\n",
6323+
"upgradeHSTS_subdomain subdomain 323\n",
6324+
"Name: diff, dtype: int64"
6325+
]
6326+
},
6327+
"execution_count": 314,
6328+
"metadata": {},
6329+
"output_type": "execute_result"
6330+
}
6331+
],
6332+
"source": [
6333+
"r.groupby([\"test_name\", \"relation_info\"])[\"diff\"].sum()"
6334+
]
6335+
},
62896336
{
62906337
"cell_type": "code",
62916338
"execution_count": 58,
@@ -8259,9 +8306,7 @@
82598306
{
82608307
"cell_type": "markdown",
82618308
"id": "8ed5e49e-a172-49c3-92c3-613f48a1d8e0",
8262-
"metadata": {
8263-
"jp-MarkdownHeadingCollapsed": true
8264-
},
8309+
"metadata": {},
82658310
"source": [
82668311
"## Framing\n",
82678312
"- Testfile: `framing.sub.html`\n",
@@ -13746,9 +13791,7 @@
1374613791
{
1374713792
"cell_type": "markdown",
1374813793
"id": "227f601a-0e6c-47b5-b80b-aa97c0087b45",
13749-
"metadata": {
13750-
"jp-MarkdownHeadingCollapsed": true
13751-
},
13794+
"metadata": {},
1375213795
"source": [
1375313796
"### General"
1375413797
]
@@ -20935,7 +20978,12 @@
2093520978
"cell_type": "code",
2093620979
"execution_count": 295,
2093720980
"id": "3a85e878-14a5-4904-86b0-7943a4c78ebd",
20938-
"metadata": {},
20981+
"metadata": {
20982+
"collapsed": true,
20983+
"jupyter": {
20984+
"outputs_hidden": true
20985+
}
20986+
},
2093920987
"outputs": [
2094020988
{
2094120989
"name": "stdout",

server.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
import signal
3+
import subprocess
4+
import time
5+
6+
# Configurable parameters
7+
command = ["poetry", "run", "-C", "_hp", "python", "wpt", "serve", "--config", "_hp/wpt-config.json"]
8+
restart_interval = 600 # Time in seconds before restarting
9+
max_retries = 4 # Max number of restart attempts (in an row)
10+
11+
def run_with_restart():
12+
retries = 0
13+
14+
while retries < max_retries:
15+
print(f"Attempt {retries + 1} of {max_retries}...")
16+
try:
17+
# Start the process in a new process group
18+
process = subprocess.Popen(
19+
command,
20+
preexec_fn=os.setsid # Create a new process group
21+
)
22+
23+
# Wait for the process to complete or timeout after the configured interval
24+
exit_code = process.wait(timeout=restart_interval)
25+
26+
# Check if the exit code was an error (non-zero)
27+
if exit_code != 0:
28+
raise Exception(f"Process exited with error code {exit_code}")
29+
print(f"Process completed successfully with exit code {exit_code}. Restarting...")
30+
retries = 0 # Reset retry count after a successful run
31+
32+
except subprocess.TimeoutExpired:
33+
print("Timeout reached. Sending SIGINT to process group...")
34+
# Send SIGINT to the entire process group
35+
os.killpg(os.getpgid(process.pid), signal.SIGINT)
36+
process.wait() # Ensure the process fully terminates
37+
retries = 0 # Reset retry count afer a successful run (until timeout)
38+
39+
except KeyboardInterrupt:
40+
print("Keyboard interrupt received. Sending SIGINT to process group...")
41+
# Send SIGINT to the entire process group in case of Ctrl+C
42+
os.killpg(os.getpgid(process.pid), signal.SIGINT)
43+
process.wait() # Ensure the process terminates
44+
return
45+
46+
except Exception as e:
47+
print(f"Error: {e}. Restarting in 10 seconds...")
48+
retries += 1
49+
if retries >= max_retries:
50+
print("Max restart attempts reached. Exiting.")
51+
break
52+
time.sleep(10)
53+
54+
if __name__ == "__main__":
55+
run_with_restart()

0 commit comments

Comments
 (0)