-
Notifications
You must be signed in to change notification settings - Fork 358
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
Enable concurrenct access to SchemaLoader #323
base: master
Are you sure you want to change the base?
Conversation
@xeipuuv Hi there 👋🏼 -- I noticed there hasn't been a commit in the last 3 years. Let me know if this library is still maintained and if this change is acceptable to you. Thank you! |
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.
Thanks! Not a maintainer, but left a comment 🤗
Let do a quick attempt what it could look like with a RWMutex
func (spd *schemaPoolDocuments) Load(key string) (*schemaPoolDocument, bool) { | ||
val, ok := spd.mp.Load(key) |
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.
tbh, I wonder if the added complexity of using a sync.Map
is needed for this use-case. sync.Map
(by itself) does not have type-safety, so requires all the extra boilerplating in this file, and while sync.Map
can perform better, in many situations it may actually be slower (unless high concurrency, large number of cores); https://medium.com/@deckarep/the-new-kid-in-town-gos-sync-map-de24a6bf7c2c
opened #324 as a possible alternative; let me know what you think 😅 |
/cc @johandorland PTAL |
@thaJeztah It might be fun to benchmark the two alternatives in different scenarios. But I'm definitely glad with either solutions if one can get merged upstream :) |
Adds a type-safe wrapper for the standard library's
sync.Map
as it fits the usecase of how gojsonschema uses its internal pool: write once, read many.Fixes xeipuuv/gojsonreference#9