Skip to content

Commit a004904

Browse files
authored
Merge pull request #274 from julia-vscode/sp/timings
feat: add some timing info for cache file download
2 parents 0eb6154 + 524e81f commit a004904

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/SymbolServer.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function download_cache_files(ssi, environment_path, progress_callback)
119119
n_done = 0
120120
n_total = length(to_download)
121121
progress_callback("Downloading cache files...", 0)
122+
t0 = time()
122123
for batch in Iterators.partition(to_download, 100) # 100 connections at a time
123124
@sync for pkg in batch
124125
@async begin
@@ -128,11 +129,14 @@ function download_cache_files(ssi, environment_path, progress_callback)
128129
yield()
129130
n_done += 1
130131
percentage = round(Int, 100*(n_done/n_total))
131-
progress_callback("Downloading cache files...", percentage)
132+
if percentage < 100
133+
progress_callback("Downloading cache files...", percentage)
134+
end
132135
end
133136
end
134137
end
135-
progress_callback("All cache files downloaded.", 100)
138+
took = round(time() - t0, sigdigits = 2)
139+
progress_callback("All cache files downloaded (took $(took)s).", 100)
136140
end
137141
end
138142
end
@@ -279,9 +283,12 @@ function load_project_packages_into_store!(ssi::SymbolServerInstance, environmen
279283
manifest === nothing && return
280284
uuids = values(deps(project))
281285
num_uuids = length(values(deps(project)))
286+
t0 = time()
282287
for (i, uuid) in enumerate(uuids)
283288
load_package_from_cache_into_store!(ssi, uuid isa UUID ? uuid : UUID(uuid), environment_path, manifest, store, progress_callback, round(Int, 100 * (i - 1) / num_uuids))
284289
end
290+
took = round(time() - t0, sigdigits = 2)
291+
progress_callback("Loaded all packages into cache in $(took)s", 100)
285292
end
286293

287294
"""
@@ -300,6 +307,7 @@ function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UU
300307
# further existence checks needed?
301308
cache_path = joinpath(ssi.store_path, get_cache_path(manifest, uuid)...)
302309
if isfile(cache_path)
310+
t0 = time()
303311
progress_callback("Loading $pe_name from cache...", percentage)
304312
try
305313
package_data = open(cache_path) do io
@@ -315,6 +323,13 @@ function load_package_from_cache_into_store!(ssi::SymbolServerInstance, uuid::UU
315323
end
316324

317325
store[Symbol(pe_name)] = package_data.val
326+
took = round(time() - t0, sigdigits = 2)
327+
msg = "Done loading $pe_name from cache..."
328+
if took > 0.01
329+
msg *= " (took $(took)s)"
330+
end
331+
progress_callback(msg, percentage)
332+
t0 = time()
318333
for dep in deps(pe)
319334
load_package_from_cache_into_store!(ssi, packageuuid(dep), environment_path, manifest, store, progress_callback, percentage)
320335
end

src/symbols.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ struct DataTypeStore <: SymStore
5050
methods::Vector{MethodStore}
5151
doc::String
5252
exported::Bool
53-
function DataTypeStore(names, super, parameters, types, fieldnames, methods, doc, exported)
54-
if length(types) < length(fieldnames)
55-
error("Only $(length(types)) types were loaded for $(length(fieldnames)) fieldnames. SymbolServer may recalculate the cache.")
53+
function DataTypeStore(names, super, parameters, fieldtypes, fieldnames, methods, doc, exported)
54+
if length(fieldtypes) < length(fieldnames)
55+
append!(fieldtypes, [Any for _ in 1:(length(fieldnames)-length(fieldtypes))])
5656
end
57-
new(names, super, parameters, types, fieldnames, methods, doc, exported)
57+
new(names, super, parameters, fieldtypes, fieldnames, methods, doc, exported)
5858
end
5959
end
6060

0 commit comments

Comments
 (0)