-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
serialize the access to mutable shared state in System.IO.Packaging #56367
Conversation
Tagging subscribers to this area: @dotnet/area-system-io-compression Issue Details
runtime/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackageXmlStringTable.cs Line 120 in 57bfe47
and it's being reused for every runtime/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs Lines 477 to 482 in 57bfe47
the problem is that it's mutable and can be modified by multiple threads at the same time (#43012) We have few options:
Fixes #43012
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea how frequently this is accessed? I'm a little concerned this will introduce a large bottleneck when used at scale. But I agree it's the simplest/safest solution.
I am sorry, but no.
Most probably if this was used a lot at scale, we would be getting more bug reports related to this issue. If we ever receive a complain, we should reconsider making the base type thread-safe using some lock-free data structures like |
PackageXmlStringTable.NameTable
is static:runtime/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackageXmlStringTable.cs
Line 120 in 57bfe47
and it's being reused for every
PartBasedPackageProperties
instance:runtime/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs
Lines 477 to 482 in 57bfe47
the problem is that it's mutable and can be modified by multiple threads at the same time (#43012)
We have few options:
NameTable
type thread-safe. Since it's not thread-safe by design (it's stated in docs) I am not sure if it's the best idea as it might be used properly in other libraries and all of them would pay the perf penaltyXmlReaderSettings
- there are no public methods that allow for that and the type is defined in different lib, moreover it seems that we do want to have global instance to use cheaper reference comparisions:runtime/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs
Lines 839 to 842 in 57bfe47
System.IO.Packaging
. I think it's the lesser evil and this is what this PR does.Fixes #43012