Comments (5)
i've pushed a bunch of ideas for the ii implementation on crow to https://github.com/trentgill/crow/blob/master/lua/ii.lua
my concern is that the proposed idea of a giant table of lua functions for every potential module is the kind of thing that will chew up all of our working RAM. obviously this is not in itself that big of a deal, but perhaps underlies some lack of understanding about how memory usage works in the lua VM.
as i understand currently whenever we load these libraries with dofile() lua reads them from flash, converts them to lua chunks, and executes those chunks. the issue is these chunks must be held in RAM throughout the duration of the program's existence. the code can't be executed from flash (like it can for c) because the code itself can be modified or destroyed by the GC.
this leads to my conclusion that "all lua code is stored in RAM, for the duration of it's ability to be called".
perhaps i'm optimizing before necessary, but just worried this style of solution isn't going to be workable in our RAM limited environment. the more we use for these things, the less is left for the user to do interesting things.
your more experienced thoughts much appreciated here.
from crow.
i believe you're correct re: RAM and GC.
we should get some numbers re: RAM usage for a function table for i2c. if we're really squeezed, we can potentially just forgo including the helper functions (and point at a reference guide with cut-paste functions).
ie under the heading ANSIBLE:
ANSIBLE_ADDR = 20 -- or whatever is correct
ANSIBLE_CMD_POS = 3 -- also
function ansible_kria_position(track, position)
i2c(ANSIBLE_ADDR, ANSIBLE_CMD_POS, track, position)
end
imagine this in a big reference guide, then users can cut-paste, or adapt them however they want. but all the info is there. it's a little weird, but perhaps an adequate solution.
also, the reference "guide" lua file could be completely imported within norns and these functions used directly.
from crow.
i do really like the idea of the big function table, and i guess my concern is perhaps something more broadly affecting the project.
one thing i started doing was make the 'crowlib.lua' file be a wrapper over all the specific pieces of the standard library we mentioned. crowlib is loaded (as crow
) before the init() is called, and by default it loads all the libraries. this means a starting user has access to everything we ship with all the helpers etc.
then there's an option to call crow.libs(arg) which can customize what libraries are loaded. eg: one can load the asl.lua system without the asllib.lua which is a bunch of helpers providing classic shapes like lfo(), ar(), adsr() to save on space.
taking this approach to the i2c context, perhaps loading the whole function table could be optional, or able to be unset if there's memory issues. we could also wrap each modules function table in its own file which is able to be loaded individually. this makes it easier to ask others to provide crow-support for their own modules, by just adding a single lua file and one line to the 'load all' function body.
this feels annoying (having to explicit say "load the kria_ii_commands" before using them), but it would be one way without requiring a separate reference guide. if things are stored in C-headers, there's obviously no issue, the hard part is just figuring out how to access them.
eg: the response to ii.get_commands() could actually fetch a C-string in flash, rather than a lua-string in RAM.
from crow.
just added a ram-usage checker that's called after each lua lib that's loaded. haven't had the chance to try it yet, but will be good to see these numbers.
from crow.
duplicate of #17
from crow.
Related Issues (20)
- ASL noise generator design
- clock accuracy within a coroutine
- `fnl` frame-based animator function in stdlib
- interpreter to allow calculator style usage (no print required)
- ASL is running at half speed HOT 4
- improve & add documentation HOT 6
- when using `input.mode = 'clock'` sense start/stop
- memory allocation issues with new modules HOT 1
- 'make -j' build successful, but with errors HOT 2
- Updates needed for Disting EX ii support
- `CROW.Q1` gives `ii lines are low` when 2 crows are on bus HOT 4
- ASL modulations HOT 1
- Clear script by self-patching on boot HOT 1
- ceify the metro lib HOT 3
- Clock & Metro libraries are slightly out of sync
- v1.1 hardware changes HOT 8
- v4.0.2RC fails when accessing `input` in druid HOT 2
- Firmware compilation fails under Docker (Windows) with missing GLIBC_2.27 HOT 5
- script clear doesn't seem to purge everything (v4.0.3)
- clock.sync to values less than 1 can cause rapid-firing (v4.0.3) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crow.