HomeSoftware Heritage

Replace `entry_to_bytes` with psycopg2's typecast

Description

Replace entry_to_bytes with psycopg2's typecast

entry_to_bytes and its friends were called many times (eg.
entry_to_bytes alone was called 40k times while indexing 500
origins with the metadata indexer), and its use of isinstance
used a non-negligible amount of CPU time.

Instead of using *_to_bytes function as post-processing on
all bits of data returned by postgresql, this patch tells psycopg2
to use a new typecast_bytea function when needed (in adapt_conn).
This function deffers the decoding work to psycopg2, which returns a
memoryview, which is turned into bytes.

Details

Provenance
vlorentzAuthored on Feb 1 2019, 11:04 AM
vlorentzPushed on Feb 1 2019, 2:00 PM
Differential Revision
D1054: Replace `entry_to_bytes` with psycopg2's typecast
Parents
rDCORE0e277770ad0f: Put the default_values argument of BaseDb.copy_to after cur and iten_cb
Branches
Unknown
Tags
Unknown
References
tag: 0.0.51
Build Status
Buildable 3936
Build 5163: test-and-build