Skip to content

bpo-42064: Optimise sqlite3 state access, part 1 - #27273

Merged
miss-islington merged 6 commits into
python:mainfrom
erlend-aasland:sqlite-ac-defining-class
Jul 29, 2021
Merged

miss-islington merged 6 commits into
python:mainfrom
erlend-aasland:sqlite-ac-defining-class

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Jul 20, 2021 •

Copy link
Copy Markdown
Contributor

Prepare for module state:

  • Add "get state by defining class" and "get state by module def" stubs
  • Add AC defining class when needed
  • Add state pointer to connection context
  • Pass state as argument to utility functions

https://bugs.python.org/issue42064

Automerge-Triggered-By: GH:encukou

@encukou

encukou commented Jul 27, 2021

Copy link
Copy Markdown
Member

Have you thought about caching the state on Connection objects? That way you could get the state from a cursor by following two pointers. (And similarly for other cases where you have a Connection, which is most of pysqlite).
Connections are already quite heavy, so adding one more pointer might be a good trade-off.

pysqlite_get_state_by_cls looks like it'll eventually use _PyType_GetModuleByDef, which isn't as fast as following two pointers.

@erlend-aasland

erlend-aasland commented Jul 27, 2021 •

Copy link
Copy Markdown
Contributor Author

Have you thought about caching the state on Connection objects? That way you could get the state from a cursor by following two pointers. (And similarly for other cases where you have a Connection, which is most of pysqlite).
Connections are already quite heavy, so adding one more pointer might be a good trade-off.

Yes, I have though about it, but I don't remember why I didn't follow that idea :) As you say, it's probably a very good trade-off. I'll have a go at it.

pysqlite_get_state_by_cls looks like it'll eventually use _PyType_GetModuleByDef, which isn't as fast as following two pointers.

Both true. No, it was meant to use PyType_GetModuleState.

@erlend-aasland
erlend-aasland marked this pull request as draft July 27, 2021 21:29
@erlend-aasland
erlend-aasland marked this pull request as ready for review July 27, 2021 23:41
@erlend-aasland

Copy link
Copy Markdown
Contributor Author

PTAL!

@encukou

encukou commented Jul 29, 2021

Copy link
Copy Markdown
Member

Looks good, I just did a trivial merge to resolve a conflict.

@miss-islington

Copy link
Copy Markdown
Contributor

@erlend-aasland: Status check is done, and it's a success ✅ .

@miss-islington
miss-islington merged commit d542742 into python:main Jul 29, 2021
@erlend-aasland

Copy link
Copy Markdown
Contributor Author

Looks good, I just did a trivial merge to resolve a conflict.

Great, thanks and thank you for reviewing.

@erlend-aasland
erlend-aasland deleted the sqlite-ac-defining-class branch July 29, 2021 09:52
erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this pull request Jul 29, 2021
erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this pull request Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants