Skip to content

Commit e38e57d

Browse files
modify things
1 parent 479c50e commit e38e57d

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

draft_code/saved_functions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,3 +656,11 @@ def print_fps():
656656
# this works to crash it:
657657
from machine import mem32
658658
mem32[0] = 0xDEADBEEF
659+
660+
661+
662+
# testing stack size: recursion depth * 256
663+
#normally I get ~16KB
664+
665+
import _thread
666+
_thread.stack_size(0)

internal_filesystem/apps/com.example.cputest/assets/cputest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
# Busy loop with yield: 46000 iterations/second => this went up 25%
2121
# SHA-256 (1KB): 5100 iterations/second
2222
#
23+
# When the nostr thing is hanging:
24+
# Busy loop: 102000 iterations/second
25+
# Busy loop with yield: 12000 iterations/second => this went down 70%!
26+
# SHA-256 (1KB): 5100 iterations/second
27+
#
2328
# Results on desktop:
2429
# Busy loop: 15 997 000 => 125x faster
2530
# Busy loop with yield: 10 575 000 => 229x faster

internal_filesystem/lib/websocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ async def _connect_and_run(self):
299299
async for msg in ws:
300300
import micropython
301301
print(f"websocket.py _connect_and_run thread stack used: {micropython.stack_use()}")
302-
_log_debug(f"websocket.py _connect_and_run received msg: type={msg.type}, length: {len(msg.data)} and data={str(msg.data)[:50]}...")
302+
_log_debug(f"websocket.py _connect_and_run received msg: type={msg.type}, length: {len(msg.data)} and data={str(msg.data)[:70]}...")
303303
if not self.running:
304304
_log_debug("Not running, breaking message loop")
305305
break
@@ -325,7 +325,7 @@ async def _connect_and_run(self):
325325

326326
async def _send_async(self, data, opcode):
327327
"""Async send implementation."""
328-
_log_debug(f"Sending: opcode={opcode}, data={str(data)[:20]}...")
328+
_log_debug(f"Sending: opcode={opcode}, data={str(data)[:90]}...")
329329
try:
330330
if opcode == ABNF.OPCODE_TEXT:
331331
await self.ws.send_str(data)

internal_filesystem/lib/websocket_nostr_receive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def printevents():
8282
# 24KB is fine
8383
# 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
8484
# tried stack sizes from 18KB up to 32KB
85-
#_thread.stack_size(48*1024)
86-
#_thread.start_new_thread(printevents, ())
87-
printevents()
85+
_thread.stack_size(16*1024)
86+
_thread.start_new_thread(printevents, ())
87+
#printevents()
8888

8989

9090
#import gc

0 commit comments

Comments
 (0)