9thFinger's ThreadingMod

Started by FrodoOf9Fingers, October 09, 2017, 04:38:56 PM

Previous topic - Next topic

Kiame

Quote from: FrodoOf9Fingers on October 20, 2017, 07:56:36 PM
Quote from: Kiame on October 20, 2017, 03:58:02 PM
For actions of pawns on shared objects - this is just observation from the game, not actually looking at the code

It looks like items get reserved by pawns before a pawn starts an action on it. In this case it could just be last one wins. If two pawns reserve a production table:
P1 checks and sees table is not reserved and-
P2 checks the table and it's not reserved and reserves it
P1 -reserves the table. P1 verifies it has the reservation on the table and starts going that way.
P2 Verifies it has the reservation but it doesn't. P2 does something else.

Worst case both pawns start doing an action the the bench but the losing pawn gives up after one update cycle.

Actually, the first pawn that reserves it gets it. It may be "overridden" by direct commands, but the first pawn to cycle through reserves the item, assuming that they both tried to get the item on the same tick.

If the same happens in a multi-threaded environment, the outcome is somewhat random (currently, working towards this point).

I should have been clearer, i was assuming a multi-threaded environment where P1 was on one thread and P2 on another - either P1 getting interrupted and both threads being executed on the same core or both executing at the same time. This might be a case where randomness is fine; again ignorant of the code though  ;)

kubolek01

No more 3 threads wasting? Yayyyyyyyy! MAKE IT REAL!
Eat lead, walking pile of silver! (greedy Player)
I...I can't do it. Leave it alive, please!(inner soul)
It lives 200 years to end up as a jacket?!(realists mind)
If I would go to vacation in off-Earth, even fictional place, I'd choose Nibel.

FrodoOf9Fingers

Progress update:

I just did some paper work to get this mod approved for school credit, meaning that if this counts as my senior project, I can spend more time on it (It has to be approved first). I think I'm almost to the 0 errors thrown stage, but I haven't tried anything with a18 and that might throw everything out of whack.

Kori


CannibarRechter

Quote from: Kori on November 04, 2017, 12:39:28 AM
good news! :)

Have you succeeded in getting RW to run in a debugger, out of curiosity?
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

FrodoOf9Fingers

Nope.

What I could do, is resolve all of the compile errors (2k +) leftover from the decompilation, which would take a long time for each new version of the game that comes out. Then I would be able to recompile it in debug mode and be able to attach a debugger (because then it would have a .PDB file with its corresponding sections in the code itself). This may be the killer of the project towards the end when I try to find odd behaviors caused by race conditions. But thats -tons- of work.

For now, I'm just using logging to a file. I might take a break to wait for the versions to settle down though, and then pick up again. I might work instead on a tool (or easy process using git) to find which files were added/changed between versions, and determine if a change needs my attention, making updating to a new version easier.

CannibarRechter

> Nope.

Crap. ;-P I keep hoping someone will know. ;-P
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

Barky

I'm not very good at this game.

lperkins2

So, Harmony and HugsLib are open source.  Your reverse patching issue could be solved by creating a modified version of Harmony, which might even get accepted upstream.  The other option would be to use the IL transformation stuff, that lets you see and edit existing methods.  Register a helper mod first in the list that reads the IL code before harmony has mucked about with it, then the multithread mod reinjects it back in later, possibly under a different method name.

FrodoOf9Fingers

Good news, this has been officially accepted as a senior project for my bachelor's degree.

@lperkins Thats true, but the author of Harmony mentioned that he had the requisite upgrades in the pipeline, I was waiting for him to figure it out. If he hasn't in the past 3-4 months, I'll go ahead and add in the functionality I need. The IL Transformation stuff is the thing that needed to be fixed. Making a second mod seems very excessive. The only benefit I really get from the update though is increased compatability with other mods.

Nightinggale

Quote from: FrodoOf9Fingers on January 26, 2018, 12:10:44 AM
Good news, this has been officially accepted as a senior project for my bachelor's degree.
I can't believe nobody replied to this yet. It's likely the best thing I have read on the forum this year. If nobody replies it will create the illusion that nobody cares and that's certainly not the case.
Quote from: FrodoOf9Fingers on January 26, 2018, 12:10:44 AMMaking a second mod seems very excessive. The only benefit I really get from the update though is increased compatability with other mods.
The best option is to get Harmony updated. The second best option is for you to update your copy of Harmony. Be aware that this can cause issues with other 0Harmony.dll files loaded in other mods. Either avoid using other mods, which use Harmony or remove 0Harmony.dll from those mods. Odds are that it will work with multiple versions if you load your version first. However loading two versions of the same assembly is undefined (not just in RimWorld) and it might cause weird issues and it's better to be safe than sorry. Loading an unmodified Harmony and then your version will likely prevent you from using your modifications.
ModCheck - boost your patch loading times and include patchmods in your main mod.

docssy

#26
Definitely watching. I have an i7 3930k waiting to eat Rimworld alive...

Just a request, B18 please. You'll have less work to bring it to Rimworld's 1.0, then having to migrate from A17 to 1.0. That, and B18 is getting more mods daily, which means modders are learning to update their code to be more efficient and subject to less errors.

Mehni

Re: Debugger.

https://github.com/0xd4d/dnSpy/wiki/Debugging-Unity-Games

I've also seen a recompiled mono dll for RimWorld floating around. Ask forum member neitsa.

Nightinggale

There is a forum thread about attaching a debugger. https://ludeon.com/forums/index.php?topic=25603.0. I have to admit that I haven't actually tried it yet, mainly because so far I haven't really needed anything more powerful than writing to the log.
ModCheck - boost your patch loading times and include patchmods in your main mod.

FrodoOf9Fingers

I'll give that a try, thanks for pointing that out.

Debugging is painful as is, but I don't think that going through those steps will be good enough. What I really wish I could do is attach a debugger to the native dll. If I correctly fixed all 2k+ errors leftover from the decompilation, I could create the pdb during my own build of rimworld. That, or maybe someone could convince Tynan to release a build in debug mode. Until then, logging and what not will be the bread and butter.

I just now finally got past all of the documentation I needed to write for the senior project (requirements document, a presentation, etc...), and coding can begin again. If I'm to graduate in April, this needs to be done by April, so expect that to be the release time (procrastination is the hardest thing...).