Indent Performance: string/comment lookups
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 28/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- elixir, vim
- Área
- performance, tooling
Línea de trabajo
Comienza en elixir#indent#indent() y elixir#indent#handle_inside_nested_construct(), y luego crea perfiles de las llamadas repetidas a 77_is_string_or_comment() y elixir#indent#searchpair_back_skip(). Compara el comportamiento de la indentación antes y después de cualquier preprocesamiento o reducción de búsquedas; el trabajo estará terminado cuando se conserve la indentación correcta y se reduzca el coste de las búsquedas repetidas de cadenas/comentarios.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Given the following file:
defmodule Http do
defmacro __using__(_) do
quote do
use HTTPoison.Base
def get(url, headers \\ [], options \\ []) do
response(:get, url, "", headers, options)
end
def delete(url, headers \\ [], options \\ []) do
response(:delete, url, "", headers, options)
end
def post(url, body, headers \\ [], options \\ []) do
response(:post, url, body, headers, options)
end
def patch(url, body, headers \\ [], options \\ []) do
response(:patch, url, body, headers, options)
end
def response(method, url, body, headers \\ [], options \\ []) do
url = options.base_url <> url
log(method, :start, url, options)
start_time = now()
response = request(method, url, body, headers, options)
case response do
{:ok, response} ->
log(method, :finish, url, options, response, start_time)
{:error, response} ->
log(method, :error, url, options, response, start_time)
end
response
end
def process_request_options(%_{} = options) do
options
|> Map.from_struct()
|> Enum.into([])
|> process_request_options()
end
def process_request_options(options) do
[
timeout: 10_000,
recv_timeout: 15_000,
hackney: [pool: :http_default_pool]
]
|> Keyword.merge(options)
end
def process_request_body(body) when is_map(body), do: Poison.encode!(body)
def process_request_body(body) when is_binary(body), do: body
def process_response_body(body) do
case Poison.Parser.parse(body) do
{:ok, parsed_body} -> parsed_body
{:error, _} -> body
end
end
def process_request_headers(headers) do
headers
end
defp now(), do: DateTime.utc_now() |> DateTime.to_unix(:millisecond)
defp log(request_method, at, path, options, response \\ nil, started_at \\ nil) do
data = %{
api_request: true,
at: at,
host: options.base_url,
request_id: options.request_id,
url: path,
method: request_method,
path: options.generic_path,
elapsed: started_at && now() - started_at
# status: response && response.status_code,
# reason: response && response.reason
}
# remove keys with falsy values
data = for {key, value} <- data, value, into: %{}, do: {key, value}
case response do
nil -> Plexy.Logger.debug(data)
%HTTPoison.Response{} -> Plexy.Logger.debug(data)
%HTTPoison.Error{} = error -> Plexy.Logger.error(data)
end
end
end
end
end
We get the following profiler output:
FUNCTIONS SORTED ON SELF TIME
count total (s) self (s) function
9466 10.457848 <SNR>77_is_string_or_comment()
312 11.036247 1.915420 elixir#indent#handle_inside_nested_construct()
8828 9.363995 0.120360 elixir#indent#searchpair_back_skip()
1522 1.123686 0.106535 <SNR>77_ends_with()
384 13.163921 0.071142 elixir#indent#indent()
52 0.205268 0.054884 elixir#indent#handle_inside_generic_block()
382 0.210430 0.053353 elixir#indent#handle_starts_with_end()
2542 0.096197 0.048705 <SNR>77_starts_with()
398 61.177775 0.024607 <SNR>77_get_base_indent()
326 0.164678 0.021031 elixir#indent#handle_starts_with_close_bracket()
4644 0.017567 <SNR>77_debug()
312 0.018112 0.006850 elixir#indent#handle_starts_with_binary_operator()
334 0.020190 0.006785 elixir#indent#handle_starts_with_pipe()
358 0.013070 0.005970 elixir#indent#handle_starts_with_mid_or_end_block_keyword()
358 0.087979 0.005809 elixir#indent#handle_following_trailing_do()
334 0.037895 0.003777 elixir#indent#handle_following_trailing_binary_operator()
230 0.003508 elixir#indent#handle_starts_with_comment()
8 0.003288 <SNR>77_find_last_pos()
384 13.166979 0.003058 elixir#indent()
1274 0.002925 <SNR>77_keyword()
The clear culprit is delegating to the syntax engine over and over. One thought - can we filter out all of the strings in a preprocessing step perhaps? That would surely be cheaper than checking them over and over
- Lenguaje dominante
- Ruby
- Estrellas
- 1.3k
- Forks
- 154
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de elixir-editors/vim-elixir
-
bug syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
elixir-editors/vim-elixir#574 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
elixir-editors/vim-elixir#569 · 3 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
elixir-editors/vim-elixir#567 · 4 comentarios · 1 reacción ·
-
Contribute runtime files to vimAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
elixir-editors/vim-elixir#565 · 2 comentarios · 2 reacciones ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 28/100
elixir-editors/vim-elixir#564 · 1 comentario ·
Todos los issues de elixir-editors/vim-elixir
Issues similares
-
bug: "Conversation information" accordion renders blank with 0px height when conversation has no attributesPosiblemente ocupada @gihovani la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
sclorg/s2i-ruby-container#660 · 1 comentario ·
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
bridgetownrb/bridgetown#1130 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
hlascelles/que-scheduler#611 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
rapid7/metasploit-framework#22008 ·
Los mantenedores suelen responder en 2 días