Remove PII reaction due to performance issue
What does this MR do and why?
I have re-enabled CORS and PII reaction logic and run another round of profiling
Method: POST, Path: /v2/completions, Duration: 131.76418702100636, Status: 200
_ ._ __/__ _ _ _ _ _/_ Recorded: 02:54:10 Samples: 135092
/_//_/// /_\ / //_// / //_'/ // Duration: 52.850 CPU time: 45.352
/ _/ v4.4.0
Program: codesuggestions
48.677 MainThread <thread>:274910217408
`- 48.664 <module> <string>:1
`- 48.664 main codesuggestions/app.py:25
`- 48.664 run uvicorn/main.py:453
[4422 frames hidden] uvicorn, asyncio, starlette, fastapi,...
44.161 AuthenticationMiddleware.__call__ starlette/middleware/authentication.py:29
| 37.866 _patched dependency_injector/wiring.py:992
| `- 37.847 completions codesuggestions/api/v2/endpoints/suggestions.py:47
| `- 37.838 wrap codesuggestions/api/timing.py:8
| `- 37.832 get_suggestions codesuggestions/api/v2/endpoints/suggestions.py:66
| `- 37.831 CodeSuggestionsUseCaseV2.__call__ codesuggestions/suggestions/base.py:140
| |- 33.725 CodeSuggestionsUseCaseV2.redact_pii codesuggestions/suggestions/base.py:93
| | `- 33.717 CodeSuggestionsUseCaseV2._detect_pii codesuggestions/suggestions/base.py:63
| | |- 29.919 DetectorBasicAuthSecrets.detect_all codesuggestions/suggestions/detectors.py:185
| | | `- 29.918 _run_detect_secrets_plugins codesuggestions/suggestions/detectors.py:250
| | | |- 27.145 _process_line_based_plugins detect_secrets/core/scan.py:305
| | | | [6514 frames hidden] detect_secrets, importlib, re, sre_co...
| | | |- 2.065 _GeneratorContextManager.__enter__ contextlib.py:114
| | | | [200 frames hidden] contextlib, detect_secrets, importlib...
| | | `- 0.698 _GeneratorContextManager.__exit__ contextlib.py:123
| | | [124 frames hidden] contextlib, detect_secrets, copy, <bu...
| | `- 3.738 DetectorTokenSecrets.detect_all codesuggestions/suggestions/detectors.py:221
| | `- 3.736 _run_detect_secrets_plugins codesuggestions/suggestions/detectors.py:250
| | |- 1.923 _GeneratorContextManager.__enter__ contextlib.py:114
| | | [118 frames hidden] contextlib, detect_secrets, importlib...
| | |- 1.090 _process_line_based_plugins detect_secrets/core/scan.py:305
| | | [128 frames hidden] detect_secrets, <built-in>, inspect, ...
| | `- 0.715 _GeneratorContextManager.__exit__ contextlib.py:123
| | [124 frames hidden] contextlib, detect_secrets, copy, <bu...
| `- 4.009 Codegen.__call__ codesuggestions/models/codegen.py:72
| `- 3.674 InferenceServerClient.infer tritonclient/grpc/__init__.py:1312
| [116 frames hidden] tritonclient, grpc, <built-in>, threa...
`- 5.367 AuthBackend.authenticate codesuggestions/api/middleware.py:136
`- 5.335 wrap codesuggestions/api/timing.py:8
`- 5.331 AuthBackend.authenticate_with_token codesuggestions/api/middleware.py:158
`- 5.324 GitLabAuthProvider.authenticate codesuggestions/auth/providers.py:73
`- 4.938 GitLabAuthProvider._request_code_suggestions_allowed codesuggestions/auth/providers.py:37
`- 4.826 get requests/api.py:62
[2868 frames hidden] requests, urllib3, http, socket, <bui...
3.785 CustomHeaderMiddleware.__call__ starlette/middleware/base.py:22
`- 0.621 CustomHeaderMiddleware.dispatch codesuggestions/api/middleware.py:54
Few observations:
- PII Reaction is taking most of the time
- CORS middleware does not affect the total time
Given the above, I propose we remove the PII Reaction but re-enable CORS to unblock the release of Web IDE with Code Suggestions release.
Edited by Tan Le