gor
Retired Admin
Netherlands
5511 Posts |
Posted - 02 February 2002 : 18:21:46
|
<b><font color=red>v4-Discussion-1: Reducing the String Load</font id=red></b>
<font color=green>Note: Some of the numbers given are rounded values as they differ from language to language and from version to version. Additionaly I don't have any benchmark results on how much load the current solution puts on the server.</font id=green>
In v40b03patch003 there are around 2000 strings, which make a language file more than 200KB in size. With the current method, 1,2 or more language files are included from config.asp, i.e. for every forum page hit. This number will increase as we continue to add new features.
Every language variable has a line in LangNNNN.asp (NNNN= Decimal LCID value of the locale) with the following format: <pre id=code><font face=courier size=2 id=code> strLangFILENAMEXXXXX = "translated string" '"original string" </font id=code></pre id=code> where FILENAME is the filename of the ASP file, XXXXX is a sequence number.
Currently, the strings of the selected language is executed only (2000 equates), although all (N languages * 2000 lines) are loaded through the INCLUDE.
<font color=green>These are some exact values: Number of strings = 1971 Avg. string length = 32.1 chars Number of unique strings = 1481 One line on average = 100 bytes </font id=green>
To reduce the server load, the following can be done:
<font color=red>a) We can get rid of the '"original string" part</font id=red>
<b>Pros</b>: reducing the size from 200K to 120K <b>Cons</b>: Not easy to translate (solution: we can strip them out before releasing, they do already exist in Lang1033.asp file) <b>My idea</b>: We can do this
<font color=red>b) Dividing the language files</font id=red>: We can divide the language file into subsections (Admin*.asp, "rarely used"*.asp, "mostly used"*.asp), i.e. creating the files LangAdminNNNN.asp, LangRareNNNN.asp, LangNNNN.asp. LangNNNN.asp will be included by config.asp to support main forum behaviour (reading & posting - 756 strings), LangAdmin.asp (543 strings) will be included by only those admin files, LangRareNNNN.asp (policy, register, FAQ, help files, setup, some of the moderation related pop_*.asp etc - 672 strings) will be included only by those files.
I think %80 percent of the will go in LangNNNN, %15 percent will go to LangRareNNNN, %5 will go to LangAdminNNNN.
<b>Pros</b>: With the above assumption, there will be 884 language strings executed on the average. <b>Cons</b>: Number of files to keep track of increase, must put include directives into each file, must decide which goes where. <b>My idea</b>: We can do this
<font color=red>c) Keeping track of files</font id=red>: We can include a string just at the beginning of the file like: <pre id=code><font face=courier size=2 id=code> strThisFileName = "active.asp" </font id=code></pre id=code> or better get it from the script address, and use this info to execute only the related equates (using a select case for example). Some strings from inc_*.asp files must be executed anyway.
<b>Pros</b>: The number of executed equates will well drop to 250 on the average. With this, we can support more detailed <TITLE> directives like "XXX Forums - Search Page" in any language. We can also support other MODs like Active Users. <b>Cons</b>: Harder to keep track, harder to maintain. <b>My idea</b>: We can do this
<font color=red>d) Define Global Strings (or Functions)</font id=red>: At an early stage I decided to keep each file standalone and not to define/share language variables among files. I.e. every file has its own definition for "All Forums". This will increase the flexibility in language and in program writing, but we have some performance lost here. Note that there are no duplicates in a file, i.e if the same phrase is used more than once, they use the same variable. Here are the current values: There are 46 such strings (some very similar) repeated more than 3, resulting in 322 definitions (322-46=276 duplicates).
We can define variables like <font color=green>LangGlobal00010 = "All Forums"</font id=green>.
<b>Pros</b>: Although this can be though as a good %14 reduction, it is not actually so. The average number of chars in these repeated strings are 12.8, so the savings in file size and server memory are much less (~%8). The real saving will be in the area of translation. <b>Cons</b>: It will not be easy for the programmer to keep trach of these "global" variables. You must use a "lexicon" to find what they are. <b>My idea</b>: We should not do this. But as most of these variables are repeated as a part of repeated code, such as the folder structure at the beginning of each file, error messages saying "go back to enter data" or "There Was A Problem With Your Details", link for the "admin section", entries for "username" or "password". I think it will be better to move some of these into inc_functions.asp as a whole, also reducing the repeated strings.
<font color=red>e) Use of generic strings</font id=red>: It is more user/programmer friendly, but the wording used is very detailed in most cases. For example just to go back these are used (numbers are how many times they are repeated): <BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> Back 2 Back to Admin Forums 1 Back To Admin Home 11 Back to Archive Admin 1 Back To Forum 5 Back to Forums Administration 2 Back to Moderator Options 1 Back to previous page 1 Back To Search Page 1 Go Back 1 Go back to correct the problem. 2 Go Back To Enter Data 15 Go Back to Forum 2 Go Back to Re-Authenticate 4 Go Back To Retry 1 <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
These can just be replaced by "Go Back", except the cases where there are two different destinations (if any). This methodology will significantly reduce the number of strings used, translated, loaded by the server, kept in the memory, ...
<b>Pros</b>: Significant reduction in string data. <b>Cons</b>: Less user/programmer/administrator friendly. <b>My idea</b>: We can carefully examine the language data to reduce the strings where appropriate.
Well, these are only my thoughts, I'm sure you can find more. Any idea will be very much appreciated <img src=icon_smile.gif border=0 align=middle>.
<font color=pink><b>Think Pink</b></font id=pink>Post v40b03 Patches |
|