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

resource: Defer SHA-256 calculation into the future #5323

Merged
merged 4 commits into from Jul 19, 2022

Conversation

bjhargrave
Copy link
Member

The osgi.content capability must hold the SHA-256 value of the
resource. But this value is rarely used. So, when building a resource
from a file, we defer the SHA-256 calculation until actually needed.
The can help performance of FileSetRepository used by bndtools m2e.

However, we do need the hashCode of the SHA-256 value early, so use
a substitute hashCode value based upon the File object. This is not
perfect since two files can hold identical content and the hashCode of
their SHA-256 values should be identical. But in practice, this should
work when creating a resource from a file since the early need for the
hashCode of the SHA-256 value is in the computing of the hashCode of
the capability so it can be inserted in a set. But creating a resource
from a file only creates a single osgi.content capability.

Fixes #5322

bjhargrave added 4 commits Jul 19, 2022
The osgi.content capability must hold the SHA-256 value of the
resource. But this value is rarely used. So, when building a resource
from a file, we defer the SHA-256 calculation until actually needed.
The can help performance of FileSetRepository used by bndtools m2e.

However, we do need the hashCode of the SHA-256 value early, so use
a substitute hashCode value based upon the File object. This is not
perfect since two files can hold identical content and the hashCode of
their SHA-256 values should be identical. But in practice, this should
work when creating a resource from a file since the early need for the
hashCode of the SHA-256 value is in the computing of the hashCode of
the capability so it can be inserted in a set. But creating a resource
from a file only creates a single osgi.content capability.

Fixes bndtools#5322

Signed-off-by: BJ Hargrave <bj@hargrave.dev>
When we know the input is a Set, we don't need to remove any duplicates.

Signed-off-by: BJ Hargrave <bj@hargrave.dev>
Signed-off-by: BJ Hargrave <bj@hargrave.dev>
Signed-off-by: BJ Hargrave <bj@hargrave.dev>
@bjhargrave bjhargrave merged commit 78a26d7 into bndtools:master Jul 19, 2022
11 checks passed
@bjhargrave bjhargrave deleted the issues/5322 branch Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance: bndtools takes too long for SHA-256 and is not interruptable
1 participant