IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PureBasic Discussion :

PureBasic 6.40 alpha 1 est disponible, avec une surprise !


Sujet :

PureBasic

  1. #1
    Responsable Purebasic

    Avatar de comtois
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 329
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 329
    Billets dans le blog
    8
    Par défaut PureBasic 6.40 alpha 1 est disponible, avec une surprise !
    Hi everyone !

    That's it, we finally decided to rework the internal stringmanager from the ground up ! The stringmanager hasn't changed since the PureBasic
    creation almost 30 years ago, so it wasn't an easy decision to make because major modification for the compilers were needed and all the functions returning a string were impacted. But it's here with the 6.40 alpha 1, only available for the C back-end on Windows x64. The idea is to validate the new stringmanager to see if there is any showstopper before porting the modification to the x86 and x64 asm compilers which will takes time.

    I will share some internal information about it:

    - It should be 99% backward compatible. We will discuss edge case below.

    - All strings are now prefixed by their length (except the strings in DataSection). The last bit of this prefix is used for a temporary flag.
    That means than all string operation will have instant length information resulting in faster operation as iterating byte by byte on the string to find the null terminated char is no more needed.
    The strings are still null terminated, so no change are needed in client code.

    - Still no garbage collector

    - The string manager doesn't have a per thread shared buffer anymore for temporary strings. That means there is no global variable to save the current position and the thread mode will have no performance hit. All is now done as new temporary string which will be used as final string if assigned. That removes useless string copy and is much more streamlined.

    Example:

    Old:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SYS_PushStringBasePosition(); // current position in the shared buffer is saved (costly in threaded mode)
    SYS_CopyString(v_bS); // string is copied on the per thread shared buffer 
    SYS_CopyString(v_cS);
    SYS_AllocateString4(&v_aS,SYS_PopStringBasePosition()); // Position is restored and string is allocated

    New:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    s1=SYS_ConcatString(v_cS,v_bS); // A temporary string is created here
    SYS_NewString(&v_aS,s1); // The temporary string is directly used (temporary bit removed)

    It's a very basic case, but it shows the improvement by avoiding useless string copy and global variable preservation

    - Optimized procedure parameters passing. If a string parameter isn't modified in the procedure, it will not be duplicated in the procedure. For example

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Procedure.s a(a$, b$)
      ProcedureReturn UCase(a$) + LCase(b$)
    EndProcedure
    Here the a$ and b$ are just referenced and won't be duplicated. In the older system, all the string parameters were duplicated.

    Even better, the procedure 'a()' will return a temporary string which will be directly assigned to Result$ (no extra allocation/copy):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Result$ = a("Hello", "World")
    Here are the case where the parameters will be duplicated

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Procedure.s a(a$, b$)
      a$ = "-"+a$ ; Here, the a$ will be duplicated at procedure start, as it's modified.
      ProcedureReturn UCase(a$) + LCase(b$)
    EndProcedure
     
    Procedure.s a(a$, b$)
      *Cursor = @a$ ; Will also be duplicated as getting the pointer allow modification
      ProcedureReturn UCase(a$) + LCase(b$)
    EndProcedure
    - The string functions don't have an hidden parameter anymore, allowing better code generation

    c$ = Str(150)

    Old:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SYS_PushStringBasePosition();
    SYS_PushStringBasePosition();
    PB_Str(150LL,SYS_PopStringBasePosition());
    SYS_AllocateString4(&v_cS,SYS_PopStringBasePosition());
    New:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    void *r5=PB_Str(150LL);
    SYS_NewString(&v_cS,r5);
    - For PureBasic function returning a string, it's possible to tag a parameter as 'reusable' to avoid extra allocation when a temporary string is passed. For now, only LCase() and UCase() uses this, but it greatly improves their performances:

    Ex:

    The allocation is done when concatenating 'b$' + 'c$', then the UCase() function directly change the buffer with upper case character and returns the same buffer which is assigned to a$. So only one allocation occurred and no extra copy were performed.

    - The 'mimalloc' memory manager has been integrated in PureBasic for all dynamic allocation to have a very fast and optimized memory allocator for all internal functions. More info here: https://github.com/microsoft/mimalloc

    - Overall the performances should be much better, but there will be probably some case were it won't ! Feel free to test it and bench it with your own code (my speed test suite show major improvement (up to 10x) on most tests). For example this one is 9x faster:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Start = ElapsedMilliseconds()
    a$ = "World WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld WorldWorld World"
    For l = 0 To 1000
      b$ = b$ + a$ 
    Next
     
    PrintN("Final length = " + Str(Len(b$)))
    PrintN("Large concat: "+Str(ElapsedMilliseconds() - Start) + " ms")
    - Edge cases:

    We tried to do the migration as painless as possible, but there is some case where code change will be required. Basically if you patch a string by putting a zero in it, the Len() function will be wrong, and the concat functions will fail. You will need to use PeekS() for this.
    You can take a look to the needed modification for the IDE to work with the new stringmanager, it's very light: https://github.com/fantaisie-software/p ... /344/files

    Using Win32 API with Space() for example will require an extra PeekS(). If you find other issues, don't hesitate to share it, so I can take a look if it can be addressed or not.

    We hope this major rework will increase the PureBasic app efficiency. Don't hesitate to test it but don't use this build in prod, it's indeed not production ready yet !

    Have fun,

    The Fantaisie Software Team

    Source de l'information
    Vous souhaitez participer à la rubrique PureBasic (tutoriels, FAQ, sources) ? Contactez-moi par MP.

  2. #2
    Responsable Purebasic

    Avatar de comtois
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 329
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 329
    Billets dans le blog
    8
    Par défaut PureBasic 6.40 alpha 3 est disponible sur votre compte
    Comme d'habitude, je ne traduis pas votre anglais est meilleur que le mien.
    2026-01-31: alpha 3 is available for Windows x64 ! A few more bugs has been fixed, and a new StringBuilder library has been added for very fast string concatenation ! Here is a small example:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    a$ = "Hello, World !"
    CreateStringBuilder(0, 64000)
    For l = 1 To 2000
      AppendStringBuilderString(0, a$)
    Next
    b$ = FinishStringBuilder(0)

    Don't hesitate to test this version if you can as we believe it's ready for larger tests.
    Vous souhaitez participer à la rubrique PureBasic (tutoriels, FAQ, sources) ? Contactez-moi par MP.

  3. #3
    Responsable Purebasic

    Avatar de comtois
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 329
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 329
    Billets dans le blog
    8
    Par défaut PureBasic 6.40 alpha 4 est disponible sur votre compte
    2026-02-12: alpha 4 is out, the assembly x64 backend is back in business ! If you can, please test it to see if everything works as expected.
    Vous souhaitez participer à la rubrique PureBasic (tutoriels, FAQ, sources) ? Contactez-moi par MP.

  4. #4
    Responsable Purebasic

    Avatar de comtois
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 329
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 329
    Billets dans le blog
    8
    Par défaut PureBasic 6.40 beta 1 est disponible sur votre compte
    2026-02-27: beta 1 is out, the assembly x86 backend is also fully working, on Windows and Linux ! All packages are now availables for testing, as usual.
    Vous souhaitez participer à la rubrique PureBasic (tutoriels, FAQ, sources) ? Contactez-moi par MP.

Discussions similaires

  1. Réponses: 0
    Dernier message: 02/12/2019, 16h31
  2. LLVM 7 est disponible avec une nouvelle extension LLVM pour Visual Studio
    Par Christian Olivier dans le forum Clang et LLDB
    Réponses: 0
    Dernier message: 24/09/2018, 21h45
  3. GTK+ 3.20 est disponible avec une mise à jour de ses composants de base
    Par Victor Vincent dans le forum GTK+ avec C & C++
    Réponses: 0
    Dernier message: 27/03/2016, 13h02
  4. Firefox 43 est disponible avec une version 64 bits pour Windows
    Par Olivier Famien dans le forum Firefox
    Réponses: 11
    Dernier message: 22/12/2015, 09h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo