-
Notifications
You must be signed in to change notification settings - Fork 4
3-way diff #37
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
Merged
Merged
3-way diff #37
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
8a1f180
Bump unison dep to get new synhash stuff
ChrisPenner 1f09c22
Start splitting off stuff into NamespaceDiffs2
ChrisPenner 935cb35
Move Postgres PPED module into Share
ChrisPenner 449e736
Implement Postgres names generator
ChrisPenner e9588f6
Bump unison dep
ChrisPenner bcc10a5
Compute typelookups
ChrisPenner f367af2
Add v1 version of getting names in project
ChrisPenner 62f9947
Implement making libdeps
ChrisPenner fae54bd
WIP transitive deps
ChrisPenner 442191f
bump unison
mitchellwrosen bcb7068
get code compiling with wundefineds
mitchellwrosen 3e8aee7
sketch out 3-way namespace diff
mitchellwrosen 6f9f603
move a couple helpers from Share.NamespaceDiffs to Share.NamespaceDif…
mitchellwrosen 6313e81
move combineTermsAndTypes from Share.NamespaceDiffs to Share.Namespac…
mitchellwrosen b331c9f
move compressNameTree from Share.NamespaceDiffs to Share.NamespaceDif…
mitchellwrosen 8b2b877
continue processing namespace diff
mitchellwrosen 27eeb4e
Return propagated updates in diff payload
mitchellwrosen 86f2573
switch over to three-way namespace diffs in `diffCausals`
mitchellwrosen 30dc66e
delete old two-way diff stuff and consolidate modules again
mitchellwrosen e070923
pass through (but ignore) libdeps diffs in diffCausals
mitchellwrosen def99ff
add libdeps diff to the json blob
mitchellwrosen a231016
⅄ main → share-3waydiff
mitchellwrosen c3eeac1
omit constructors from term diff, rename/rekey namespace_diffs table
mitchellwrosen 0791861
⅄ main → share-3waydiff
mitchellwrosen 3f98db4
⅄ main → share-3waydiff
mitchellwrosen d2e5038
delete accidentally-created Postgres.hs file
mitchellwrosen 7821ef5
re-run transcripts
mitchellwrosen b931f3e
⅄ main → share-3waydiff
mitchellwrosen 56c8332
bump unison dep
mitchellwrosen 53df207
⅄ bump-unison-dep → share-3waydiff
mitchellwrosen 421da83
include propagated updates in diff payload
mitchellwrosen 86a397d
properly filter out parts of a diff that contain only constructors
mitchellwrosen 5466a91
⅄ main → share-3waydiff
mitchellwrosen 262077d
fix namespace diff from-branch
mitchellwrosen a513698
include propagated updates in namespace diff
mitchellwrosen 24dd624
bump to ucm-0.5.37 in ci
mitchellwrosen 81dc256
re-run transcripts with ucm 0.5.37
mitchellwrosen fc7c912
⅄ main → share-3waydiff
mitchellwrosen d887e00
use Compose instead of MaybeT
mitchellwrosen a4edbc4
re-enable contribution diffs background worker
mitchellwrosen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| -- Recreate namespace diffs table, since we're changing a foreign key reference | ||
| -- Could truncate and alter columns instead, but it's more work | ||
|
|
||
| DROP TABLE namespace_diffs; | ||
|
|
||
| CREATE TABLE namespace_diffs ( | ||
| left_causal_id INTEGER NOT NULL REFERENCES causals(id) ON DELETE CASCADE, | ||
| right_causal_id INTEGER NOT NULL REFERENCES causals(id) ON DELETE CASCADE, | ||
|
|
||
| -- Since different codebases can have different variable names and such we also need to sandbox diffs by codebase owner | ||
| left_codebase_owner_user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, | ||
| right_codebase_owner_user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, | ||
|
|
||
| diff JSONB NOT NULL, | ||
|
|
||
| PRIMARY KEY (left_causal_id, right_causal_id, left_codebase_owner_user_id, right_codebase_owner_user_id) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| module Share.BackgroundJobs (startWorkers) where | ||
|
|
||
| import Ki.Unlifted qualified as Ki | ||
| import Share.BackgroundJobs.Diffs.ContributionDiffs qualified as ContributionDiffs | ||
| import Share.BackgroundJobs.Monad (Background) | ||
| import Share.BackgroundJobs.Search.DefinitionSync qualified as DefnSearch | ||
|
|
||
| -- | Kicks off all background workers. | ||
| startWorkers :: Ki.Scope -> Background () | ||
| startWorkers scope = do | ||
| DefnSearch.worker scope | ||
| ContributionDiffs.worker scope | ||
|
|
||
| -- Temporary disable background diff jobs until the new diffing logic is done. | ||
| -- ContributionDiffs.worker scope | ||
| -- SerializedEntitiesMigration.worker scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| -- | Efficiently fetch a Names object for a given set of labeled dependencies. | ||
| module Share.Names.Postgres (namesForReferences) where | ||
|
|
||
| import Control.Lens | ||
| import Data.Set qualified as Set | ||
| import Share.Postgres qualified as PG | ||
| import Share.Postgres.NameLookups.Conversions qualified as CV | ||
| import Share.Postgres.NameLookups.Ops qualified as NameLookupOps | ||
| import Share.Postgres.NameLookups.Types (NamesPerspective) | ||
| import Share.Postgres.NameLookups.Types qualified as NameLookups | ||
| import Share.Postgres.Refs.Types | ||
| import Share.Prelude | ||
| import Unison.LabeledDependency (LabeledDependency) | ||
| import Unison.Name (Name) | ||
| import Unison.Names (Names) | ||
| import Unison.Names qualified as Names | ||
| import Unison.Reference qualified as V1 | ||
| import Unison.Referent qualified as V1 | ||
|
|
||
| namesForReferences :: forall m. (PG.QueryM m) => NamesPerspective -> Set LabeledDependency -> m Names | ||
| namesForReferences namesPerspective refs = do | ||
| withPGRefs <- | ||
| Set.toList refs | ||
| & CV.labeledDependencies1ToPG | ||
| (termNames, typeNames) <- foldMapM namesForReference withPGRefs | ||
| pure $ Names.fromTermsAndTypes termNames typeNames | ||
| where | ||
| -- TODO: Can probably speed this up by skipping suffixification. | ||
| namesForReference :: Either (V1.Referent, PGReferent) (V1.Reference, PGReference) -> m ([(Name, V1.Referent)], [(Name, V1.Reference)]) | ||
| namesForReference = \case | ||
| Left (ref, pgref) -> do | ||
| termNames <- fmap (bothMap NameLookups.reversedNameToName) <$> NameLookupOps.termNamesForRefWithinNamespace namesPerspective pgref Nothing | ||
| let termNames' = termNames <&> \(fqn, _suffixed) -> (fqn, ref) | ||
| pure $ (termNames', []) | ||
| Right (ref, pgref) -> do | ||
| typeNames <- fmap (bothMap NameLookups.reversedNameToName) <$> NameLookupOps.typeNamesForRefWithinNamespace namesPerspective pgref Nothing | ||
| let typeNames' = typeNames <&> \(fqn, _suffixed) -> (fqn, ref) | ||
| pure $ ([], typeNames') | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Probably worth testing one of the common queries on prod with and without suffixification to see if the real-world cost changes :)
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.
Yeah, how might we go about doing this? (Btw, this was one of the functions you authored before I took over)
Uh oh!
There was an error while loading. Please reload this page.
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.
It's a little leg-work to do it, sorry >_>
The queries it's running are here: https://github.com/unisoncomputing/share-api/blob/main/src/Share/Postgres/NameLookups/Queries.hs#L44-L122
You'll need to copy-paste that, then manually fill in the parameters into the query which is a little annoying tbh; you can probably query a release or something from the
debug_project_releasesview, then cross reference that withscoped_term_name_lookupto get the params you need;From there you can
EXPLAIN ...and/orEXPLAIN ANALYSEon the queries with and without the suffixification.If you need DB credentials you can get a read-only login for psql via
vault read secret/production/enlil/userdb-readonly; For some reason our main DB is still calledusers🤷🏼Or my preferred method:
Uh oh!
There was an error while loading. Please reload this page.
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.
If you need a hand knowing where to poke around don't hesitate to ask, it's probably good to get more folks used to digging around :)