[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gbs3 not exiting
[Thread Prev] | [Thread Next]
- Subject: Re: gbs3 not exiting
- From: Brian G <brian@xxxxxxxxxxxxxxxx>
- Date: Sun, 15 Nov 2026 01:29:52 -0800
- To: user@xxxxxxxxxxxxxxxxxxxxxx, Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Libtcc is not tcc, I noticed the h file already was setup for tcc. Libtcc does not fork anything. I have been testing it quite a lot. It did produce bad code to start. It is now a separate c file from jit.c called jit_tcc.c provides the interface to the libtcc.
Some small work was done on how code was structured as well.This patch was also required to get it working to start and probably should go into the existing repository it caused my code to abend: 3acaf3472 ("Compile correctly functions that use indirect GOTO"). It changed JIT_get_code_size() in main/lib/jit/jit.c to always return size - func->n_label - 1. Most functions have no labels, so this cuts off their last instruction and the translator aborts. gcc fails exactly the same way. Upstream master doesn't have a fix yet.
I changed it to subtract only when there are labels: if (func->n_label) size -= func->n_label + 1; return size;I can also create a new project in my gitlab projects called gambas_libtcc for you to review/clone for your own testing. I have been doing testing with everything I have, making it all fast, or just parts etc... I finally managed to get it all to work in harmony with jit.
I was able to run the benchmarks as well.I also have a patch file that you can apply to a clone of your own project. You do need to build and install a copy of the libtcc on your system if it is the static type library in your distributions repository.
I have a script for building that as well. Anyway, it really solves my slow initial start issues by a good margin.On November 14, 2026 11:43:43 PM PST, "Benoît Minisini" <benoit.minisini@xxxxxxxxxxxxxxxx> wrote:
Le 15/11/2026 à 01:28, Brian G a écrit :
I have been working on adding support for the libtcc into the
jit module of gambas it improves the compile time, quite a lot,
but long running compute tasks are a little slower. I configured
it to use libtcc if found else it will fall back to gcc. I can
submit a merge request if anyone is interested. , I built libtcc
as a relocatable lib, can be loaded at runtime. but the debian
libtcc is a static, and must be linked at build time to the gbx3
module..... Also I found a bug in the latest code updates in the
JIT_get_code_size() for functions without labels, causes
segfault I also have a patch for that. Here is the comparison
gsh (Gambas shell, 3 JIT modules: gb, gb.highlight,
westwood.sharedmem) startup time of 'gsh -S -c "echo hi"',
median of 7 runs (3 for gcc cold): Mode Startup Range
Interpreter (no JIT) 0.057 s 0.053 - 0.067 gcc -O2, cold (no
cache) 19.5 s 19.46 - 19.54 gcc -O2, warm cache 0.197 s 0.167
- 0.205 libtcc, cold (no cache) 0.295 s 0.284 - 0.303 libtcc,
warm cache 0.102 s 0.102 s libtcc, in memory (GB_JIT_CACHE=0)
0.280 s 0.271 - 0.288 A cold start is ~66x faster with libtcc.
Warm, libtcc is ~2x faster than gcc, because the per-process
pointer table is rebuilt in-process instead of forking gcc.
Benchmarks (main/benchmark), run time in seconds, output
compared with the interpreter's: Benchmark Interp gcc -O2
libtcc gcc output libtcc output mandelbrot 2.05 0.15 0.39
last-digit drift same nbody 3.60 0.40 0.88 last-digit drift
same polynom 6.26 0.82 2.14 same same primes 2.33 0.79 1.11 same
same sort 2.70 0.40 0.79 same same string1 1.75 1.78 1.55 same
same string2 2.13 1.52 2.20 same same btree 3.78 3.67 4.60 same
same gcc's last-digit drift comes from -march=native contracting
multiply-adds into FMA instructions. libtcc code runs 1.4-2.7x
slower than gcc -O2 on compute-bound code, still much faster
than the interpreter. libtcc wins on startup and compile time;
gcc wins on raw speed of long- running code. GB_JIT_CC=gcc
selects gcc when that matters more.
Interesting. The last time I used tcc (by just using GB_JIT_CC=tcc), it sometimes compiled not workable code... Regards,
Attachment:
OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature
| gbs3 not exiting | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: gbs3 not exiting | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
| Re: gbs3 not exiting | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: gbs3 not exiting | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Re: gbs3 not exiting | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |
| Re: gbs3 not exiting | Bruce Steers <bsteers4@xxxxxxxxx> |
| Re: gbs3 not exiting | Brian G <brian@xxxxxxxxxxxxxxxx> |
| Re: gbs3 not exiting | Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx> |