Jump to content

Best of both worlds: less RAM and less lag?


Recommended Posts

Before RoG was a thing, DS was fun little game; it now expanded into a huge universe, with several DLCs and multi-player fan base, aka welcome here!

As the devs kept delivering the much promised content updates, performance and optimization is now needed more than ever. I feel my computer slowly heating up, and sometimes even have to close my Chrome/Firefox so the game could run more smoothly.

Klei recently addressed this issue partially with Texture Streaming feature; they enabled a lot of performance optimizations before, like reducing built-up trash stuff in the World etc. Worked wonders!

There is something even better now (link below), which will deliver smoother game play experience via both reducing RAM usage and optimized GPU usage. Please check out. It has been tested for over 4 years and was hid from us since it was a technology from the far East, China. To use this mod, you simply download a .zip, put it in the proper folder, and create a "desktop icon" (not needed for Windows) for the game.

 

How does it work? Casual players probably doesn't care, but most of DS/DST are written in a language called Lua. There was been major updates to the language itself (from 5.1 to 5.3), and the machinery that allows Lua programs to run in our computers (LuaJIT). This "mod" uses the second. The hope is that, once enough users rely on this, Klei may as well incorporate this to their code base. Thanks to the developer @PaintDream, the whole thing is licensed freely so incorporating it into DS/DST will be a breeze.

Strange New Powers we have!

 

Link to comment
Share on other sites

LuaJIT 

Just now, Ryne21 said:

Enabling Texture steaming seems to cause random fps drops for me, so I keep it disabled for a smooth 60fps but still, really hope to check this out. Can you put me the link to get the .zip file and the tutorial probably? ( Im using windows)

https://paintdream.github.io/DontStarveLuaJIT/

Just click "Download Binary" and download the latest release.

Link to comment
Share on other sites

29 minutes ago, Shosuko said:

Why was the game built in lua anyway?  Isn't lua kinda a garbage language?

If by garbage you mean really good, then yes.

LUA is quite a powerhouse for being able to do it all while having integration with C.

It also is a lot easier to have mods interact with the base code since all of the source code is there for you to poke at and manipulate, and with the simple syntax and no memory management on the programmer's part makes it a quick to pick up language.

 

If you want to see how to not make a modding interface, look no further than Bethesda's engine for any of their titles.  Clunky software to make things in, records overriding other mods on things that a mod didn't even change because the data is copied as a chunk rather than an edit, etc.  Once again the modders picked up their slack by making tools to help alleviate the pain that is installing and managing mod lists for any of their games.  Things like BOSS/LOOT to help sort, Wyre Bash to help merge, and TESEdit for manually going in for those got-to-have interaction fixes.  I shudder to think of how many issues those modders went through to make the content they did.

Compare that to Klei's where I've really yet to see any major mod conflict when the mods are done in good practices such as not direct file replacements.

Link to comment
Share on other sites

6 hours ago, Ryne21 said:

Thank you so much :D 
Is this some sort of witch spell? cause my game now runs smooth as hell

Here's a performance report on comparision between LuaJIT and official Lua version: http://luajit.org/performance_x86.html

Usually its accelarate ratio ranges from 10x to 40x, which mostly depends on how many code can be jitted.

Most jit compilers, including LuaJIT, jit code with native assembly in adaptive way. It trace the execution of function, find out the "hot path" and convert it into machine code if it fits the specified restrictions of code layout.  Unfortunetly the Don't Starve's OOP system may break these restrictions at some situation and only a part of code can be jitted. Even so, the accelate ratio of this game is still optimistic, floating around 5x~20x in my practice.

 

Link to comment
Share on other sites

Hey there, person with a wonderful but evil profile picture,

How dare you ask me to live without my browser? That is how you lost track of reality and betrayed the beloved Will Carter, remember? Aren't you excited by this new magic trick that I discovered from the far East?

Link to comment
Share on other sites

Question: does this require manual fixes or updates when the game self updates, or will the game auto update as usual without having to install/move extra things?

I know nothing about programming or modding, so feel free to roll eyes if its a silly question :-D

Link to comment
Share on other sites

8 minutes ago, ShadowDuelist said:

Question: does this require manual fixes or updates when the game self updates, or will the game auto update as usual without having to install/move extra things?

I know nothing about programming or modding, so feel free to roll eyes if its a silly question :-D

I think @PaintDream is the best person to answer this, but for what I know it works if the game update:

a) was just the lua scripts rather than the binary (these kind of updates are most common as 99% of the game is written in lua and doesn't requires changes to the C/C++ stuff, e.g. content updates, bug fixes etc.);

b) did change the binary (what double-clicking the game icon runs) but not in a significant way that interferes with this "mod"

c) did change the binary to "patch" this "issue" that improved game performance, in which case @PaintDream has to find a completely new workaround

 

Link to comment
Share on other sites

2 minutes ago, Charlie Dark said:

Wow this magic trick is far too complicated... 

Hmm? How is "download a zip, copy files over there, change the call icon and voila" more complicated than "get a hat and a rabbit, hide it under the hat, and flip the hat over"? If confused, try to read the manual that comes with the .zip --- the readme file.

Link to comment
Share on other sites

2 minutes ago, hyiltiz said:

Hmm? How is "download a zip, copy files over there, change the call icon and voila" more complicated than "get a hat and a rabbit, hide it under the hat, and flip the hat over"?

You probably should acknowledge mentioning programming syntax and operations to people with no programming knowledge whatsoever is like trying to debate some low-key String Theory problem to illiterate people: we "the 21st century Peasants" can only look at you with moist, dumbfound eyes and perhaps nod as admitting you're saying.. something. Oh well, not everything is for everyone. Or.. "learn to code" :black_eyed:

Link to comment
Share on other sites

2 minutes ago, x0-VERSUS-1y said:

You probably should acknowledge mentioning programming syntax and operations to people with no programming knowledge whatsoever is like trying to debate some low-key String Theory problem to illiterate people: we "the 21st century Peasants" can only look at you with moist, dumbfound eyes and perhaps nod as admitting you're saying.. something. Oh well, not everything is for everyone. Or.. "learn to code" :black_eyed:

I'm not completely clueless... I just understood it much better with umm... the "assistant's" language. 

Link to comment
Share on other sites

15 minutes ago, x0-VERSUS-1y said:

You probably should acknowledge mentioning programming syntax and operations to people with no programming knowledge whatsoever is like trying to debate some low-key String Theory problem to illiterate people: we "the 21st century Peasants" can only look at you with moist, dumbfound eyes and perhaps nod as admitting you're saying.. something. Oh well, not everything is for everyone. Or.. "learn to code" :black_eyed:

Probably... Hmm, the coding part did use a lot of dark magic, but I thought the end result was packaged nicely. Here is the readme file minus the Chinese translations of each English sentence (BTW it also works in Linux Desktop, not just for Dedicated Servers; I just tested it out):

# DontStarveLuaJIT for Windows
	LuaJIT for DontStarve (compatible with DS, RoG, SW, DST for Windows, Dedicated Server for Linux)

####  PLEASE BACKUP YOUR SAVES BEFORE APPLYING THIS PATCH. 
All technique detils available at: https://zhuanlan.zhihu.com/p/24570361 (Chinese only).

-------------------------------------------------------

## Installation(安装): 
### Windows
	Copy all files from folder "win" to "[Your Don't Starve [Together] Directory]/bin/"

### Linux
        Copy all files from folder "linux" to "[Your Don't Starve [Together] Directory]/bin/lib32/", start game with the following environment setting:
	export LD_PRELOAD=libpreload.so

	NOTICE: libpreload.so/liblua51.so/liblua51DS.so may rely on some C-runtime libraries, which are not present on your computer.
	Installing gcc:i386 may be help. For example, you can run this command in Ubuntu/Debian:
	sudo apt-get install gcc:i386

## Acknowledgements(致谢): 
	Great thanks to the following players from Baidu Tieba for testing and suggestions!
	风雨凌芸、子恒Clark、359368170、lild100、kkrbdsgc、__PeakChen、o裙下臣o、 LC_1992、
	pikry、沉睡森丶林、可待year、绝世鱼人、王太太平、力玄破、渊_雎、风雪归途、幻想草莓梦、
	sharpwind95、乔碧萝、辣椒小皇纸

 

Link to comment
Share on other sites

2 minutes ago, Charlie Dark said:

I'm not completely clueless... I just understood it much better with umm... the "assistant's" language. 

For me "most jit compilers, including LuaJIT, jit code with native assembly in adaptive way. It trace the execution of function, find out the "hot path" and convert it into machine code if it fits the specified restrictions of code layout" is like Ancient Mayan. I realize I lack even the basic definitions on what "jit complilers" are or "native assembly" means. Sure I could search on web, but I suppose context also plays a big role. Is like re-learning how to read and think when you're past your prime.

 

8 minutes ago, hyiltiz said:

Probably... Hmm, the coding part did use a lot of dark magic, but I thought the end result was packaged nicely. Here is the readme file minus the Chinese translations of each English sentence:


# DontStarveLuaJIT for Windows
	LuaJIT for DontStarve (compatible with DS, RoG, SW, DST for Windows, Dedicated Server for Linux)

####  PLEASE BACKUP YOUR SAVES BEFORE APPLYING THIS PATCH. 


All technique detils available at: https://zhuanlan.zhihu.com/p/24570361 (Chinese only).

-------------------------------------------------------

## Installation(安装): 

### Windows

	Copy all files from folder "win" to "[Your Don't Starve [Together] Directory]/bin/"

### Linux

        Copy all files from folder "linux" to "[Your Don't Starve [Together] Directory]/bin/lib32/", start game with the following environment setting:
	
	export LD_PRELOAD=libpreload.so

	NOTICE: libpreload.so/liblua51.so/liblua51DS.so may rely on some C-runtime libraries, which are not present on your computer.
	Installing gcc:i386 may be help. For example, you can run this command in Ubuntu/Debian:

	sudo apt-get install gcc:i386


## Acknowledgements(致谢): 

	Great thanks to the following players from Baidu Tieba for testing and suggestions!
	
	风雨凌芸、子恒Clark359368170lild100kkrbdsgc__PeakCheno裙下臣o LC_1992
	pikry、沉睡森丶林、可待year、绝世鱼人、王太太平、力玄破、渊_雎、风雪归途、幻想草莓梦、
	sharpwind95、乔碧萝、辣椒小皇纸
	

 

I would love to make my DST performance go higher but am afraid if something occurs I won't know how to get myself out of that pickle ...aside reinstalling the game ofc. But thank you for providing such optimization alternative.

Link to comment
Share on other sites

33 minutes ago, ShadowDuelist said:

Question: does this require manual fixes or updates when the game self updates, or will the game auto update as usual without having to install/move extra things?

I know nothing about programming or modding, so feel free to roll eyes if its a silly question :-D

I apply a flexible method to adapt with Dont'Starve executable files. It has been working fine at most cases since 2016. The only small exception is that Klei merges thier lua engine modifications in DST to DS in early 2019. (I maintained two versions before that time, one for DS and the other for DST, since there are some differences between them) So after that update, the old DS version was deprecated and then nicely replaced by DST version. :D

Binary mods are not always appliable when the host game upgrades. But I've tried my best to make it compatible. I think it would be OK if Klei are not to do strange modification on thier lua engine.

Link to comment
Share on other sites

17 minutes ago, x0-VERSUS-1y said:

I would love to make my DST performance go higher but am afraid if something occurs I won't know how to get myself out of that pickle ...aside reinstalling the game ofc. But thank you for providing such optimization alternative.

To get yourself out of the pickle if something goes awry, before you copy the files, make a copy of the original files. To get back to "normal" without re-installing the whole game, just move the "mod" out of the folder and put the original ones back in.

More specifically, copy [Game]/bin/WINMM.dll to your Desktop before you copy this "mod" over there as a backup. To get back, copy that file from the Desktop back in there. In Linux, simply open the game through Steam rather than the command line.

Link to comment
Share on other sites

18 minutes ago, x0-VERSUS-1y said:

For me "most jit compilers, including LuaJIT, jit code with native assembly in adaptive way. It trace the execution of function, find out the "hot path" and convert it into machine code if it fits the specified restrictions of code layout" is like Ancient Mayan. I realize I lack even the basic definitions on what "jit complilers" are or "native assembly" means. Sure I could search on web, but I suppose context also plays a big role. Is like re-learning how to read and think when you're past your prime.

 

I would love to make my DST performance go higher but am afraid if something occurs I won't know how to get myself out of that pickle ...aside reinstalling the game ofc. But thank you for providing such optimization alternative.

Usually the script language (e.g. Python, Lua) executes in a virtual machine (VM). VM is flexible and portable but slow. The JIT (Just-In Time) technique are designed to run threse languages directly in your CPU native language (native assembly), which could be much faster than virtual machine.

Link to comment
Share on other sites

9 minutes ago, hyiltiz said:

To get yourself out of the pickle if something goes awry, before you copy the files, make a copy of the original files. To get back to "normal" without re-installing the whole thing, just move the "mod" out of the folder and put the original ones back in. More specifically, copy [Game]/bin/WINMM.dll to your Desktop before you copy this "mod" over there as a backup. To get back, copy that file from the Desktop back in there. In Linux, simply open the game through Steam rather than the command line.

In fact you needn't to make a backup of original binaries files (but still recommend to backup your save slots). DontStarveLuaJIT does not replace any existing binary files :D

Your uninstallation steps are correct and it can be much simpler: just rename the WINMM.dll with aother name if you want to disable/uninstall it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...