CN103544276B - Method and device for displaying script files by virtual machine - Google Patents
Method and device for displaying script files by virtual machine Download PDFInfo
- Publication number
- CN103544276B CN103544276B CN201310499437.XA CN201310499437A CN103544276B CN 103544276 B CN103544276 B CN 103544276B CN 201310499437 A CN201310499437 A CN 201310499437A CN 103544276 B CN103544276 B CN 103544276B
- Authority
- CN
- China
- Prior art keywords
- file
- virtual machine
- compiling
- script
- script file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/957—Browsing optimisation, e.g. caching or content distillation
- G06F16/9574—Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Disclosed is a method and device for displaying script files by a virtual machine. The displaying method includes receiving page generating requests, containing target locations, sent by a client terminal; acquiring stored script files according to the target locations, retrieving compiled files compiled from the latest version of the script files; if the compiled files are retrieved, adopting the virtual machine to execute the compiled files, obtaining display files of the script files, and returning the display files used for displaying the page at the client terminal to the client terminal. According to the method, after the script files are determined, the retrieved compiled files are analyzed directly, so that the display files used for displaying the page at the client terminal. Since the compiles files are pre-stored, same script files are not required to be compiled repeatedly; source consumption is reduced, using rate of a system CPU is provided, and system load is reduced.
Description
Technical field
The present invention relates to show script file correlative technology field, particularly a kind of employing virtual machine shows script file
Method and device.
Background technology
Script file, i.e. dynamic web page file, such as php script files, using server end php script interpreters, point
Analysis, explanation, calculate php script files, generate the content of html format, respond to client browser.Due to needing to combine clothes
Data on business device, therefore existing script file display packing generally requires first compilation script file, perform type deduce and
Optimization, then parsing performs compiling file, obtains result of calculation, usually html format.Client obtains the result of calculation simultaneously
Show.
The method is normally applied on the server, and because the function of server is more powerful, cpu resource is more, therefore, clothes
Business device can support compiling and analytical capabilities substantially.
However, when the analysis of employing virtual machine, analyzing script file prior art, when customer volume is very big, CPU disappears
Consumption is higher.In analysis, calculating php scripts, CPU consumes higher official's virtual machine of such as php.Still using prior art
Script file display packing, is easily caused the problems such as system resource is not enough, and the virtual machine appearance of server can not provide service.
The content of the invention
Based on this, it is necessary to when for prior art, on a virtual machine perform script file shows, CPU consumes larger skill
Art problem, there is provided a kind of employing virtual machine shows the method and device of script file.
A kind of method that employing virtual machine shows script file, including:
The auto-building html files including target location for receiving client transmission are asked;
The script file for preserving is obtained according to the target location;
Retrieve the script file latest edition be compiled after compiling file, if retrieve it is described compiling text
Part, then perform the compiling file using virtual machine parsing, obtains the display file of the script file, and to the client
The display file is returned, the display file is used to show webpage in the client.
A kind of employing virtual machine shows the device of script file, including:
Auto-building html files request receiving module, the auto-building html files including target location for receiving client transmission please
Ask;
Script file acquisition module, for obtaining the script file for preserving according to the target location;
Compiling file obtains parsing module, and the compiling after the latest edition for retrieving the script file is compiled is literary
Part, if retrieving the compiling file, using virtual machine parsing the compiling file is performed, and obtains the script file
File is shown, and the display file is returned to the client, the display file is used to show webpage in the client.
The present invention is it is determined that after script file, the compiling file to retrieving directly carries out parsing execution, so as to be used
In the display file that webpage is shown in the client.Because compiling file is pre-saved, therefore for identical script
File, is compiled without the need for multiple, so as to reduce resource consumption, there is provided the utilization rate of system CPU, reduces system and bears
Carry.
Description of the drawings
Fig. 1 is the workflow diagram of the method that a kind of employing virtual machine of the invention shows script file;
Fig. 2 is the construction module figure of the device that a kind of employing virtual machine of the invention shows script file;
Fig. 3 show the system construction drawing of an example of the present invention.
Specific embodiment
With reference to the accompanying drawings and examples the present invention will be further described in detail.
The workflow diagram that a kind of employing virtual machine of the invention shows the method for script file is illustrated in figure 1, including:
Step S101, the auto-building html files including target location for receiving client transmission are asked;
Step S102, the script file for preserving is obtained according to the target location;
Step S103, retrieve the script file latest edition be compiled after compiling file, if retrieving institute
Compiling file is stated, then the compiling file is performed using virtual machine parsing, obtain the display file of the script file, and to institute
State client and return the display file, the display file is used to show webpage in the client.
Wherein, in step S102, script file is stored in disk or data base.
Wherein, in step S103, compiling file is compiled in advance and preserved, and each script file then becomes new through updating
The script file of version.In execution step S103, the compiling file after being only compiled to the latest edition of script file is straight
Parsing is connect, if what is preserved is that the legacy version to script file is compiled the compiling file for obtaining, script file is illustrated
Latest edition is not compiled, therefore can not directly parse.
Compiling file after the present embodiment is compiled as a result of the latest edition to script file is directly parsed, and one
Individual compiling file can be used always until script file there occurs change, therefore avoids script file is repeatedly compiled,
So as to cause the wasting of resources.
If not retrieving the compiling file, display file can not be generated, directly exit flow process.However,
In one of embodiment, also include:
If not retrieving the compiling file, analyzed simultaneously using the lexical analyzer and syntax analyzer of virtual machine
The latest edition for compiling the script file obtains compiling file, preserves the compiling file, and parses the execution compiling text
Part, obtains the display file for showing webpage in the client of the script file, and returns institute to the client
State display file.
In the case where compiling file is not preserved, analyze and compile using the lexical analyzer and syntax analyzer of virtual machine
The latest edition for translating the script file obtains compiling file, while the compiling file for newly obtaining is preserved, subsequently to use.
Wherein in one embodiment, the compiling file is preserved in the buffer.
The present embodiment preserves compiling file in the buffer, then access more quick.
Wherein in one embodiment, the compiling file includes bytecode.Bytecode is bytecode.
Wherein in one embodiment, the bytecode is performed using the intermediary bytes code resolver parsing of virtual machine, obtained
Static file to the script file is used as the display file.
Wherein in one embodiment, the bytecode is performed using the instant compiler parsing of virtual machine, by the word
Section code translates into machine code, using the machine code as the display file.
Bytecode in compiling file is translated into machine code by the present embodiment using instant compiler, removes explanation bytecode
Process, greatly improve calculating speed, can further improve performance.Php codes are particularly according to each different project
Function, the present embodiment can lift the performance of 50%-30%, and common average behavior is lifted at 100%.
The construction module figure that a kind of employing virtual machine of the invention shows the device of script file is illustrated in figure 2, including:
Auto-building html files request receiving module 201, for receiving the auto-building html files including target location of client transmission
Request;
Script file acquisition module 202, for obtaining the script file for preserving according to the target location;
Compiling file obtain parsing module 203, the latest edition for retrieving the script file be compiled after volume
Translation part, if retrieving the compiling file, using virtual machine parsing the compiling file is performed, and obtains the script text
The display file of part, and the display file is returned to the client, the display file is used to be shown in the client
Webpage.
Wherein in one embodiment, also include:
Compiling file generates parsing module, if for not retrieving the compiling file, using the word of virtual machine
Method analyzer and syntax analyzer are analyzed and compile the latest edition of the script file and obtain compiling file, preserve the compiling
File, and the execution compiling file is parsed, obtain the display for showing webpage in the client of the script file
File, and return the display file to the client.
Wherein in one embodiment, the compiling file is preserved in the buffer.
Wherein in one embodiment, the compiling file includes bytecode.
Wherein in one embodiment, the bytecode is performed using the intermediary bytes code resolver parsing of virtual machine, obtained
Static file to the script file is used as the display file.
Wherein in one embodiment, the bytecode is performed using the instant compiler parsing of virtual machine, by the word
Section code translates into machine code, using the machine code as the display file.
The system construction drawing of an example of the present invention is illustrated in figure 3, including:Client browser 31 and virtual machine
Server 32.
Wherein, server 32 includes:
The web server component 321 of Http Web Server functions is realized, is realized using libevent;
Bytecode caching 322(Code Cache), it is SQLite database(SQLite database are conventional one kind
Data base)Caching, for caching intermediary bytes code, reduce morphology, syntactic analysiss number of times.
Virtual machine 323 on server 32 adopts HipHop VM(HHVM).Include on virtual machine 323:
Analysis engine 3231, including lexical analyzer(Lexical Analysor)And syntax analyzer(Semantic
Analysor), for analyzing php source codes, generate bytecode.Realized using the Flex and Bison of linux system.
Intermediary bytes code interpreter 3232(Interpreter), bytecode is performed for explaining, return operation result.
Instant compiler 3233(Just In Time compilation, JIT), for bytecode to be translated into into machine code
Perform, improve the code speed of service.
The operation principle of system shown in Figure 3 is as follows:
The web server component 221 of virtual machine receives client browser 21 to the server 22 for loading virtual machine
The auto-building html files request sent;
Web server component 221 finds corresponding php script files according to the hostname that auto-building html files are asked;
If identifying php script files, the cache in SQLite database, i.e. bytecode caching can be first checked
322, if having compiled bytecode, if it has, and the php script files be not modified, it will directly adopt
The bytecode of the caching is performed with middle oneself code resolver 3232 parsing.If it did not, analysis engine 3231 will be called
To compile php script files, perform type and deduce, optimization, and result is stored to the cache of SQLite database, i.e. byte
In code caching 322.
Alternatively, the parsing of bytecode is performed and can also be realized using instant compiler 3233, bytecode is translated
Perform into machine code, to improve the code speed of service.
Compare with existing php officials virtual machines:
It is compared using the search service page of company:
Domain name:search.jd.com
Reach the standard grade a server:172.17.5.110
Operational effect is shown in Tables 1 and 2:
CPU usage peak value(%) | CPU usage meansigma methodss(%) | |
Php officials virtual machine | 14.38 | 8.32 |
Virtual machine of the present invention | 7.53(Reduce by 47.63%) | 4.47(Reduce by 46.27%) |
The CPU usage comparison sheet of table 1
The system average load comparison sheet of table 2
Embodiment described above only expresses the several embodiments of the present invention, and its description is more concrete and detailed, but and
Therefore the restriction to the scope of the claims of the present invention can not be interpreted as.It should be pointed out that for one of ordinary skill in the art
For, without departing from the inventive concept of the premise, some deformations and improvement can also be made, these belong to the guarantor of the present invention
Shield scope.Therefore, the protection domain of patent of the present invention should be defined by claims.
Claims (12)
1. a kind of method that employing virtual machine shows script file, it is characterised in that include:
The auto-building html files including target location for receiving client transmission are asked;
The script file for preserving is obtained according to the target location;
Retrieve the script file latest edition be compiled after compiling file, if retrieving the compiling file,
The compiling file is performed using virtual machine parsing, the display file of the script file is obtained, and is returned to the client
The display file, the display file is used to show webpage in the client;
The virtual machine is located at server end.
2. the method that employing virtual machine according to claim 1 shows script file, it is characterised in that also include:
If not retrieving the compiling file, analyze and compile using the lexical analyzer and syntax analyzer of virtual machine
The latest edition of the script file obtains compiling file, preserves the compiling file, and parses the execution compiling file, obtains
To the display file for showing webpage in the client of the script file, and the display is returned to the client
File.
3. the method that employing virtual machine according to claim 1 shows script file, it is characterised in that by the compiling text
Part is preserved in the buffer.
4. the method that employing virtual machine according to claim 1 shows script file, it is characterised in that the compiling file
Including bytecode.
5. the method that employing virtual machine according to claim 4 shows script file, it is characterised in that using virtual machine
The parsing of intermediary bytes code resolver performs the bytecode, and the static file for obtaining the script file shows text as described
Part.
6. the method that employing virtual machine according to claim 4 shows script file, it is characterised in that using virtual machine
Instant compiler parsing performs the bytecode, and the bytecode is translated into into machine code, and the machine code is shown as described
Show file.
7. a kind of employing virtual machine shows the device of script file, it is characterised in that include:
Auto-building html files request receiving module, the auto-building html files including target location for receiving client transmission are asked;
Script file acquisition module, for obtaining the script file for preserving according to the target location;
Compiling file obtain parsing module, the latest edition for retrieving the script file be compiled after compiling file,
If retrieving the compiling file, the compiling file is performed using virtual machine parsing, obtain the aobvious of the script file
Show file, and the display file is returned to the client, the display file is used to show webpage in the client;
The virtual machine is located at server end.
8. employing virtual machine according to claim 7 shows the device of script file, it is characterised in that also include:
Compiling file generates parsing module, if for not retrieving the compiling file, using the morphology point of virtual machine
Parser and syntax analyzer are analyzed and compile the latest edition of the script file and obtain compiling file, preserve the compiling text
Part, and the execution compiling file is parsed, obtain the display text for showing webpage in the client of the script file
Part, and return the display file to the client.
9. employing virtual machine according to claim 7 shows the device of script file, it is characterised in that by the compiling text
Part is preserved in the buffer.
10. employing virtual machine according to claim 7 shows the device of script file, it is characterised in that the compiling text
Part includes bytecode.
11. employing virtual machines according to claim 10 show the device of script file, it is characterised in that adopt virtual machine
The parsing of intermediary bytes code resolver perform the bytecode, the static file for obtaining the script file shows text as described
Part.
12. employing virtual machines according to claim 10 show the device of script file, it is characterised in that adopt virtual machine
Instant compiler parsing perform the bytecode, the bytecode is translated into into machine code, using the machine code as described
Show file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310499437.XA CN103544276B (en) | 2013-10-22 | 2013-10-22 | Method and device for displaying script files by virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310499437.XA CN103544276B (en) | 2013-10-22 | 2013-10-22 | Method and device for displaying script files by virtual machine |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103544276A CN103544276A (en) | 2014-01-29 |
CN103544276B true CN103544276B (en) | 2017-05-10 |
Family
ID=49967728
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310499437.XA Active CN103544276B (en) | 2013-10-22 | 2013-10-22 | Method and device for displaying script files by virtual machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103544276B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104572194B (en) * | 2014-12-30 | 2019-03-08 | 北京奇虎科技有限公司 | A kind of module loading method and apparatus |
CN111694571B (en) * | 2019-03-15 | 2022-11-01 | 上海寒武纪信息科技有限公司 | Compiling method and device |
WO2021184304A1 (en) * | 2020-03-19 | 2021-09-23 | 深圳市欢太科技有限公司 | Distributed cache compilation method and system |
CN112954075B (en) * | 2021-03-29 | 2023-04-07 | 中信银行股份有限公司 | Business function implementation method, system, corresponding device and storage medium |
CN113656720B (en) * | 2021-08-25 | 2024-04-16 | 北京达佳互联信息技术有限公司 | Page display method and device, electronic equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102750281A (en) * | 2011-04-19 | 2012-10-24 | 腾讯科技(深圳)有限公司 | Script processing method and system of browser |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101446955A (en) * | 2008-12-11 | 2009-06-03 | 深圳市茁壮网络技术有限公司 | Method for implementing a browser as well as device and system thereof |
US8707161B2 (en) * | 2009-09-30 | 2014-04-22 | Facebook, Inc. | Executing server side script code specified using PHP on a server to generate dynamic web pages |
CN102043807A (en) * | 2009-10-12 | 2011-05-04 | 英业达股份有限公司 | Web page generating system and method based on configuration files |
-
2013
- 2013-10-22 CN CN201310499437.XA patent/CN103544276B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102750281A (en) * | 2011-04-19 | 2012-10-24 | 腾讯科技(深圳)有限公司 | Script processing method and system of browser |
Also Published As
Publication number | Publication date |
---|---|
CN103544276A (en) | 2014-01-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10324741B2 (en) | Speeding up dynamic language execution on a virtual machine with type speculation | |
US8627281B2 (en) | Method, computer program and computer system for converting source code written in dynamically typed language into target code written in statically typed language and executing target code | |
CN103544276B (en) | Method and device for displaying script files by virtual machine | |
US8539464B2 (en) | Distributed just-in-time compilation | |
AU2014275115B2 (en) | Debugging native code by transitioning from execution in native mode to execution in interpreted mode | |
CN104182267B (en) | Compilation Method, means of interpretation, device and user equipment | |
US9182953B2 (en) | Hybrid dynamic code compiling device, method, and service system thereof | |
US20130205282A1 (en) | Transferring program execution from compiled code to interpreted code | |
US7788657B2 (en) | Targeted runtime compilation | |
US8683319B2 (en) | Shared script files in multi-tab browser | |
US8122439B2 (en) | Method and computer program product for dynamically and precisely discovering deliquent memory operations | |
US20110138373A1 (en) | Method and apparatus for globally optimizing instruction code | |
US9740463B2 (en) | Mechanism for increasing the performance of multiple language programs by inserting called language IR into the calling language | |
WO2013036703A2 (en) | Profile guided jit code generation | |
US20130024759A1 (en) | Shared Script Files in Multi-Tab Browser | |
US9619215B2 (en) | Pre-compiler | |
US20110067018A1 (en) | Compiler program, compilation method, and computer system | |
CN103412754A (en) | Dynamic language code execution method and device | |
US20110276950A1 (en) | Name binding extensibility for typed programming language | |
Ogasawara | Workload characterization of server-side javascript | |
GB2563381A (en) | Method and apparatus for executing a scripting language | |
Park et al. | Dynamic code compression for JavaScript engine | |
Park et al. | Javascript ahead-of-time compilation for embedded web platform | |
CN111782239B (en) | Method, device and storage medium for software packaging and source code version information acquisition | |
CN105786465A (en) | Scripting language execution method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |