modify things

This commit is contained in:
Thomas Farstrike
2025-05-20 16:41:51 +02:00
parent 479c50e501
commit e38e57d00a
4 changed files with 18 additions and 5 deletions
+8
View File
@@ -656,3 +656,11 @@ buf.data[1000000] = 0xFF # Write way beyond buffer size
# this works to crash it:
from machine import mem32
mem32[0] = 0xDEADBEEF
# testing stack size: recursion depth * 256
#normally I get ~16KB
import _thread
_thread.stack_size(0)
@@ -20,6 +20,11 @@
# Busy loop with yield: 46000 iterations/second => this went up 25%
# SHA-256 (1KB): 5100 iterations/second
#
# When the nostr thing is hanging:
# Busy loop: 102000 iterations/second
# Busy loop with yield: 12000 iterations/second => this went down 70%!
# SHA-256 (1KB): 5100 iterations/second
#
# Results on desktop:
# Busy loop: 15 997 000 => 125x faster
# Busy loop with yield: 10 575 000 => 229x faster
+2 -2
View File
@@ -299,7 +299,7 @@ class WebSocketApp:
async for msg in ws:
import micropython
print(f"websocket.py _connect_and_run thread stack used: {micropython.stack_use()}")
_log_debug(f"websocket.py _connect_and_run received msg: type={msg.type}, length: {len(msg.data)} and data={str(msg.data)[:50]}...")
_log_debug(f"websocket.py _connect_and_run received msg: type={msg.type}, length: {len(msg.data)} and data={str(msg.data)[:70]}...")
if not self.running:
_log_debug("Not running, breaking message loop")
break
@@ -325,7 +325,7 @@ class WebSocketApp:
async def _send_async(self, data, opcode):
"""Async send implementation."""
_log_debug(f"Sending: opcode={opcode}, data={str(data)[:20]}...")
_log_debug(f"Sending: opcode={opcode}, data={str(data)[:90]}...")
try:
if opcode == ABNF.OPCODE_TEXT:
await self.ws.send_str(data)
@@ -82,9 +82,9 @@ def printevents():
# 24KB is fine
# somehow, if I run this in a thread, I get: can't create thread" at File "/lib/nostr/relay_manager.py", line 48, in open_connections
# tried stack sizes from 18KB up to 32KB
#_thread.stack_size(48*1024)
#_thread.start_new_thread(printevents, ())
printevents()
_thread.stack_size(16*1024)
_thread.start_new_thread(printevents, ())
#printevents()
#import gc