Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sqlite3] _pysqlite_connection_begin() optimisations #88208

Closed
erlend-aasland opened this issue May 4, 2021 · 2 comments
Closed

[sqlite3] _pysqlite_connection_begin() optimisations #88208

erlend-aasland opened this issue May 4, 2021 · 2 comments
Labels
3.11 only security fixes performance Performance or resource usage

Comments

@erlend-aasland
Copy link
Contributor

BPO 44042
Nosy @berkerpeksag, @serhiy-storchaka, @erlend-aasland
PRs
  • bpo-44042: sqlite3 begin transaction optimisations #25908
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-06-03.21:24:34.944>
    created_at = <Date 2021-05-04.23:41:24.768>
    labels = ['3.11', 'performance']
    title = '[sqlite3]  _pysqlite_connection_begin() optimisations'
    updated_at = <Date 2021-06-03.21:24:34.943>
    user = 'https://github.com/erlend-aasland'

    bugs.python.org fields:

    activity = <Date 2021-06-03.21:24:34.943>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-03.21:24:34.944>
    closer = 'pablogsal'
    components = []
    creation = <Date 2021-05-04.23:41:24.768>
    creator = 'erlendaasland'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44042
    keywords = ['patch']
    message_count = 2.0
    messages = ['392967', '395051']
    nosy_count = 3.0
    nosy_names = ['berker.peksag', 'serhiy.storchaka', 'erlendaasland']
    pr_nums = ['25908']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue44042'
    versions = ['Python 3.11']

    @erlend-aasland
    Copy link
    Contributor Author

    The following optimisations can be applied to _pysqlite_connection_begin():

    1. Return an int instead of a PyObject pointer

      Per now, we do Py_RETURN_NONE and Py_DECREF(result) if _pysqlite_connection_begin() was successful (normally the case). There's no reason to do this. Let's just it the C way: return -1 on error and 0 if things are ok.

    2. Defer error checking till post sqlite3_finalize()

      Any error code returned by sqlite3_step() will also be returned by sqlite3_finalize() for the same statement. From the SQLite docs:
      "If the most recent evaluation of statement S failed, then sqlite3_finalize(S) returns the appropriate error code or extended error code."

    3. Move _pysqlite_connection_begin() to Modules/_sqlite/cursor.c

      The single use is in _pysqlite_query_execute() in cursor.c. Moving it makes it possible for the compiler to apply more optimisations. At least so I've heard :)
      (As a side effect, the namespace will be cleaner.)

    @erlend-aasland erlend-aasland added 3.11 only security fixes performance Performance or resource usage labels May 4, 2021
    @pablogsal
    Copy link
    Member

    New changeset 3446516 by Erlend Egeberg Aasland in branch 'main':
    bpo-44042: Optimize sqlite3 begin transaction (GH-25908)
    3446516

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants