-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code which makes heavy use of interrupts considerably slows down the simulator. E.g. that transmit programs large amount of data over SPI. See wokwi/wokwi-features#280 for an example.
- Loading branch information
Showing
1 changed file
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c029ed1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I fear JS/TS will always be a foreign language to me, but I can appreciate that you've made the browser's job much easier by replacing many null comparisons with far fewer. 👍
c029ed1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I planned to make a video where I show how I profile this and find the bottleneck. But I figured out it'll be too much distraction to edit it, promote it, etc. so I ditched that plan.
In general, the offending line was:
I'm not really sure why it was that expensive - my bet is that it converts the array into sparse array, possibly allocating new memory and copying over all the content.
We had a similar win in 968a6ee, where I switched from an array to a more performant linked list.
c029ed1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for expanding on that. Avoiding the sparse -> full allocation would certainly help too, especially in a garbage-collected language. JS makes slightly more sense to me each time you describe something, so maybe one day I won't be such a complete stranger to it. ❤️