Skip to content

Commit d344838

Browse files
Kobayashisloorush
Kobayashi
authored andcommitted
Improve performance of NormalizedFilePath (haskell#3067)
* upgrade lsp * modify default benchmark config * upgrade lsp * use lsp master * temp: compare benchmark with previous commit * use text in NormalizedFilePath * upgrade to lsp master * fix stack config * remove obsolete dir form ghcide.cabal * run pre-commit without args * Revert "run pre-commit without args" This reverts commit 1c2a11d. * remove unnecessary tests
1 parent 83da34d commit d344838

File tree

9 files changed

+92
-93
lines changed

9 files changed

+92
-93
lines changed

bench/config.yaml

+56-54
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ versions:
7676

7777

7878
# - 1.8.0.0
79-
# - upstream: origin/master
79+
- upstream: origin/master
8080
# - HEAD~1
8181
- HEAD
8282

@@ -95,26 +95,28 @@ configurations:
9595
# The implicitly included plugins are:
9696
# - ghcide-core
9797
# - ghcide-hover-and-symbols
98-
- None: []
99-
- Core:
100-
- callHierarchy
101-
- codeRange
102-
- eval
103-
- ghcide-code-actions-bindings
104-
- ghcide-code-actions-fill-holes
105-
- ghcide-code-actions-imports-exports
106-
- ghcide-code-actions-type-signatures
107-
- ghcide-completions
108-
- ghcide-type-lenses
109-
- pragmas
110-
- Ghcide:
111-
- ghcide-completions
112-
- ghcide-type-lenses
113-
- Refactor:
114-
- ghcide-code-actions-bindings
115-
- ghcide-code-actions-fill-holes
116-
- ghcide-code-actions-imports-exports
117-
- ghcide-code-actions-type-signatures
98+
99+
# Uncomment below sections if needed
100+
# - None: []
101+
# - Core:
102+
# - callHierarchy
103+
# - codeRange
104+
# - eval
105+
# - ghcide-code-actions-bindings
106+
# - ghcide-code-actions-fill-holes
107+
# - ghcide-code-actions-imports-exports
108+
# - ghcide-code-actions-type-signatures
109+
# - ghcide-completions
110+
# - ghcide-type-lenses
111+
# - pragmas
112+
# - Ghcide:
113+
# - ghcide-completions
114+
# - ghcide-type-lenses
115+
# - Refactor:
116+
# - ghcide-code-actions-bindings
117+
# - ghcide-code-actions-fill-holes
118+
# - ghcide-code-actions-imports-exports
119+
# - ghcide-code-actions-type-signatures
118120
- All:
119121
- alternateNumberFormat
120122
- callHierarchy
@@ -141,36 +143,36 @@ configurations:
141143
- refineImports
142144
- rename
143145
- stylish-haskell
144-
- alternateNumberFormat
145-
# - brittany
146-
- callHierarchy
147-
- changeTypeSignature
148-
- class
149-
- codeRange
150-
- eval
151-
- explicitFixity
152-
# - floskell
153-
# - fourmolu
154-
- gadt
155-
- ghcide-code-actions-bindings
156-
- ghcide-code-actions-fill-holes
157-
- ghcide-code-actions-imports-exports
158-
- ghcide-code-actions-type-signatures
159-
- ghcide-completions
160-
# - ghcide-core # implicitly included in all configurations
161-
# - ghcide-hover-and-symbols # implicitly included in all configurations
162-
- ghcide-type-lenses
163-
- haddockComments
164-
- hlint
165-
- importLens
166-
- moduleName
167-
# - ormolu
168-
- pragmas
169-
- qualifyImportedNames
170-
- refineImports
171-
- rename
172-
- retrie
173-
- splice
174-
- stan
175-
# - stylish-haskell
176-
- tactics
146+
# - alternateNumberFormat
147+
# # - brittany
148+
# - callHierarchy
149+
# - changeTypeSignature
150+
# - class
151+
# - codeRange
152+
# - eval
153+
# - explicitFixity
154+
# # - floskell
155+
# # - fourmolu
156+
# - gadt
157+
# - ghcide-code-actions-bindings
158+
# - ghcide-code-actions-fill-holes
159+
# - ghcide-code-actions-imports-exports
160+
# - ghcide-code-actions-type-signatures
161+
# - ghcide-completions
162+
# # - ghcide-core # implicitly included in all configurations
163+
# # - ghcide-hover-and-symbols # implicitly included in all configurations
164+
# - ghcide-type-lenses
165+
# - haddockComments
166+
# - hlint
167+
# - importLens
168+
# - moduleName
169+
# # - ormolu
170+
# - pragmas
171+
# - qualifyImportedNames
172+
# - refineImports
173+
# - rename
174+
# - retrie
175+
# - splice
176+
# - stan
177+
# # - stylish-haskell
178+
# - tactics

cabal.project

+14-3
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,24 @@ source-repository-package
8181
location: https://github.com/wz1000/hie-bios
8282
tag: aa73d3d2eb89df0003d2468a105e326d71b62cc7
8383

84-
-- Needed for ghcide-bench until a new release of lsp-test is out
84+
-- Remove me when a new version of lsp is released
85+
source-repository-package
86+
type:git
87+
location: https://github.com/haskell/lsp
88+
subdir: lsp
89+
tag: b0f8596887088b8ab65fc1015c773f45b47234ae
90+
91+
source-repository-package
92+
type:git
93+
location: https://github.com/haskell/lsp
94+
subdir: lsp-types
95+
tag: b0f8596887088b8ab65fc1015c773f45b47234ae
96+
8597
source-repository-package
8698
type:git
8799
location: https://github.com/haskell/lsp
88100
subdir: lsp-test
89-
tag: c95eb06c70c35f1e13c37ed11a7d9e5b36bfa2e8
90-
-- https://github.com/haskell/lsp/pull/450
101+
tag: b0f8596887088b8ab65fc1015c773f45b47234ae
91102

92103
allow-newer:
93104
-- ghc-9.4

ghcide/ghcide.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ test-suite ghcide-tests
378378
record-hasfield
379379
if impl(ghc < 9.3)
380380
build-depends: ghc-typelits-knownnat
381-
hs-source-dirs: test/cabal test/exe test/src bench/lib
381+
hs-source-dirs: test/cabal test/exe test/src
382382
ghc-options: -threaded -Wall -Wno-name-shadowing -O0 -Wno-unticked-promoted-constructors
383383
main-is: Main.hs
384384
other-modules:

ghcide/src/Development/IDE/Types/Location.hs

+1-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ toNormalizedFilePath' "" = emptyFilePath
5050
toNormalizedFilePath' fp = LSP.toNormalizedFilePath fp
5151

5252
emptyFilePath :: LSP.NormalizedFilePath
53-
#if MIN_VERSION_lsp_types(1,3,0)
54-
emptyFilePath = LSP.normalizedFilePath emptyPathUri ""
55-
#else
56-
emptyFilePath = LSP.NormalizedFilePath emptyPathUri ""
57-
#endif
53+
emptyFilePath = LSP.emptyNormalizedFilePath
5854

5955
-- | We use an empty string as a filepath when we don’t have a file.
6056
-- However, haskell-lsp doesn’t support that in uriToFilePath and given

hls-plugin-api/src/Ide/PluginUtils.hs

+1-4
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ fullRange s = Range startPos endPos
218218
lastLine = fromIntegral $ length $ T.lines s
219219

220220
subRange :: Range -> Range -> Bool
221-
subRange smallRange range = _start smallRange >= _start range && _end smallRange <= _end range
222-
223-
positionInRange :: Position -> Range -> Bool
224-
positionInRange p (Range sp ep) = sp <= p && p < ep -- Range's end position is exclusive, see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range
221+
subRange = isSubrangeOf
225222

226223
-- ---------------------------------------------------------------------
227224

hls-plugin-api/test/Ide/PluginUtilsTest.hs

+1-17
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,5 @@ import Test.Tasty.HUnit
99

1010
tests :: TestTree
1111
tests = testGroup "PluginUtils"
12-
[ positionInRangeTest
13-
]
14-
15-
positionInRangeTest :: TestTree
16-
positionInRangeTest = testGroup "positionInRange"
17-
[ testCase "single line, after the end" $
18-
positionInRange (Position 1 10) (Range (Position 1 1) (Position 1 3)) @?= False
19-
, testCase "single line, before the begining" $
20-
positionInRange (Position 1 0) (Range (Position 1 1) (Position 1 6)) @?= False
21-
, testCase "single line, in range" $
22-
positionInRange (Position 1 5) (Range (Position 1 1) (Position 1 6)) @?= True
23-
, testCase "single line, at the end" $
24-
positionInRange (Position 1 5) (Range (Position 1 1) (Position 1 5)) @?= False
25-
, testCase "multiline, in range" $
26-
positionInRange (Position 3 5) (Range (Position 1 1) (Position 5 6)) @?= True
27-
, testCase "multiline, out of range" $
28-
positionInRange (Position 3 5) (Range (Position 3 6) (Position 4 10)) @?= False
12+
[
2913
]

stack-lts16.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ extra-deps:
8787
- constraints-extras-0.3.0.2@sha256:013b8d0392582c6ca068e226718a4fe8be8e22321cc0634f6115505bf377ad26,1853
8888
- some-1.0.1@sha256:26e5bab7276f48b25ea8660d3fd1166c0f20fd497dac879a40f408e23211f93e,2055
8989
- unliftio-core-0.2.0.1@sha256:9b3e44ea9aacacbfc35b3b54015af450091916ac3618a41868ebf6546977659a,1082
90-
- lsp-1.5.0.0
91-
- lsp-types-1.5.0.0
92-
- lsp-test-0.14.0.3
90+
- git: [email protected]:haskell/lsp
91+
commit: b0f8596887088b8ab65fc1015c773f45b47234ae
92+
subdirs:
93+
- lsp
94+
- lsp-types
95+
- lsp-test
9396
- stm-containers-1.1.0.4
9497
- stm-hamt-1.2.0.6@sha256:fba86ccb4b45c5706c19b0e1315ba63dcac3b5d71de945ec001ba921fae80061,3972
9598
- primitive-extras-0.10.1

stack-lts19.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ extra-deps:
5555
- refinery-0.4.0.0@sha256:fe3a43add8ff1db5cfffee7e7694c86128b1dfe62c541f26e25a8eadf9585610,1663
5656
- retrie-1.1.0.0
5757
- stylish-haskell-0.14.2.0@sha256:fffe1c13ad4c2678cf28a7470cac5d3bf20c71c36f09969e3e5f186787cceb7c,4321
58-
- lsp-1.5.0.0
59-
- lsp-types-1.5.0.0
60-
- lsp-test-0.14.0.3
58+
- git: [email protected]:haskell/lsp
59+
commit: b0f8596887088b8ab65fc1015c773f45b47234ae
60+
subdirs:
61+
- lsp
62+
- lsp-types
63+
- lsp-test
6164
- co-log-core-0.3.1.0
6265

6366
configure-options:

stack.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ extra-deps:
4141
- hiedb-0.4.1.0@sha256:fb20c657d9ecc91701b00dffcf4bbd77cb83720a1f9d867badd77ea227973135,2875
4242
- implicit-hie-0.1.2.7@sha256:82bbbb1a8c05f99c8af3c16ac53e80c8648d8bf047b25ed5ce45a135bd736907,3122
4343
- implicit-hie-cradle-0.5.0.0@sha256:4276f60f3a59bc22df03fd918f73bca9f777de9568f85e3a8be8bd7566234a59,2368
44-
- lsp-1.5.0.0
45-
- lsp-test-0.14.0.3
46-
- lsp-types-1.5.0.0
44+
- git: [email protected]:haskell/lsp
45+
commit: b0f8596887088b8ab65fc1015c773f45b47234ae
46+
subdirs:
47+
- lsp
48+
- lsp-types
49+
- lsp-test
4750
- monad-dijkstra-0.1.1.3@sha256:d2fc098d7c122555e726830a12ae0423ac187f89de9228f32e56e2f6fc2238e1,1900
4851
- retrie-1.2.0.1
4952
- co-log-core-0.3.1.0

0 commit comments

Comments
 (0)