3

I use company for completion, and it's fast and efficient in OCaml, Tuareg, and Merlin.

However, it is very slow in my C project. For example, it takes more than 10 seconds when it suggests completions for structure, during which I cannot do anything in Emacs.

An example of structure I use in my project :

typedef struct {
  char name[D_NAME_MAXLEN];      /**< name of the disk */
  uint32_t size;   /**< size of the disk */
  uint32_t npart;   /**< number of partitions */
  uint32_t part[D_PARTMAX];    /**< parition sizes */
} d_stat;

Then I have a d_stat pointer caled d_stat and after typing typing dstat-> it stops for a looong long time, even sometimes it bugs...

Same thing with the macros, I have some macros :

OPT_SIZE
OPT_LONG_SIZE
OPT_FORCE
OPT_LONG_FORCE
OPT_NAME
OPT_LONG_NAME
etc...

And when I type OPT_ it stops like above.

How can I speed up company completion when it gets this slow? Right now, it is not usable.

I'm using (global-company-mode) in my init file.

tree of the project looks like :

syscp
├── bin
│   ├── disk.tfs
│   ├── libll.so
│   ├── libtfs.so
│   ├── tfs_analyze
│   ├── tfs_create
│   ├── tfs_format
│   └── tfs_partition
├── dev
│   └── device.tfs
├── disk.tfs
├── doc
│   └── config
├── ld
├── lib
│   ├── block0.h
│   ├── block.c
│   ├── block.h
│   ├── error.c
│   ├── error.h
│   ├── ll.c
│   ├── ll.h
│   ├── tfs.c
│   ├── tfs.h
│   ├── utils.c
│   └── utils.h
├── Makefile
├── obj
│   ├── block.o
│   ├── error.o
│   ├── libblock.o
│   ├── liberror.o
│   ├── libll.o
│   ├── libtfs.o
│   ├── ll.o
│   └── utils.o
├── README
├── setup.sh
└── src
    ├── default.h
    ├── tfs_analyze.c
    ├── tfs_create.c
    ├── tfs_format.c
    └── tfs_partition.c

7 directories, 39 files
7
  • I have added these informations in the post. Commented Dec 25, 2015 at 20:08
  • Is this a big project?
    – Dmitry
    Commented Dec 26, 2015 at 14:31
  • For me yes since I'm a student ! But it's just a school project... It's a library for a filesystem encoded in a file (inception !) with the ordinary tools to manipulate the filesystem like mkdir, etc... I put the tree in the post. Commented Dec 27, 2015 at 9:29
  • Hmm, it shouldn't be too slow at this size. After all, completion is much faster than you describe inside the Emacs C sources. If you can send me the project itself (see the email in any of my GitHub repos), I will take a look.
    – Dmitry
    Commented Dec 29, 2015 at 0:18
  • On the other hand, company-clang (you do use Clang, right? see by typing M-x company-diag) is inherently only suitable for small-ish projects, because it calls Clang for every completion, and each time it scans all dependencies of the current file. You can use some third-party daemon-based backend for improved performance, such as irony-mode or rtags.
    – Dmitry
    Commented Dec 29, 2015 at 0:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.