patchGNU MIX Development Kit - Patches: patch #9778, Change vm->address_list from...


You are not allowed to post comments on this tracker with your current authentication level.

patch #9778: Change vm->address_list from GSList to GQueue

Submitter:  Kevin Brunelle <brunk23>
Submitted:  Thu 28 Mar 2019 03:01:39 AM UTC
Category:  None Priority:  5 - Normal
Status:  In Progress Privacy:  Public
Assigned to:  jao Open/Closed:  Open

Wed 10 Apr 2019 01:46:07 AM UTC, comment #2: 

[I am also including this here, as I don't know if the email response went through. It doesn't show up as a comment.]

A configuration option would be a great idea.  As you probably can guess from the additional patch to the original one, I quickly ran into a situation where I wanted to be able to turn it on, off, and change the limit without needing to recompile.  That is why I added a command to allow it to be changed during execution.

I have to be honest.  I am not 100% sure how to add configuration options.  I don't know if I could do it myself. I probably could figure it out, but it might take me a little bit while I work through the code for it.

I have no problem giving the copyright assignment to the FSF.  I just assumed that they took copyright ownership of the code when I contributed to the project.  I thought that was how GNU worked.  If you tell me what I need to do, I will get that done.  I am sure I am not on file already.

Thanks for everything.

-Kevin Brunelle

Kevin Brunelle <brunk23>
Tue 09 Apr 2019 01:53:28 AM UTC, comment #1: 


This looks reasonable, and I agree it's in general a good idea to move to a bounded list.

I as thinking that maybe it'd be a good idea to read the maximum number of entries from a configuration option... what do you think?

Also: I think that we are going to need a copyright assignment to the FSF for you (if you're OK with that), because GNU MDK is copyrighted by them and that's GNU's policy.  Are you already on file?  If not, I can help with that and point you to more info!

Thanks again!

Jose Antonio Ortega Ruiz <jao>
Group administrator
Thu 28 Mar 2019 03:01:39 AM UTC, original submission:  

The current emulator uses an unbounded linked list for tracking the memory locations our program has traveled through.  On a 64 bit system, this requires 16 bytes of data for every instruction a MIX program performs.  For small programs that are light on computation cycles, this does not cause a noticeable issue.

For programs that execute hundreds of millions of instructions, this causes the memory footprint of the virtual machine to explode.  I have attached an example MIXAL program that will cause the VM to grow to over 3 GB of memory usage when run.

To run the sample, compile coin-opt.mixal (attached), run it in mixvm, and enter 499 at the prompt.  Or use the following steps.

mixasm coin-opt.mixal && echo "499" | mixvm --run coin-opt.mix

This patch changes all the appropriate references to GQueue references and also caps the backtrace at 1000, which can be changed in the mixlib/mix_vm.h header.  I feel like 1000 is a reasonable limit for the vast majority of debugging needs.  Most people are looking back at the most recent 100 instructions or so.

You can get the original behavior (unlimited tracing) back by setting the MIX_MAXTRACE to -1, albeit with a slightly higher memory cost (24 bytes per instruction).  Or you can turn it off entirely by setting it to 0.

Using a queue doesn't change the logic of the program in any significant way, and it allows programs to run for an extended period of time without consuming all the memory on the machine and slowing down to a crawl.

-Kevin Brunelle

Kevin Brunelle <brunk23>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #46670:  backtrace3.patch added by brunk23 (819B - text/x-patch - Update documentation for the new abilities. It should also be noted that these patches fix a buffer overrun that caused segmentation faults due to j going over SIZE and then writing to BUFFER[j].)
file #46669:  backtrace2.patch added by brunk23 (6KiB - text/x-patch - This enhances the previous patch, and permits the user to change the limit from inside the emulator with a new command (sbt).)
file #46649:  backtrace.patch added by brunk23 (5KiB - text/x-patch)
file #46650:  coin-opt.mixal added by brunk23 (3KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jao (Posted a comment)
  • -email is unavailable- added by brunk23 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-09 jao StatusNone In Progress
        Assigned toNone jao
    2019-03-29 brunk23 Attached File- Added backtrace3.patch, #46670
    2019-03-29 brunk23 Attached File- Added backtrace2.patch, #46669
    2019-03-28 brunk23 Attached File- Added backtrace.patch, #46649
        Attached File- Added coin-opt.mixal, #46650

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code