php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51610 1 second+ needed for OCI8 versus PDO/oci to open/close connection and exit
Submitted: 2010-04-20 05:24 UTC Modified: 2010-11-10 20:07 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: marioroy at verizon dot net Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.3SVN-2010-04-20 (snap) OS: Linux & Snow Leopard
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marioroy at verizon dot net
New email:
PHP Version: OS:

 

 [2010-04-20 05:24 UTC] marioroy at verizon dot net
Description:
------------
Is this normal to see the native OCI8 1.3.5 or later requiring additional time to 
run code snippet shown below when accessing Oracle 10.2.0.4. I'm seeing this at 
work as well (SUSE Linux).  Therefore, I have stayed with OCI8 1.2.5 for the 
moment.

Notice how the time is the same when using the PDO/OCI interface.


Test script:
---------------
# Native OCI8 Performance:
#
# PHP 5.2.14 201004191430, OCI8 1.2.5:  ~ 0.15 seconds ;this is nice
#
# PHP 5.3.3  201004191430, OCI8 1.2.5:  ~ 0.25 seconds ;takes 0.1 extra here
# PHP 5.3.3  201004191430, OCI8 1.3.5:  ~ 1.20 seconds ;slowness begins when
# PHP 5.3.3  201004191430, OCI8 1.4.1:  ~ 1.20 seconds ;script exits for 1.3.5+
# PHP 5.3.3  201004191430, OCI8 1.4.2:  ~ 1.20 seconds

<?php

$conn = oci_connect('hr', 'hr', '//localhost:1521/mac10g');

if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

oci_close($conn);

exit;

?>

# PDO/OCI Performance:
#
# PHP 5.2.14 201004191430, OCI8 1.2.5:  ~ 0.15 seconds ;very fast
#
# PHP 5.3.3  201004191430, OCI8 1.2.5:  ~ 0.15 seconds ;same as PHP 5.2.14 :)
# PHP 5.3.3  201004191430, OCI8 1.3.5:  ~ 0.15 seconds ;very happy to see this
# PHP 5.3.3  201004191430, OCI8 1.4.1:  ~ 0.15 seconds ;with 1.3.5+
# PHP 5.3.3  201004191430, OCI8 1.4.2:  ~ 0.15 seconds

<?php

try {
    $conn = new PDO('oci:dbname=127.0.0.1/mac10g', 'hr', 'hr');
}
catch (PDOException $e) {
    trigger_error("Could not connect to database: ". $e->getMessage(), E_USER_ERROR);
}

$conn = NULL;

exit;

?>


Expected result:
----------------
I'm hoping that PHP 5.3.2+ with OCI8 1.4.1+ can perform as fast as PHP 5.2.13 with 
OCI8 1.2.5 when using the native driver.  This is why I have stayed with 1.2.5 at 
work.

It wasn't until tonight that I saw the times the same via the PDO interface. That 
made my day.

Actual result:
--------------
The native OCI8 1.3.5+ requires extra time to open/close and exit.  The time delta 
is 1 second for such a small code snippet.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-21 18:31 UTC] sixd@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: sixd
 [2010-04-21 18:31 UTC] sixd@php.net
This is expected.  There is a shutdown cost at process termination from closing 
a timer thread needed by the connection rearchitecture of OCI8 1.3. 

Most deployments either do not start and stop PHP processes frequently, or are 
not sensitive to the time between completing the work of the script and the 
termination of the process.

It's possible that PDO_OCI may be changed in future and might get the same 
behaviour.
 [2010-04-22 00:33 UTC] marioroy at verizon dot net
Thank you for the feedback.
 [2010-06-17 15:29 UTC] chris at leaflock dot net
I filed a duplicate bug, but I noticed something unique; It doesn't happen with Oracle 10.2.0.3.

I'm pretty unhappy about this, what is the benefit and/or requirement for this behavior, and why does it not happen in 10.2.0.3?

Oracle's own SQLPlus doesn't display this behavior.  I never thought I'd see the day when SQLPlus could do something faster for me than PHP.
 [2010-06-18 04:19 UTC] sixd@php.net
The PHP OCI8 code changes in question have been in production for two
years.  They were introduced to support Database Resident Connection
Pooling and FAN for scalability in web apps.  The dominant use cases
for SQL*Plus and PHP are very different.
 [2010-06-26 05:44 UTC] marioroy at verizon dot net
I have applied this patch to oci8.c.  It resolves the issue for me.  I set 
use_spool to 0.  Can we have use_spool enabled/disabled via an oci8.ini 
directive.  Thanks.

@@ -1711,7 +1693,7 @@
        smart_str hashed_details = {0};
        time_t timestamp;
        php_oci_spool *session_pool = NULL;
-       zend_bool use_spool = 1;           /* Default is to use client-side 
session pool */
+       zend_bool use_spool = 0;           /* Default is to use client-side 
session pool */
        zend_bool ping_done = 0;
 [2010-07-08 07:37 UTC] sixd@php.net
I wonder what issues the following patch would bring?


Index: oci8.c
===================================================================
--- oci8.c    (revision 300858)
+++ oci8.c    (working copy)
@@ -35,6 +35,7 @@
 #include "php.h"
 #include "ext/standard/info.h"
 #include "php_ini.h"
+#include "SAPI.h"
 #include "ext/standard/php_smart_str.h"

 #if HAVE_OCI8
@@ -3187,7 +3188,11 @@
         PHP_OCI_CALL(OCIHandleFree, ((dvoid *) session_pool->err, 
OCI_HTYPE_ERROR));
     }

-    if (session_pool->env) {
+    /* When PHP is invoked as a CLI then destruction of the
+     * Environment handle is left to the OS at PHP process shutdown.
+     */
+    if (session_pool->env && !sapi_module.phpinfo_as_text) {
         PHP_OCI_CALL(OCIHandleFree, ((dvoid *) session_pool->env, 
OCI_HTYPE_ENV));
     }
 [2010-08-07 02:24 UTC] sixd@php.net
Automatic comment from SVN on behalf of sixd
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=301960
Log: Fixed bug #51610 (Using oci_connect causes PHP to take a long time to exit). Do PECL OCI8 1.4.3 release
 [2010-08-07 02:28 UTC] sixd@php.net
-Status: Wont fix +Status: Closed
 [2010-08-07 02:28 UTC] sixd@php.net
The increase in exit cleanup time occurs when OCI8 1.3+ uses Oracle 10.2.0.4+ client libraries.

There is a resolution in OCI8 1.4.3.  An Oracle client library fix (Oracle bug 9891199) is also needed for this patch to have an effect.

OCI8 1.4.3 will be included in the PHP release _after_ PHP 5.3.3.
 [2010-11-10 20:07 UTC] sixd@php.net
The fix for Oracle bug 9891199 is included in Oracle libraries from 11.2.0.2 
onwards.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC