@akkartik mhmm, it depends, I'd say time? But uxn just waits if a frame takes longer than expect so it's not really noticeable.

This week, people revealed in the mailing list that they were using fancy stashing techniques to spread logic over multiple frames, I realized that I was using the update vector for almost everything, and maybe I shouldn't do.. that-

I haven't written an application that was larger than 20kb yet, so not space.

@neauoire Do you use any dynamic memory? Like, lines.love is 40KB, but it usually allocates a few tens of MB.

With LÖVE I've been finding that CPU is plentiful -- as long as I don't use too much memory, overloading the GC.

@akkartik I've been seeing the words garbage collection flying around all day on here, and I went to look it up and I don't understand what they mean.

Is uxn garbage collected?

@neauoire @akkartik AFAIK uxn is fully non-GC, but that's also because it is fully programmer-managed memory anyway out of that static 64KB block.

the rough tl;dr is: in a language like C you call malloc() to get a block of heap ram at some given size, and have to remember to free() that ram later or it'll leak. in a language like, say, Lua, strings just "come into existence" as far as the developer is concerned, and the VM tracks its lifecycle (and calls free() for you when the string "dies")

@klardotsh @neauoire I think uxn not only doesn't have a GC, it has no heap allocation of any kind. There's no equivalent of Forth's ALLOCATE. Which means that if you limit the stack and load a small program, most of the 64KB can't ever be used.

(Which is totally fine! Great, even!)

@akkartik @klardotsh we tend do that sort of stuff in program-space instead of it being part of the assembler I think.

@neauoire @akkartik @klardotsh has been quite delightful learning that you learned about garbage collection today :) a constant reminder of how unpredictably varied folks exposure is to... everything.

as far as i can tell the go-to uxn approach is to statically allocate however much memory you think you'll need?

you could write a heap allocator or GC for uxn, and it may be useful if you wanted to do something with dynamic needs; variable size level + variable number of enemies in a game for eg

@neauoire @akkartik @klardotsh for the most part in 64k there's just not _that_ much room for heavily dynamic requirements, so you just don't do it. might farm it out to the disk instead and use files as dynamically sized records.

slightly funny; if you went down the lisp route rather than the forth one you'd almost certainly had to write a GC right at the start, as it's pretty fundamental. but you wouldn't have written an assembler, probably. different challenges in different spaces.

@maxc @akkartik @klardotsh I just woke up with a realization about this,

So, recently I was implementing cons cells in Uxn, and I stopped because I couldn't figure out how to handle the data that I pop out from between two cells, it would create all that wasted memory space, so I flagged these addresses into another list to recycle them, but in the end I stopped because I figured that maybe my implementation was just not a good way to do this.

But maybe that was a form of garbage collection

@neauoire @maxc @akkartik @klardotsh that's not unusual, that just sounds like a basic allocator.

@aeva @neauoire @maxc @akkartik @klardotsh The term "the heap" for all dynamically allocated memory in fact originates from the practice of storing exactly such a free list in a heap data structure.

(I assume at some point you want to add some minor additional smarts to coalesce adjacent free blocks, but I'm not familiar with specific implementations.)

@mcc @neauoire @maxc @akkartik @klardotsh a basic heap allocator is probably a fine place to start either way for something like an uxn application as it's easy to reason about and easy to replace if perf calls for it. does uxn have perf instrumentation?

Follow

@aeva @mcc @maxc @akkartik @klardotsh uxntal doesn't have built-in heap allocation, but it can be built in uxntal itself if someone needs it in the programs.

git.sr.ht/~rabbits/uxn/tree/ma

I haven't had to make use of that yet, personally. Whenever I need modifiable strings, I store them in a buffer with a fixed size in the zero-page.

What are perf instrumentation?

· · Web · 1 · 0 · 1

@neauoire @mcc @maxc @akkartik @klardotsh performance instrumentation. this would either be part of the uxn emulator, or something that attaches to the emulator, or something the application would add hooks for, and it measure timing information and other things (eg power consumption) to help you identify bottlenecks by severity and thus what actually needs to be optimized in a given application.

@neauoire @aeva @mcc @akkartik @klardotsh at its most basic, profiling can just be a list of numbers indicating time spent in different regions of the program; usually either a running total or last X counts (frames or whatever) to get min/max/mean/median from.

Ideally you can nest regions.

Could be instruction counts or wall clock time or battery consumption or, whatever.

From that you can see at a coarse level "updating the rabbits is slow" and start reasoning about why.

@maxc @neauoire @mcc @akkartik @klardotsh it's worthwhile skill, as improving the computational efficiency of programs also improves their energy efficiency

@maxc @neauoire @aeva @akkartik @klardotsh One nice thing is you don't have to write most of the profiler yourself; there are existing profiling tools, and there are ways you can do things like call a function at periodic times inside your interpreter and have an external profiler time the differences between that function call.

Sign in to participate in the conversation
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.