flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [fasmg] big slowdown after version hxmfv

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 17 Oct 2017, 13:56
The following example code parses a field in a large text file and converts the text hexadecimal to binary.
In version hxmfv when run as either a macro or not it takes only insignificantly longer to run as a macro.
However in the subsequent and lastest version it take 2X longer.
Code:
virtual at 0
unicode_data::
  file "UnicodeData-11.0.0d1.txt"
end virtual

struc column n
  local x, position, value
  x = 0
  position = 0
  repeat n
    while x <> ';'
      load x: byte from unicode_data: + line + position
      position = position + 1
    end while
    x = 0
  end repeat
  value = '0'
  while 1
    load x: byte from unicode_data: + line + position
    if x = ';'
      break
    end if
    position = position + 1
    value = (value shl 8) + x
  end while
  . = value
end struc

macro next_line
  local x
  x = 0
  while x <> 0x0A
    load x: byte from unicode_data: + line
    line = line + 1
  end while
end macro

struc hex2bin value
  local x
  result = 0
  repeat 5, n: 0
    result = result shl 4
    x = (value shr (32 - n * 8)) and 0xFF
    x = x - '0'
    if x > 9
      x = x - 7
    end if
    result = result + x
  end repeat
  . = result
end struc

  line = 0

;macro unicode_parser
;  local x, unicode
  repeat 10000
    x column 0
    next_line
    unicode hex2bin x
    dd unicode
  end repeat
;end macro

;  unicode_parser    
The text file is here

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com
Post 17 Oct 2017, 13:56
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 Oct 2017, 16:06
"hxmfv" is a number of version in the lowmem branch, which is a separately maintained fork at the moment. I have not merged this variant into the trunk, because in other cases (like fasmg self-hosting) it is slower (though it uses less memory). If this variant works better for you, please use checkouts from this branch instead of the official packages (which are made from the trunk).
Post 17 Oct 2017, 16:06
View user's profile Send private message Visit poster's website Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 17 Oct 2017, 16:14
Tomasz Grysztar wrote:
"hxmfv" is a number of version in the lowmem branch, which is a separately maintained fork at the moment. I have not merged this variant into the trunk, because in other cases (like fasmg self-hosting) it is slower. If this variant works better for you, please use checkouts from this branch instead of the official packages (which are made from the trunk).
All versions are the same time when not used as a macro. It is only the newer versions which have the large
difference between macro and non-macro when both methods are run on the same version.

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com
Post 17 Oct 2017, 16:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 Oct 2017, 16:20
Mike Gonta wrote:
Tomasz Grysztar wrote:
"hxmfv" is a number of version in the lowmem branch, which is a separately maintained fork at the moment. I have not merged this variant into the trunk, because in other cases (like fasmg self-hosting) it is slower. If this variant works better for you, please use checkouts from this branch instead of the official packages (which are made from the trunk).
All versions are the same time when not used as a macro. It is only the newer versions which have the large
difference between macro and non-macro when both methods are run on the same version.
The differences between the trunk and the "lowmem" branch are exactly in how the macros are handled. The newest version at the moment is actually the "hyhy9" in the "lowmem" branch, please try it. Because my guess it not related to which version is more recent, only whether it is from the trunk or the branch.
Post 17 Oct 2017, 16:20
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 Oct 2017, 16:31
I should have made the branch display a different signature next to the version number. I have initially made this branch for some private tests and I have not thought about it.
Post 17 Oct 2017, 16:31
View user's profile Send private message Visit poster's website Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 17 Oct 2017, 23:14
Tomasz Grysztar wrote:
The differences between the trunk and the "lowmem" branch are exactly in how the macros are handled. The newest version at the moment is actually the "hyhy9" in the "lowmem" branch, please try it. Because my guess it not related to which version is more recent, only whether it is from the trunk or the branch.
OK, it's the branch.
Code:
hyhy9 self hosted = 39.1
hyhy9 example inline = 11.0
hyhy9 example as macro = 11.4

hygtl self hosted = 37.8
hygtl example inline = 11.0
hygtl example as macro = 16.9    
However, my actual program which parses 16,584 lines of the text file and creates a rule based compressed table
takes 10X longer as a macro verses inline (15 times longer than hxmfv).
Code:
hxmfv actual program inline = 63.2
hxmfv actual program as macro = 64.0

hyhy9 actual program inline = 68.5
hyhy9 actual program as macro = 95.3

hygtl actual program inline = 55.0
hygtl actual program as macro = 965.1    

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com
Post 17 Oct 2017, 23:14
View user's profile Send private message Visit poster's website Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 243
Mike Gonta 18 Oct 2017, 09:00
Mike Gonta wrote:
However, my actual program which parses 16,584 lines of the text file and creates a rule based compressed table
takes 10X longer as a macro verses inline (15 times longer than hxmfv).
OK, the actual program actually needs to create 3 similar compressed lookup tables (and maybe some other tables
with other different info from the file) based on a column from the file (which is actually a semicolon separated csv
spreadsheet.
Originally, I had intended to repeat the code as a macro 3 times (changing the column number each time). Now, I'll
simply repeat the inline code 3 times to avoid the macro overhead.

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com
Post 18 Oct 2017, 09:00
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 18 Oct 2017, 09:31
Mike Gonta wrote:
... a semicolon separated csv spreadsheet.
I'd guess that would make it a ssv file?

Semicolon Separated Values
Post 18 Oct 2017, 09:31
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 18 Oct 2017, 12:41
I have found the actual problem that was causing the slow-down. The thing is, the changes made in the "lowmem" branch did hide the problem, and that's why it seemed that the branch fixed it.
Post 18 Oct 2017, 12:41
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 18 Oct 2017, 12:49
Please try the new version "hykpg", it fixes the actual underlying problem.
Post 18 Oct 2017, 12:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.