Commit 16567c8
feat(ovsm): Add sleep function and fix tight loop issue
Problem: WebSocket streaming script hit 10M iteration limit
- Tight while loop without delay
- stream-poll returns instantly when buffer empty
- Loop spins millions of times per second
Solution: Add sleep(milliseconds) function
- Pauses execution for specified milliseconds
- Uses std::thread::sleep internally
- Update stream script to sleep 100ms between polls
Script changes:
- Restore 60 second duration (was reduced to 10)
- Add sleep(100) in poll loop
- Add poll-count stat to show polling frequency
- Now ~600 polls in 60 seconds (1 every 100ms)
Benefits:
- No more iteration limit errors
- CPU friendly (no busy-wait spinning)
- Still responsive (100ms latency acceptable)
- WebSocket events buffered while sleeping
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent d417d6e commit 16567c8
File tree
2 files changed
+33
-1
lines changed- crates/ovsm/src/runtime
- examples/ovsm_scripts
2 files changed
+33
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
| |||
4016 | 4017 | | |
4017 | 4018 | | |
4018 | 4019 | | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
| 4027 | + | |
| 4028 | + | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
| 4038 | + | |
| 4039 | + | |
| 4040 | + | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
| 4044 | + | |
4019 | 4045 | | |
4020 | 4046 | | |
4021 | 4047 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
36 | 41 | | |
37 | 42 | | |
38 | 43 | | |
| |||
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
0 commit comments