remote dba support
More
    HomeOracle InternalsShared vs Static Library Performance

    Shared vs Static Library Performance

    The article explains the benefits of a shared library and static library usage in application building for improving application performance.

    Build your applications using shared libraries for performance gaining

    In your C, Pro C, Pro C++, or other precompiler applications, encourage the use of shared libraries whenever possible. Shared libraries help conserve memory. Before addressing the memory advantage, let’s understand in detail how shared libraries differ from their more conventional static libraries.

    Any application written in a language such as C or C++ is a collection of source code files, consisting of a lot of custom code and calls to predefined library routines. The custom code will handle the business logic specific to your company, and the library routines will handle specific common functions, including conversion to uppercase, error-condition checks, and so on. Library functions help prevent reinventing the wheel for minuscule reusable tasks. Each source file will be compiled;  the source code will be checked for errors and then converted to an intermediate object file. Each object file consists of relatively error-free code and a number of links to specific library routines, which remains unresolved. Then all the object files and necessary library files are linked together to resolve all these tangled-up calls. Now here’s where we come to the main part of the story. There are two ways to resolve all the library calls; either by statically embedding each library call used into the actual code or by putting in jump-links to each library routine. The former method is referred to as static linking, and the latter method is called DYNAMIC linking. A typical Windows user can relate to this concept by thinking of object linking and embedding.

    - Advertisement -
    dbametrix

    Static linking uses libraries in a static manner since the library routines are sewn into the code; dynamic linking allows the libraries to be shared between different program files, and thus remain independent of the code. Links to shared libraries are resolved at runtime by locating the appropriate library link via the inserted jump link and dynamically loading the routine in memory.

    From a memory perspective, the shared libraries allow an application to use a lot less memory than static libraries because the reference to each library routine is loaded in only once and not duplicated with every call to the routine. While using static libraries, repeated calls to the same library routine will result in that routine being embedded multiple times in the code, resulting in fatter code that will take up more memory to load. Additionally, each individual program file will be smaller, taking up less disk space, since the library code is not embedded. In fact, most major applications, including Oracle on Unix and Linux, use shared libraries. At times, however, static libraries may provide superior performance, since there is no need to seek and load the library routines at runtime. However, this runtime delay will generally be incurred only the first time the program is run. Every subsequent call should be a lot faster since the routine has already been loaded into memory.

    Evaluate coding applications dealing extensively with the database for large batch jobs processing numerous rows in Pro*C or OCI, rather than PL/SQL. OCI especially has a more direct path to the kernel, and it is significantly faster than Pro*C and of course PL/SQL. Additionally, it is a lot easier to code explicit failover to a standby or data guard instance in Pro*C and OCI than in PL/SQL since, in the latter case, the database connection is acquired external to the PL/SQL routine, making reconnections within the PL/SQL code block difficult to achieve.

    When you want to make a strong Oracle DBA career then you should be aware of database services and other database technology. Without having knowledge of Oracle internals, Oracle performance tuning, and skill of Oracle database troubleshooting you can’t be an Oracle DBA expert. This expert DBA Team club blog always provides you latest technology news and database news to keep yourself up to date. You should need to be aware of Cloud database technology like DBaaS. All Oracle DBA tips are available in a single unique resource at our orageek. Meanwhile, we are also providing some sql tutorials for Oracle DBA. This is the part of Dbametrix Group and you would enjoy more advanced topics from our partner resource.

    - Advertisement -
    dbametrix
    - Advertisment -
    remote dba services

    Most Popular