AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   The Pawn Memory Squeeze (https://forums.alliedmods.net/showthread.php?t=72976)

[DeathTV] Sid 6.7 06-19-2008 19:28

The Pawn Memory Squeeze
 
2 Attachment(s)
In Pawn, repeated strings are not represented by the same object or memory like in Java so this is an exercise to remedy that by tossing strings on the heap to stop redundancy in memory and save memory.

This script does two things:
A) Generates a dump file with all the tokenized data first (for fun), then the two string tables at the end of the file. The first one lists all strings and how many times they are repeated, the second one only contains repeated strings that are long enough to be considered. It reports how much memory can be saved by optimizing out everything.
B) Generation of an optimized source code file. Compiling this will make the amxx file take up less resources as reported by the compiler.

To begin processing (after you installed this plugin, of course) call amx_memorysqueeze from console upon a .sma file in your scripting directory.

At the end of processing, a report is generated on how much memory can be saved, and a new file is outputted in scripting with _memsqueeze.sma ending. The strings tossed on the heap should be declared before the very first function. The symbol dump is located in the matching txt file.
This does not have the ability to see around aliases to strings, ex defines, although it is possible.

Notes:
put a #define MEMORYSQUEEZE somewhere in your source file at top, and there will be dumped all the strings placed on the heap. Otherwise it will try to autoguess where the first function is defined and define the replacements immediately before the function.


The following is an example of how good this works, even on the largest plugins.
Quote:

Command: amx_memorysqueeze amx_super.sma
This is on a alpha or beta 4.0 for amx_super.
Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Header size: 5232 bytes
Code size: 178020 bytes
Data size: 98120 bytes
Stack/heap size: 16384 bytes; max. usage is unknown, due to recursion
Total requirements: 297756 bytes
Done.

Unsqueezed
Welcome to the AMX Mod X 1.76-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team
Header size: 5960 bytes
Code size: 196512 bytes
Data size: 104124 bytes
Stack/heap size: 16384 bytes; max. usage is unknown, due to recursion
Total requirements: 322980 bytes
Done.
If you are interested in code optimization, visit http://wiki.amxmodx.org/Optimizing_P...X_Scripting%29

soccdoodcss 06-19-2008 19:30

Re: The Pawn Memory Squeeze
 
Very interesting! I'll have to take a look into how this works. :D

bmann_420 06-19-2008 20:46

Re: The Pawn Memory Squeeze
 
Wow, that is an insight and a half man :D

Exolent[jNr] 06-19-2008 22:28

Re: The Pawn Memory Squeeze
 
Proof it works :)

I changed some of what your plugin does into mine (saving memory with strings) and also changed certain variables from "new" to "static".

Here was my result:
[img]http://img167.**************/img167/7808/06192008212554fr0.png[/img]

Thanks :up:

atomen 06-20-2008 05:09

Re: The Pawn Memory Squeeze
 
Actually this is very interesting as soccdoodcss said.
I have to try it asap when I get home from the country side.

Alka 06-20-2008 06:49

Re: The Pawn Memory Squeeze
 
A nice file and string manipulation, looks interesting...

Simon Logic 06-20-2008 08:44

Re: The Pawn Memory Squeeze
 
Code:
    new itwouldbeironicifididntdothis[] = "amx_memorysqueeze" ... register_concmd(itwouldbeironicifididntdothis,itwouldbeironicifididntdothis,ADMIN_RCON,         "shows how much memory a plugin could save by tossing strings on the heap")
:D

You should mention this plugin is for AMX/X 1.80 & higher only.

I think using such a tool via amx/x is more complex than a separate (console application or standalone script) tool. But i was still impressed :)

iknowiz58 07-18-2008 13:12

Re: The Pawn Memory Squeeze
 
1 Attachment(s)
I have tried this out an it is not working.

- Made sure your plugin was working
- I uploaded the deagsmapmanager.sma to the scripting folder.
- amx_memorysqueeze deagsmapmanager.sma in console
- Got the deagsmapmanger_memorysqueeze.sma
- Downloaded & added #define MEMORYSQUEEZE
- Attempted to compile and got the error
"Could not locate outputfile <compile failed>."

Could you help?

Attachment 28995

[DeathTV] Sid 6.7 07-21-2008 19:35

Re: The Pawn Memory Squeeze
 
Found the problem. Try the new code and report back


All times are GMT -4. The time now is 10:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.