diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2024-02-18 15:59:48 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-19 11:58:12 +0000 |
| commit | 3bd2c69e70853584beaaa5a4fd62589fa051d911 (patch) | |
| tree | 3dc6469a1895cc7a31a58e4fc9dc43cef9a82cfb /bitbake/lib/hashserv/sqlalchemy.py | |
| parent | be909636c608d5ba24a41327c53d6a4ba3b70151 (diff) | |
| download | poky-3bd2c69e70853584beaaa5a4fd62589fa051d911.tar.gz | |
bitbake: hashserv: Add unihash-exists API
Adds API to check if the server is aware of the existence of a given
unihash. This can be used as an optimization for sstate where a client
can query the hash equivalence server to check if a unihash exists
before querying the sstate cache. If the hash server isn't aware of the
existence of a unihash, then there is very likely not a matching sstate
object, so this should be able to significantly cut down on the number
of negative hits on the sstate cache.
(Bitbake rev: cfe0ac071cfb998e4a1dd263f8860b140843361a)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv/sqlalchemy.py')
| -rw-r--r-- | bitbake/lib/hashserv/sqlalchemy.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/sqlalchemy.py b/bitbake/lib/hashserv/sqlalchemy.py index 873547809a..0e28d738f5 100644 --- a/bitbake/lib/hashserv/sqlalchemy.py +++ b/bitbake/lib/hashserv/sqlalchemy.py | |||
| @@ -48,6 +48,7 @@ class UnihashesV3(Base): | |||
| 48 | __table_args__ = ( | 48 | __table_args__ = ( |
| 49 | UniqueConstraint("method", "taskhash"), | 49 | UniqueConstraint("method", "taskhash"), |
| 50 | Index("taskhash_lookup_v4", "method", "taskhash"), | 50 | Index("taskhash_lookup_v4", "method", "taskhash"), |
| 51 | Index("unihash_lookup_v1", "unihash"), | ||
| 51 | ) | 52 | ) |
| 52 | 53 | ||
| 53 | 54 | ||
| @@ -279,6 +280,16 @@ class Database(object): | |||
| 279 | ) | 280 | ) |
| 280 | return map_row(result.first()) | 281 | return map_row(result.first()) |
| 281 | 282 | ||
| 283 | async def unihash_exists(self, unihash): | ||
| 284 | async with self.db.begin(): | ||
| 285 | result = await self._execute( | ||
| 286 | select(UnihashesV3) | ||
| 287 | .where(UnihashesV3.unihash == unihash) | ||
| 288 | .limit(1) | ||
| 289 | ) | ||
| 290 | |||
| 291 | return result.first() is not None | ||
| 292 | |||
| 282 | async def get_outhash(self, method, outhash): | 293 | async def get_outhash(self, method, outhash): |
| 283 | async with self.db.begin(): | 294 | async with self.db.begin(): |
| 284 | result = await self._execute( | 295 | result = await self._execute( |
