Skip to content

Commit

Permalink
SCS cache
Browse files Browse the repository at this point in the history
Summary:
A really basic cache. We're expecting tends of thousands of revisions,
so cache size is not really an issue. I went with a bounded cache that
has approximate LRU by keeping two semi-spaces, kind of like a 2-space
GC. It's suboptimal in space and time but scores highly in simplicity.

Reviewed By: nhawkes

Differential Revision: D55800094

fbshipit-source-id: d2655a6e5d3b5d886e159d200fe22024f4098af1
  • Loading branch information
Simon Marlow authored and facebook-github-bot committed Apr 15, 2024
1 parent 2654ffe commit a5ff658
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions glean/glass/Glean/Glass/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ data Config = Config
-- ^ whether to trust listDatabases and how often to wait to retry N times
, numWorkerThreads :: Maybe Int
, snapshotBackend :: EventBaseDataplane -> Some SnapshotBackend
, sourceControl :: EventBaseDataplane -> Some SourceControl
, sourceControl :: EventBaseDataplane -> IO (Some SourceControl)
, tracer :: GlassTracer
, welcomeMessage :: EventBaseDataplane -> Config -> IO Text
}
Expand All @@ -64,7 +64,7 @@ setSnapshotBackend snapshotBackend config =
config { snapshotBackend = snapshotBackend }

setSourceControl
:: (EventBaseDataplane -> Some SourceControl)
:: (EventBaseDataplane -> IO (Some SourceControl))
-> Config -> Config
setSourceControl sourceControl config =
config { sourceControl = sourceControl }
Expand Down
7 changes: 4 additions & 3 deletions glean/glass/Glean/Glass/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ withEnv Glass.Config{..} gleanDB f =
withLogger cfgapi $ \logger ->
withFb303 serviceName $ \fb303 ->
withBackendWithDefaultOptions evp cfgapi gleanService (Just schema_id)
$ \backend ->
withLatestRepos backend (sourceControl evp) (Just logger)
$ \backend -> do
scm <- sourceControl evp
withLatestRepos backend scm (Just logger)
(if isRemote gleanService then listDatabasesRetry else Nothing) refreshFreq
$ \latestGleanRepos -> do
repoMapping <- getRepoMapping
Expand All @@ -97,7 +98,7 @@ withEnv Glass.Config{..} gleanDB f =
, gleanIndexBackend = indexBackend backend
, gleanDB = gleanDB
, snapshotBackend = snapshotBackend evp
, sourceControl = sourceControl evp
, sourceControl = scm
, ..
}

Expand Down
2 changes: 1 addition & 1 deletion glean/glass/Glean/Glass/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ configParser = do
listDatabasesRetry <- listDatabasesRetryParser
numWorkerThreads <- workerThreadsParser
snapshotBackend <- pure (const $ Some NilSnapshotBackend)
sourceControl <- pure (const (Some NilSourceControl))
sourceControl <- pure (const (return (Some NilSourceControl)))
tracer <- pure mempty
welcomeMessage <- pure (pure (pure . defaultWelcomeMessage))
return Glass.Config{configKey = Glass.defaultConfigKey, ..}
Expand Down

0 comments on commit a5ff658

Please sign in to comment.