Performance improvements in Ring 1.21 (GitHub) - 2024.07.10

173 views
Skip to first unread message

Mahmoud Fayed

unread,
Jul 10, 2024, 3:53:35 AM (12 days ago) Jul 10
to The Ring Programming Language
Hello

This is a report about some of the performance improvements in Ring 1.21 (GitHub) - 2024.07.10

In this release a lot of improvements are done at different levels in the Ring VM (Faster Strings when using small strings, Better Byte Code representation, Faster Functions Call, Avoiding Eval in Setter/Getter/Operator Overloading, etc.)

As a result, the stars3.ring example now works at over 4000 FPS in Ring 1.21 on my machine (instead of 2350 FPS in Ring 1.20)
per1.png1

Also, the waving cubes example works at 85 FPS (Using RayLib 2.5) and Ring 1.21 instead of 40 FPS (Using RayLib 2.5) and Ring 1.20

Also, the waving cubes example works at 110 FPS (Using RayLib 4.5 Or RayLib 5.0) and Ring 1.21
Which is faster than the Python 3.11 version which works at 85 FPS using the same RayLib version (RayLib 4.5). 

per2.png1

Greetings,
Mahmoud


Mansour Ayouni

unread,
Jul 10, 2024, 4:04:09 AM (12 days ago) Jul 10
to msfcl...@gmail.com, ring...@googlegroups.com

Hello Mahmoud,

Very interesting and promising! This adds to the reliability of Ring on real world projects.

Thanks a lot.

Mansour


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/6e75f4f1-fda5-4110-ba26-c75cc6f22bd5n%40googlegroups.com.

Mahmoud Fayed

unread,
Jul 10, 2024, 4:05:53 AM (12 days ago) Jul 10
to The Ring Programming Language
Hello Mansour

>> "Very interesting and promising! This adds to the reliability of Ring on real world projects."

You are welcome :D

Greetings,
Mahmoud

Bert Mariani

unread,
Jul 11, 2024, 5:46:41 PM (11 days ago) Jul 11
to The Ring Programming Language
Hello Mahmoud

Trying to update to the latest Ring-21 using command used during the FastPro testing
    Just use
    - cd ring
    - git stash
   -  git pull

cd c:\ring
c:\ring>git stash
fatal: not a git repository (or any of the parent directories): .git


Mahmoud Fayed

unread,
Jul 11, 2024, 5:56:24 PM (11 days ago) Jul 11
to The Ring Programming Language
Hello Bert

Using these Git commands requires a git repository

So, get a clone first

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jul 11, 2024, 8:44:52 PM (11 days ago) Jul 11
to The Ring Programming Language
Hello

Today we did more performance improvements in the next commits

The motivation behind these commits was a message from Ilir (A few weeks ago about a function inside Ring VM called ring_vm_movetoprevscope() and this function if improved, it could speed up the Waving Cubes samples)

Today I discovered a way to avoid this function when calling C functions

Results after this update using Ring 1.21 and RayLib 5.0
When building Ring using MSVC:   120 FPS  
When building Ring using mingw64:  130 FPS

Now compare this to the Python 3.11 (85 FPS) ---> Ring is faster by 40% to 50%
And since Ring doesn't have GIL, we have a threads version of the waving cubes sample
The threads version works at (300 FPS) 

Note: Using RayLib 2.5 you will not notice most of these performance improvements, because this version of RayLib suffer from a performance problem in one of the functions called ColorFromHSV() 

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jul 11, 2024, 8:52:39 PM (11 days ago) Jul 11
to Mahmoud Fayed, The Ring Programming Language
Hello Mahmoud,

Good achievement!

Thanks for your efforts.
Best,
Mansour

Mahmoud Fayed

unread,
Jul 11, 2024, 8:59:50 PM (11 days ago) Jul 11
to The Ring Programming Language
Hello Mansour

You are welcome :D

Greetings,
Mahmoud

Bert Mariani

unread,
Jul 11, 2024, 10:51:59 PM (10 days ago) Jul 11
to The Ring Programming Language
Hello Mahmoud

Ran following commands to get Ring-21
- git clone http://github.com/ring-lang/ring.git
- cd c:/ring/build/buildvc_x64.bat
- ringpm run ringnotepad

I see new sample files ... to confirm the update
I see new Ring Notepad with new icons on the menu bar

Number results on my HP-i5  
  -  ring/samples/UsingRayLib/more/resources/ex5_wavingcubes_threads.ring --- max 57 FPS
  -  ring/samples/UsingRayLib/more/resources/ex5_wavingcubes_withoutthreads.ring --- max 47 FPS

 - ring/samples/UsingOpenGL/stars/stars3.ring 
FPS : 1028

FPS : 975

FPS : 956

FPS : 1028

FPS : 1059

FPS : 903

FPS : 967

FPS : 1071

FPS : 1068

FPS : 1000

Mahmoud Fayed

unread,
Jul 11, 2024, 11:19:06 PM (10 days ago) Jul 11
to The Ring Programming Language
Hello Bert

These numbers are based on RayLib 2.5 (Which is slow)

Once we share RingRayLib that uses RayLib 5.0, You will see the performance improvements in the Waving Cubes sample

With respect to the stars3.ring sample
On my machine 
Using Intel GPU ---> 1460 FPS
Using NVIDIA GEFORCE RTX ---> 4000 FPS 

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jul 11, 2024, 11:43:29 PM (10 days ago) Jul 11
to The Ring Programming Language
Hello Bert

I have already added RingRayLib 5.0 (Under Development) to Ring 1.21 (GitHub)
Also, added the Waving Cubes sample 

To test it and see the performance results on your machine

cd ring
git pull
cd extensions/ringraylib5/src
buildvc_x64
cd ../../libdepwin/raylib5_x64/lib
copy *.dll ..\..\..\..\bin
cd ..\..\..\..\samples\usingraylib5\more
ring ex5_wavingcubes_withoutthreads.ring

Greetings,
Mahmoud

Ilir Liburn

unread,
Jul 12, 2024, 6:01:43 AM (10 days ago) Jul 12
to The Ring Programming Language
Hello Mahmoud,

Yes, during ref() development in Ring2A/B, I noticed lists are returned from the C functions by using temp memory and ref() is a reference to extern list/object, therefore there is no need for the ring_vm_movetoprevscope(). I'm glad this is now recognized and implemented in a new version.

Greetings,
Ilir

Antonio F.S.

unread,
Jul 12, 2024, 7:16:25 AM (10 days ago) Jul 12
to ring...@googlegroups.com

Hello.
What is Ring2 A/B?

Thank you in advance.
Antonio F.S.

---------------------------------------------------------

El 12/7/24 a las 12:01, Ilir Liburn escribió:

Ilir Liburn

unread,
Jul 12, 2024, 7:33:41 AM (10 days ago) Jul 12
to The Ring Programming Language
Hello Antonio,

Ring2 A/B (and now C) are my personal projects where I learned how the Ring VM works. While gaining experience, I managed to accelerate Ring 2A/B 2-3 times (compared to official Ring). As now official Ring is catching up, that means it can be accelerated furthermore (because most of the changes I made are not in the official Ring)!

So, exciting new times are coming for the Ring. One is array support and statically typed variables (so that Ring code can be translated to the C language without handling dynamic types/values where applicable).

Greetings,
Ilir

Antonio F.S.

unread,
Jul 12, 2024, 8:04:35 AM (10 days ago) Jul 12
to ring...@googlegroups.com

Hello Ilir.

Do you mean that your progress with Ring will be incorporated into official Ring?

Thank you for your answer.
Antonio F.S.

----------------------------------------------------------

El 12/7/24 a las 13:33, Ilir Liburn escribió:

Ilir Liburn

unread,
Jul 12, 2024, 8:21:03 AM (10 days ago) Jul 12
to The Ring Programming Language
Hello Antonio,

there is no reason to not be incorporated. We (me and Mahmoud) are in contact since I discovered Ring. As a result, official Ring is now faster than Ring 2A/B when tested on the newer hardware (gaming laptop), while I'm still measuring faster execution of the Ring 2A/B on older hardware (with integrated graphics, etc.). So, goal is to get the same experience on different environments.

Array (implemented as a String) is an idea of Mahmoud. Which is wonderful idea because it also allows to have statically typed variables where you can't change the type once variable is declared. As we stay in contact, more we discover, which is important for the Ring future.

Greetings,
Ilir

Mansour Ayouni

unread,
Jul 12, 2024, 8:32:23 AM (10 days ago) Jul 12
to Ilir Liburn, The Ring Programming Language
Hello Ilir,

A very nice story of collaboration!

Thank you for you both.
Best,
Mansour

Antonio F.S.

unread,
Jul 12, 2024, 8:49:01 AM (10 days ago) Jul 12
to ring...@googlegroups.com

Hello.

What a wonderful team!

Static typing is just one of my wishes in Ring. Too bad I'm too busy to spend more time studying it, but I follow all the comments on the list.

Thank you very much.
Best regards.

Antonio F.S.

-------------------------------------------------------------------

El 12/7/24 a las 14:32, Mansour Ayouni escribió:

Ilir Liburn

unread,
Jul 12, 2024, 8:49:43 AM (10 days ago) Jul 12
to The Ring Programming Language

Hello Mansour,

You're Welcome. We also thank you for enriching the Ring through Softanza library.

Greetings,
Ilir

Bert Mariani

unread,
Jul 12, 2024, 12:23:00 PM (10 days ago) Jul 12
to The Ring Programming Language
Hello Mahmoud

>>>  To test it and see the performance results on your machine <<<
cd ring
git pull
cd extensions/ringraylib5/src
buildvc_x64                                         <<<===
cd ../../libdepwin/raylib5_x64/lib
copy *.dll ..\..\..\..\bin
cd ..\..\..\..\samples\usingraylib5\more
ring ex5_wavingcubes_withoutthreads.ring

=======================================
c:\ring\extensions\ringraylib5\src>
buildvc_x64 

** Visual Studio 2022 Developer Command Prompt v17.3.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31630 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

ring_raylib.c
ring_raylib.c(12194): warning C4047: 'function': 'bool *' differs in levels of indirection from 'bool'
ring_raylib.c(12194): warning C4024: 'GuiToggle': different types for formal and actual parameter 3
ring_raylib.c(12214): warning C4047: 'function': 'int *' differs in levels of indirection from 'int'
ring_raylib.c(12214): warning C4024: 'GuiToggleGroup': different types for formal and actual parameter 3
ring_raylib.c(12234): warning C4047: 'function': 'bool *' differs in levels of indirection from 'bool'
ring_raylib.c(12234): warning C4024: 'GuiCheckBox': different types for formal and actual parameter 3
ring_raylib.c(12254): warning C4047: 'function': 'int *' differs in levels of indirection from 'int'
ring_raylib.c(12254): warning C4024: 'GuiComboBox': different types for formal and actual parameter 3
ring_raylib.c(12387): warning C4020: 'GuiListView': too many actual parameters
ring_raylib.c(12429): warning C4020: 'GuiListViewEx': too many actual parameters
Microsoft (R) Incremental Linker Version 14.33.31630.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   Creating library ..\..\..\bin\ring_raylib.lib and object ..\..\..\bin\ring_raylib.exp
ring_raylib.obj : error LNK2019: unresolved external symbol ring_vm_api_paracount referenced in function ring_BeginBlendMode
ring_raylib.obj : error LNK2019: unresolved external symbol ring_vm_api_retnumber referenced in function ring_ChangeDirectory
ring_raylib.obj : error LNK2019: unresolved external symbol ring_vm_api_retstring referenced in function ring_GetClipboardText
..\..\..\bin\ring_raylib.dll : fatal error LNK1120: 3 unresolved externals

c:\ring\extensions\ringraylib5\src>

Mahmoud Fayed

unread,
Jul 12, 2024, 4:02:47 PM (10 days ago) Jul 12
to The Ring Programming Language
Hello Bert

>> "ring_raylib.obj : error LNK2019: unresolved external symbol ring_vm_api_paracount referenced in function ring_BeginBlendMode"

These errors mean that the Ring source code (ring/src & ring/include) is not identical to what we have in GitHub: 

You could try
cd ring
git stash
git pull

Then build Ring (ring/build/buildvc_x64.bat)
Then build again RingRayLib5  as in the steps in my previous post

Greetings,
Mahmoud

Bert Mariani

unread,
Jul 12, 2024, 4:50:31 PM (10 days ago) Jul 12
to The Ring Programming Language
Hi Mahmoud

cd c:\ring
c:\ring>git stash
No local changes to save

c:\ring>git pull
warning: redirecting to https://github.com/ring-lang/ring.git/
Already up to date.

c:\ring>

Bert Mariani

unread,
Jul 12, 2024, 5:14:32 PM (10 days ago) Jul 12
to The Ring Programming Language
Hello Mahmoud

Starting from scratch
========================

c:\ring>cd c:\

c:\>git clone http://github.com/ring-lang/ring.git
fatal: destination path 'ring' already exists and is not an empty directory.


RENAMED  C:\ring   to  ring-20b

c:\>
c:\>git clone http://github.com/ring-lang/ring.git

Cloning into 'ring'...
remote: Enumerating objects: 315165, done.
remote: Counting objects: 100% (2796/2796), done.
remote: Compressing objects: 100% (1212/1212), done.
remote: Total 315165 (delta 1818), reused 2465 (delta 1564), pack-reused 312369Receiving objects: 100% (315165/315165), Receiving objects: 100% (315165/315165), 2.30 GiB | 4.42 MiB/s, done.

Resolving deltas: 100% (209775/209775), done.
Updating files: 100% (24595/24595), done.

c:\>
cd c:/ring/build/
buildvc_x64.bat

....
....
..\extensions\libdepwin\pgsql_x64\lib\libcrypto-1_1-x64.dll
..\extensions\libdepwin\pgsql_x64\lib\libiconv-2.dll
..\extensions\libdepwin\pgsql_x64\lib\libintl-8.dll
..\extensions\libdepwin\pgsql_x64\lib\libpq.dll
..\extensions\libdepwin\pgsql_x64\lib\libssl-1_1-x64.dll
        5 file(s) copied.

c:\ring>
c:\ring>
c:\ring>
c:\ring>ringpm run ringnotepad

================================================================================
RingNotepad Package
================================================================================
RingNotepad package for the Ring programming language
See the folder : ring/tools/ringnotepad
================================================================================

Library File : ringqt.dll
Line 5 Error (R38) : Runtime Error in loading the dynamic library
In loadlib() In function loadlibfile() in file C:\Ring\libraries\guilib\loadlibfile.ring

Called from line 11 in file rnote.ring

c:\ring>

Mahmoud Fayed

unread,
Jul 12, 2024, 5:25:12 PM (10 days ago) Jul 12
to The Ring Programming Language
Hello Bert

The file ring/build/buildvc_x64.bat assume a path for Qt 5.15.17
If you have another version, this should be changed before running the batch file


Greetings,
Mahmoud

Bert Mariani

unread,
Jul 12, 2024, 6:32:11 PM (10 days ago) Jul 12
to The Ring Programming Language
Hello Mahmoud

 Click the button: Download the Qt online installer

After a few ... next ... next steps
Qt 5.15.17  does not show up in the list
Only version 6

QT5.PNG

Mahmoud Fayed

unread,
Jul 12, 2024, 6:34:36 PM (10 days ago) Jul 12
to The Ring Programming Language
Hello Bert

Just update the environment variable to use Qt 5.15.2 that you have

Qt 5.15.17 exist for commercial Qt users (But it's not necessary for building RingQt, i.e. Qt 5.15.2 is good enough)

Greetings,
Mahmoud

Bert Mariani

unread,
Jul 12, 2024, 9:49:43 PM (9 days ago) Jul 12
to The Ring Programming Language
Hello Mahmoud

c:\ring>SET RING_QT_VERSION=5.15.17   <<< started here then rest of cmds


c:\>
cd c:/ring/build/
buildvc_x64.bat


c:\ring>
c:\ring>ringpm run ringnotepad

================================================================================
RingNotepad Package
================================================================================
RingNotepad package for the Ring programming language
See the folder : ring/tools/ringnotepad
================================================================================

Library File : ringqt.dll
Line 5 Error (R38) : Runtime Error in loading the dynamic library
In loadlib() In function loadlibfile() in file C:\Ring\libraries\guilib\loadlibfile.ring

Called from line 11 in file rnote.ring


c:\ring>echo %RING_QT_VERSION%
5.15.17    <<<  version was previously 5.15.12

c:\ring>

Mahmoud Fayed

unread,
Jul 12, 2024, 11:55:20 PM (9 days ago) Jul 12
to The Ring Programming Language
Hello Bert

This line
SET RING_QT_VERSION=5.15.17   

Must be the version of Qt that you have on your machine
So, change it to
SET RING_QT_VERSION=5.15.2 

Greetings,
Mahmoud

MOHANNAD ALDULAIMI

unread,
Jul 13, 2024, 8:05:16 AM (9 days ago) Jul 13
to The Ring Programming Language
Hello Bert, Mahmoud.

Try to build qt lib using this commands:
cd extensions
cd ringqt
SET RING_QT_VERSION=5.15.2
buildvc.bat

Note you must have a qtcreator installed in your machine
I always update 'buildvc.bat' file according to my environment , e.g. my qt creator path is :  C:\Qt\qtcreator-11.0.2
not "C:\Qt\tools\qtcreator"

Best wishes 
Mohannad 

Bert Mariani

unread,
Jul 13, 2024, 8:51:16 AM (9 days ago) Jul 13
to The Ring Programming Language
Hello Mahmoud, Mohannad

Summary:
=======================
This was done before
========================
Change QT Version

cd  C:\ring\extensions
cd ringqt
SET RING_QT_VERSION=5.15.2

==========================
Rebuild everything

c:\>
cd c:/ring/build/
buildvc_x64.bat

==========================
Start Ring NotePad

c:\ring>ringpm run ringnotepad
================================================================================
RingNotepad Package
================================================================================
RingNotepad package for the Ring programming language
See the folder : ring/tools/ringnotepad
================================================================================
qt.gui.icc: Unsupported ICC profile class 70727472
QPngHandler: Failed to parse ICC profile

==========================
Ring NotePad  -- Started GUI

C:/ring/samples.UsingOpenGL/stars3.ring

Old Speed New Speed
FPS : 1028 FPS : 1290    
FPS : 975 FPS : 1314    
FPS : 956 FPS : 1323    
FPS : 1028 FPS : 1393    
FPS : 1059 FPS : 1723    
FPS : 903 FPS : 1751    
FPS : 967 FPS : 1769    
FPS : 1071 FPS : 1733    
FPS : 1068 FPS : 1731    
FPS : 1000 FPS : 1751    
        FPS : 1798    
        FPS : 1728    
        FPS : 1732    
        FPS : 1779    
        FPS : 1696  

Certainly a lot faster by ~70% on my HP-i5
Now I have to check out the speed on some other drawing apps  :D

Thanks
Bert Mariani

====================
QT on my machine

QTDir.png

Mahmoud Fayed

unread,
Jul 13, 2024, 10:18:44 AM (9 days ago) Jul 13
to The Ring Programming Language
Hello Bert

>> "Certainly a lot faster by ~70% on my HP-i5"

This is good news, Thanks for sharing :D

Greetings,
Mahmoud

Mansour Ayouni

unread,
Jul 13, 2024, 10:34:30 AM (9 days ago) Jul 13
to Mahmoud Fayed, The Ring Programming Language
Hello Bert,

I appreciate the discipline you demonstrate in documenting the problems you encounter and sharing back the solutions in an instructive way.

This helps everyone to learn while following this group.

 Best,
Mansour

Reply all
Reply to author
Forward
0 new messages