Raised This Month: $14 Target: $400
 3% 

The Pawn Memory Squeeze


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Plugin Info:     Modification:   ALL        Category:   Technical/Development        Approver:   Emp` (115)
[DeathTV] Sid 6.7
Member
Join Date: Oct 2007
Old 06-19-2008 , 19:28   The Pawn Memory Squeeze
Reply With Quote #1

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
Attached Files
File Type: sma Get Plugin or Get Source (amx_memorysqueeze.sma - 1321 views - 25.1 KB)
__________________
Power Votes Core << Democracy at your fingertips
Get Mortal Kombat Miscstats for CS

Last edited by [DeathTV] Sid 6.7; 07-21-2008 at 19:36. Reason: minor bugfix
[DeathTV] Sid 6.7 is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:44.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode