Author Topic: How to improve the computing speed of MD5  (Read 4332 times)

0 Members and 1 Guest are viewing this topic.

baitang36

  • Bull Frog
  • Posts: 213
How to improve the computing speed of MD5
« on: October 16, 2022, 09:28:21 PM »
The MD5 algorithm of the lsp version is very slow, which is criticized by many people. Can you optimize it and improve the speed?

Yc-MD5.lsp is the source code of MD5 algorithm for lsp version found in the forum. It has been changed from time to time with little speed improvement. It seems that we need to find another way out.

The problem with the lsp version of MD5 is that it uses lsp to build wheels and uses lsp statements to implement MD5.

After searching, it is found that the Windows kernel has MD5 algorithm, that is, it provides the API of MD5 algorithm, so long as it is called, there is no need to make your own wheel.

syz-md5.fas is implemented by calling the system api with pure lsp. 32-bit and 64 bit are common. The usage is after loading (syz-md5 "string"). The return value is the MD5 value string of the string. The speed can be described as fast. In my test, 500 MD5 calculations were performed, and the yc-md5 program took 14.15 seconds; The syz-md5 program takes 0.032 seconds, and the speed difference is 400 times.

Tt5.lsp is the test program.
Command: (LOAD "D:/aa/tt5. lsp") C: TT5
Command: tt5
This method is only applicable to autocad because it uses the unexposed functions of autocad

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2087
  • class keyThumper<T>:ILazy<T>
Re: How to improve the computing speed of MD5
« Reply #1 on: October 17, 2022, 02:11:25 AM »
500 MD5 calculations seems a lot.

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

d2010

  • Bull Frog
  • Posts: 322
Re: How to improve the computing speed of MD5
« Reply #2 on: October 17, 2022, 11:13:07 AM »
The MD5 algorithm of the lsp version is very slow, which is criticized by many people. Can you optimize it and improve the speed?
Yc-MD5.lsp is the source code of MD5 algorithm for lsp version found in the forum. It has been changed from time to time with little speed improvement. It seems that we need to find another way out.
For optimize the code source.lisp, then you  must learn, before, other programming  language. (e.g Java, Julia, ). Why?
Because .. The module javac.exe contain hunders * hunders of optimizations.
Too many years, 10-50 engineers work at
--a)code optimization of speed
--b)code optimization of eating memory
--c)code optimization of parse the variabile (local, static ,global , dynamical, incapsulate inside Object)
Ps:=Visual Lisp are too weak for support the optimizations.
 :sleezy:
« Last Edit: October 17, 2022, 11:17:04 AM by d2010 »

VovKa

  • Water Moccasin
  • Posts: 1617
  • Ukraine
Re: How to improve the computing speed of MD5
« Reply #3 on: October 17, 2022, 01:53:50 PM »
syz-md5.fas is implemented by calling the system api with pure lsp.
and this is great news, baitang36
well done
i think it brings lisp to a new level

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: How to improve the computing speed of MD5
« Reply #4 on: October 17, 2022, 02:00:06 PM »
syz-md5.fas is implemented by calling the system api with pure lsp
when this possibility will be available for the normal people ? :-)

baitang36

  • Bull Frog
  • Posts: 213
Re: How to improve the computing speed of MD5
« Reply #5 on: October 18, 2022, 07:43:17 PM »
syz-md5.fas is implemented by calling the system api with pure lsp
when this possibility will be available for the normal people ? :-)
Because this technology is not disclosed by autodesk, I am afraid that if it is disclosed, it will be blocked and will not be used in the future

baitang36

  • Bull Frog
  • Posts: 213
Re: How to improve the computing speed of MD5
« Reply #6 on: October 18, 2022, 07:44:58 PM »
syz-md5.fas is implemented by calling the system api with pure lsp.
and this is great news, baitang36
well done
i think it brings lisp to a new level
I tested that there was no problem in the 32-bit system. However, in 64 bit systems, some APIs will make mistakes

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: How to improve the computing speed of MD5
« Reply #7 on: October 18, 2022, 10:55:19 PM »
Quote
Because this technology is not disclosed by autodesk, I am afraid that if it is disclosed, it will be blocked and will not be used in the future

but maybe with Bricscad it could be different ...

VovKa

  • Water Moccasin
  • Posts: 1617
  • Ukraine
Re: How to improve the computing speed of MD5
« Reply #8 on: October 19, 2022, 05:26:15 AM »
I tested that there was no problem in the 32-bit system. However, in 64 bit systems, some APIs will make mistakes
i guess the api function that generates MD5 hash works with strings, takes a string as an argument and returns a string
what about arrays?
is there a way to pass an array as an argument to dll calls?

baitang36

  • Bull Frog
  • Posts: 213
Re: How to improve the computing speed of MD5
« Reply #9 on: October 19, 2022, 07:19:27 AM »
I tested that there was no problem in the 32-bit system. However, in 64 bit systems, some APIs will make mistakes
i guess the api function that generates MD5 hash works with strings, takes a string as an argument and returns a string
what about arrays?
is there a way to pass an array as an argument to dll calls?
In fact, the input of md5 is a pile of binary data, and the output is also binary. It is made into a string for reading convenience
The array can be converted to a string first, and then MD5 can be calculated

baitang36

  • Bull Frog
  • Posts: 213
Re: How to improve the computing speed of MD5
« Reply #10 on: October 19, 2022, 07:24:54 AM »
syz-md5.fas is implemented by calling the system api with pure lsp.
and this is great news, baitang36
well done
i think it brings lisp to a new level
  Called ntdll.dll, core code is :
(syz-api "ntdll.dll" "MD5Init" ctx)
  (syz-api "ntdll.dll" "MD5Update" ctx str1  (strlen str1)  )
  (syz-api "ntdll.dll" "MD5Final" ctx)

VovKa

  • Water Moccasin
  • Posts: 1617
  • Ukraine
Re: How to improve the computing speed of MD5
« Reply #11 on: October 19, 2022, 08:10:55 AM »
In fact, the input of md5 is a pile of binary data, and the output is also binary. It is made into a string for reading convenience
The array can be converted to a string first, and then MD5 can be calculated
this is clear
what if i want to pass to a dll function an array of floats (list of point coordinates for example)?
is it possible with syz-api?

baitang36

  • Bull Frog
  • Posts: 213
Re: How to improve the computing speed of MD5
« Reply #12 on: October 19, 2022, 08:34:40 AM »
In fact, the input of md5 is a pile of binary data, and the output is also binary. It is made into a string for reading convenience
The array can be converted to a string first, and then MD5 can be calculated
this is clear
what if i want to pass to a dll function an array of floats (list of point coordinates for example)?
is it possible with syz-api?
(syz-md5(strcat(rtos x)(rtos y)(rtos z)))

VovKa

  • Water Moccasin
  • Posts: 1617
  • Ukraine
Re: How to improve the computing speed of MD5
« Reply #13 on: October 19, 2022, 09:09:03 AM »
(syz-md5(strcat(rtos x)(rtos y)(rtos z)))
a have a library of functions written i C++ and compiled to a dll file (i can not modify it)
i want to call one of these functions from lisp and pass two arguments to it, one is a float and another is an array of floats
can it be done with your syz-api function?

baitang36

  • Bull Frog
  • Posts: 213
Re: How to improve the computing speed of MD5
« Reply #14 on: October 19, 2022, 09:50:09 PM »
(syz-md5(strcat(rtos x)(rtos y)(rtos z)))
a have a library of functions written i C++ and compiled to a dll file (i can not modify it)
i want to call one of these functions from lisp and pass two arguments to it, one is a float and another is an array of floats
can it be done with your syz-api function?
syz-api only support string and inter(addr)