Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lua/wincent/commandt/lib/vendor
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,29 @@ exit
vagrant halt
vagrant destroy
```

# Profiling

## On macOS

I didn't have any success the last time I tried these, but including the notes here for reference anyway:

```
xctrace record --launch bin/benchmarks/matcher.lua --template "CPU Profiler" # Instruments.app hangs while opening this.
xctrace record --launch bin/benchmarks/matcher.lua --template "Time Profiler" # Instruments.app hangs while opening this.
xctrace record --launch bin/benchmarks/matcher.lua --template "Activity Monitor" # Produces not very useful system-wide stats.
xctrace record --launch bin/benchmarks/matcher.lua --template "Allocations" # Completes with an error and produces no useful info.
```

In theory, should be able to run the following, but it hangs:

```
xctrace symbolicate --input some.trace --dsym lua/wincent/commandt/lib/commandt.so.dSYM
```

I also attempted using the `/usr/bin/sample` tool, which produces results, albeit not particularly easy ones to parse:

```
(sleep 1 && luajit bin/benchmarks/matcher.lua) &
sample -wait luajit -mayDie
```
18 changes: 18 additions & 0 deletions bin/vendor-mimalloc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
# SPDX-FileCopyrightText: Copyright 2022-present Greg Hurrell and contributors.
# SPDX-License-Identifier: BSD-2-Clause

set -ex

REPO_ROOT="${BASH_SOURCE%/*}/.."
cd "$REPO_ROOT"

BASE=lua/wincent/commandt/lib/vendor/github/microsoft
mkdir -p "$BASE"
cd "$BASE"
rm -rf mimalloc*
wget https://github.com/microsoft/mimalloc/archive/refs/tags/v2.1.7.tar.gz -O mimalloc.tar.gz
tar xzf mimalloc.tar.gz
rm mimalloc.tar.gz
ln -s mimalloc-2.1.7 mimalloc
6 changes: 5 additions & 1 deletion data/wincent/commandt/benchmark/configs/scanner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ return {
assert(_G.vim == nil)
_G.vim = {
api = {
nvim_buf_is_valid = function()
return true
end,
nvim_list_bufs = function()
local handles = {}
for i = 1, #names do
Expand Down Expand Up @@ -237,7 +240,8 @@ return {
{
name = 'git',
source = function()
local command = require('wincent.commandt').default_options().finders.git.command('', {})
local options = require('wincent.commandt').default_options()
local command = options.finders.git.command('', options)
local scanner = require('wincent.commandt.private.scanners.command').scanner
return {
scanner = function()
Expand Down
1 change: 1 addition & 0 deletions lua/wincent/commandt/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.o
*.so
*.so.dSYM
20 changes: 18 additions & 2 deletions lua/wincent/commandt/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ LIBS = -lpthread
HDRS = $(wildcard *.h)
SRCS = $(wildcard *.c)

MIMALLOC_BASE = vendor/github/microsoft/mimalloc
MIMALLOC_INCLUDE = $(MIMALLOC_BASE)/include
MIMALLOC_SRC = $(MIMALLOC_BASE)/src
MIMALLOC_OVERRIDE = mimalloc-override.o

ifdef USE_MIMALLOC
MIMALLOC_HDRS = $(wildcard $(MIMALLOC_INCLUDE)/*.h)
MIMALLOC_SRCS = $(wildcard $(MIMALLOC_SRC)/*.c)
MALLOC_OBJ = $(MIMALLOC_OVERRIDE)
endif

all: commandt.$(DLLEXT)

# Rebuild whenever CCFLAGS changes (eg. when DEBUG passed or not passed).
Expand All @@ -56,12 +67,17 @@ define DEPEND_ON
@if [[ `cat .make/$1 2>&1` != '$($1)' ]]; then echo $($1) > .make/$1; fi
endef
$(eval $(call DEPEND_ON,CCFLAGS))
$(eval $(call DEPEND_ON,USE_MIMALLOC))

$(MIMALLOC_OVERRIDE): $(MIMALLOC_HDRS) $(MIMALLOC_SRCS) Makefile .make/CCFLAGS
$(CC) $(CCFLAGS) -I$(MIMALLOC_INCLUDE) -c -fPIC -o $(MIMALLOC_OVERRIDE) $(MIMALLOC_SRC)/static.c

commandt.$(DLLEXT): $(HDRS) $(SRCS) Makefile .make/CCFLAGS
$(CC) $(CCFLAGS) -shared -fPIC -o commandt.$(DLLEXT) $(SRCS)
commandt.$(DLLEXT): $(HDRS) $(SRCS) $(MIMALLOC_OVERRIDE) Makefile .make/CCFLAGS .make/USE_MIMALLOC
$(CC) $(CCFLAGS) -shared -fPIC -o commandt.$(DLLEXT) $(MALLOC_OBJ) $(SRCS)

.PHONY: clean
clean:
rm -f *.$(DLLEXT)
rm -f *.o
rm -f .make/*
rm -rf *.so.dSYM
4 changes: 4 additions & 0 deletions lua/wincent/commandt/lib/vendor/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# Stop vendored files from being checked.
DisableFormat: true
SortIncludes: Never
1 change: 1 addition & 0 deletions lua/wincent/commandt/lib/vendor/github/microsoft/mimalloc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# default behavior is to always use unix style line endings
* text eol=lf
*.png binary
*.pdn binary
*.jpg binary
*.sln binary
*.suo binary
*.vcproj binary
*.patch binary
*.dll binary
*.lib binary
*.exe binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ide/vs20??/*.db
ide/vs20??/*.opendb
ide/vs20??/*.user
ide/vs20??/*.vcxproj.filters
ide/vs20??/.vs
ide/vs20??/VTune*
out/
docs/
*.zip
*.tar
*.gz
Loading