[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gbs3 not exiting


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,

--
Benoît Minisini.


Follow-Ups:
Re: gbs3 not exitingBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: gbs3 not exitingBrian G <brian@xxxxxxxxxxxxxxxx>
References:
gbs3 not exitingBruce Steers <bsteers4@xxxxxxxxx>
Re: gbs3 not exitingBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: gbs3 not exitingBruce Steers <bsteers4@xxxxxxxxx>
Re: gbs3 not exitingBrian G <brian@xxxxxxxxxxxxxxxx>
Re: gbs3 not exitingBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: gbs3 not exitingBruce Steers <bsteers4@xxxxxxxxx>
Re: gbs3 not exitingBrian G <brian@xxxxxxxxxxxxxxxx>