The Inbox: Compiler-mt.437.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Compiler-mt.437.mcz

commits-2
A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
  ----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
  pragmaStatement
  "Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.
 
  Note that custom pragma parsers need to fulfill two requirements:
  (1) method selector must match the current token as simple getter,
  e.g., <apicall: ...> matches #apicall or <primitive: ...> matches #primitive
  (2) method must declare <pragmaParser> to be called.
  This is for the protection of the parser's (message) namespace."
 
+ | parserSelector |
- | parserSelector parserMethod |
  (hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
  ifFalse: [  ^ self expected: 'pragma declaration' ].
 
+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as <primitive> and <foobar>; also avoid interning new symbols for made-up pragmas such as for <my: 1 new: 2 pragma: 3> not interning #my."
+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].
 
+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
  ^ self pragmaStatementKeywords!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.437.mcz

marcel.taeumel
Hi all!

Here are some benchmarks. Same context as here:

=== BEFORE ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "39,800 per second. 25.1 microseconds per run. 7.5 % GC time.",
      "41,600 per second. 24 microseconds per run. 3.72 % GC time.",
      "40,800 per second. 24.5 microseconds per run. 3.92 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,610 per second. 178 microseconds per run. 2.26 % GC time.",
      "5,590 per second. 179 microseconds per run. 2.65947 % GC time.",
      "5,550 per second. 180 microseconds per run. 2.95941 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "25,800 per second. 38.7 microseconds per run. 2.9794 % GC time.",
      "25,800 per second. 38.8 microseconds per run. 3.19936 % GC time.",
      "26,000 per second. 38.5 microseconds per run. 3.14 % GC time."
   ],
   "Win32Pool class>>winver":[
      "16,100 per second. 62 microseconds per run. 3.65927 % GC time.",
      "16,200 per second. 61.7 microseconds per run. 3.66 % GC time.",
      "16,100 per second. 62 microseconds per run. 3.52 % GC time."
   ]
}

=== AFTER ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "37,200 per second. 26.8 microseconds per run. 7.4785 % GC time.",
      "37,800 per second. 26.4 microseconds per run. 6.77864 % GC time.",
      "37,400 per second. 26.7 microseconds per run. 7.16 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,140 per second. 195 microseconds per run. 8.04 % GC time.",
      "5,220 per second. 192 microseconds per run. 8.22 % GC time.",
      "5,270 per second. 190 microseconds per run. 8.22 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "24,000 per second. 41.7 microseconds per run. 9.43811 % GC time.",
      "23,900 per second. 41.9 microseconds per run. 9.25815 % GC time.",
      "23,500 per second. 42.6 microseconds per run. 9.3 % GC time."
   ],
   "Win32Pool class>>winver":[
      "13,900 per second. 72.1 microseconds per run. 8.88 % GC time.",
      "13,700 per second. 73 microseconds per run. 8.58 % GC time.",
      "13,800 per second. 72.6 microseconds per run. 8.7 % GC time."
   ]
}

Best,
Marcel

Am 13.06.2020 11:01:53 schrieb [hidden email] <[hidden email]>:

A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.

Note that custom pragma parsers need to fulfill two requirements:
(1) method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
(2) method must declare to be called.
This is for the protection of the parser's (message) namespace."

+ | parserSelector |
- | parserSelector parserMethod |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."
+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].

+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
^ self pragmaStatementKeywords!




Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.437.mcz

marcel.taeumel
Here is the benchmark code:

({
   FFITestLibrary >> #ffiPrintString:. "<cdecl...>"
   BitBlt >> #copyBits. "<primitive: ...>"
   ExternalPoolReadWriter >> #fetchFromFile. "1 simple pragma"
   Win32Pool class >> #winver. "9 simple pragmas"
} collect: [:method |
   | source class |
   source := method getSource.
   class := method methodClass.
   (method methodClass name, '>>', method selector)
      -> ((1 to: 3) collect: [:e | [Parser new parse: source class: class] bench])]
   as: OrderedDictionary) asJsonString.


Best,
Marcel

Am 13.06.2020 11:17:36 schrieb Marcel Taeumel <[hidden email]>:

Hi all!

Here are some benchmarks. Same context as here:

=== BEFORE ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "39,800 per second. 25.1 microseconds per run. 7.5 % GC time.",
      "41,600 per second. 24 microseconds per run. 3.72 % GC time.",
      "40,800 per second. 24.5 microseconds per run. 3.92 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,610 per second. 178 microseconds per run. 2.26 % GC time.",
      "5,590 per second. 179 microseconds per run. 2.65947 % GC time.",
      "5,550 per second. 180 microseconds per run. 2.95941 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "25,800 per second. 38.7 microseconds per run. 2.9794 % GC time.",
      "25,800 per second. 38.8 microseconds per run. 3.19936 % GC time.",
      "26,000 per second. 38.5 microseconds per run. 3.14 % GC time."
   ],
   "Win32Pool class>>winver":[
      "16,100 per second. 62 microseconds per run. 3.65927 % GC time.",
      "16,200 per second. 61.7 microseconds per run. 3.66 % GC time.",
      "16,100 per second. 62 microseconds per run. 3.52 % GC time."
   ]
}

=== AFTER ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "37,200 per second. 26.8 microseconds per run. 7.4785 % GC time.",
      "37,800 per second. 26.4 microseconds per run. 6.77864 % GC time.",
      "37,400 per second. 26.7 microseconds per run. 7.16 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,140 per second. 195 microseconds per run. 8.04 % GC time.",
      "5,220 per second. 192 microseconds per run. 8.22 % GC time.",
      "5,270 per second. 190 microseconds per run. 8.22 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "24,000 per second. 41.7 microseconds per run. 9.43811 % GC time.",
      "23,900 per second. 41.9 microseconds per run. 9.25815 % GC time.",
      "23,500 per second. 42.6 microseconds per run. 9.3 % GC time."
   ],
   "Win32Pool class>>winver":[
      "13,900 per second. 72.1 microseconds per run. 8.88 % GC time.",
      "13,700 per second. 73 microseconds per run. 8.58 % GC time.",
      "13,800 per second. 72.6 microseconds per run. 8.7 % GC time."
   ]
}

Best,
Marcel

Am 13.06.2020 11:01:53 schrieb [hidden email] <[hidden email]>:

A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.

Note that custom pragma parsers need to fulfill two requirements:
(1) method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
(2) method must declare to be called.
This is for the protection of the parser's (message) namespace."

+ | parserSelector |
- | parserSelector parserMethod |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."
+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].

+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
^ self pragmaStatementKeywords!




Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.437.mcz

fniephaus
In reply to this post by marcel.taeumel


On Sat, 13 Jun 2020 at 11:17 am, Marcel Taeumel <[hidden email]> wrote:
Hi all!

Here are some benchmarks. Same context as here:

=== BEFORE ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "39,800 per second. 25.1 microseconds per run. 7.5 % GC time.",
      "41,600 per second. 24 microseconds per run. 3.72 % GC time.",
      "40,800 per second. 24.5 microseconds per run. 3.92 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,610 per second. 178 microseconds per run. 2.26 % GC time.",
      "5,590 per second. 179 microseconds per run. 2.65947 % GC time.",
      "5,550 per second. 180 microseconds per run. 2.95941 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "25,800 per second. 38.7 microseconds per run. 2.9794 % GC time.",
      "25,800 per second. 38.8 microseconds per run. 3.19936 % GC time.",
      "26,000 per second. 38.5 microseconds per run. 3.14 % GC time."
   ],
   "Win32Pool class>>winver":[
      "16,100 per second. 62 microseconds per run. 3.65927 % GC time.",
      "16,200 per second. 61.7 microseconds per run. 3.66 % GC time.",
      "16,100 per second. 62 microseconds per run. 3.52 % GC time."
   ]
}

=== AFTER ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "37,200 per second. 26.8 microseconds per run. 7.4785 % GC time.",
      "37,800 per second. 26.4 microseconds per run. 6.77864 % GC time.",
      "37,400 per second. 26.7 microseconds per run. 7.16 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,140 per second. 195 microseconds per run. 8.04 % GC time.",
      "5,220 per second. 192 microseconds per run. 8.22 % GC time.",
      "5,270 per second. 190 microseconds per run. 8.22 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "24,000 per second. 41.7 microseconds per run. 9.43811 % GC time.",
      "23,900 per second. 41.9 microseconds per run. 9.25815 % GC time.",
      "23,500 per second. 42.6 microseconds per run. 9.3 % GC time."
   ],
   "Win32Pool class>>winver":[
      "13,900 per second. 72.1 microseconds per run. 8.88 % GC time.",
      "13,700 per second. 73 microseconds per run. 8.58 % GC time.",
      "13,800 per second. 72.6 microseconds per run. 8.7 % GC time."
   ]
}

Am I reading this wrong, or is after worse than before?

Fabio


Best,
Marcel

Am 13.06.2020 11:01:53 schrieb [hidden email] <[hidden email]>:

A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.

Note that custom pragma parsers need to fulfill two requirements:
(1) method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
(2) method must declare to be called.
This is for the protection of the parser's (message) namespace."

+ | parserSelector |
- | parserSelector parserMethod |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."

+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].

+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
^ self pragmaStatementKeywords!





Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.437.mcz

marcel.taeumel
Hi Fabio!

Am I reading this wrong, or is after worse than before?

Huh? Of course it is a little bit worse. I am proposing an extension hook for pragma parsing here. :-) The goal is to make the overhead as thin as possible.

"=== BEFORE ===" means Compiler-mt.435 in Trunk.
"=== AFTER ===" means Compiler-mt.437 in Inbox but with the Hook enabled, which would allow me to extract FFI-specific parsing code to the FFI-Kernel package.

That's why my examples parse only some methods that have pragmas in them. There is no impact on parsing methods that do not have any pragmas.

Best,
Marcel

Am 13.06.2020 12:36:26 schrieb Fabio Niephaus <[hidden email]>:



On Sat, 13 Jun 2020 at 11:17 am, Marcel Taeumel <[hidden email]> wrote:
Hi all!

Here are some benchmarks. Same context as here:

=== BEFORE ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "39,800 per second. 25.1 microseconds per run. 7.5 % GC time.",
      "41,600 per second. 24 microseconds per run. 3.72 % GC time.",
      "40,800 per second. 24.5 microseconds per run. 3.92 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,610 per second. 178 microseconds per run. 2.26 % GC time.",
      "5,590 per second. 179 microseconds per run. 2.65947 % GC time.",
      "5,550 per second. 180 microseconds per run. 2.95941 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "25,800 per second. 38.7 microseconds per run. 2.9794 % GC time.",
      "25,800 per second. 38.8 microseconds per run. 3.19936 % GC time.",
      "26,000 per second. 38.5 microseconds per run. 3.14 % GC time."
   ],
   "Win32Pool class>>winver":[
      "16,100 per second. 62 microseconds per run. 3.65927 % GC time.",
      "16,200 per second. 61.7 microseconds per run. 3.66 % GC time.",
      "16,100 per second. 62 microseconds per run. 3.52 % GC time."
   ]
}

=== AFTER ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "37,200 per second. 26.8 microseconds per run. 7.4785 % GC time.",
      "37,800 per second. 26.4 microseconds per run. 6.77864 % GC time.",
      "37,400 per second. 26.7 microseconds per run. 7.16 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,140 per second. 195 microseconds per run. 8.04 % GC time.",
      "5,220 per second. 192 microseconds per run. 8.22 % GC time.",
      "5,270 per second. 190 microseconds per run. 8.22 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "24,000 per second. 41.7 microseconds per run. 9.43811 % GC time.",
      "23,900 per second. 41.9 microseconds per run. 9.25815 % GC time.",
      "23,500 per second. 42.6 microseconds per run. 9.3 % GC time."
   ],
   "Win32Pool class>>winver":[
      "13,900 per second. 72.1 microseconds per run. 8.88 % GC time.",
      "13,700 per second. 73 microseconds per run. 8.58 % GC time.",
      "13,800 per second. 72.6 microseconds per run. 8.7 % GC time."
   ]
}

Am I reading this wrong, or is after worse than before?

Fabio


Best,
Marcel

Am 13.06.2020 11:01:53 schrieb [hidden email] <[hidden email]>:

A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.

Note that custom pragma parsers need to fulfill two requirements:
(1) method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
(2) method must declare to be called.
This is for the protection of the parser's (message) namespace."

+ | parserSelector |
- | parserSelector parserMethod |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."

+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].

+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
^ self pragmaStatementKeywords!





Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.437.mcz

fniephaus


On Sat, 13 Jun 2020 at 12:41 pm, Marcel Taeumel <[hidden email]> wrote:
Hi Fabio!

Am I reading this wrong, or is after worse than before?

Huh? Of course it is a little bit worse. I am proposing an extension hook for pragma parsing here. :-) The goal is to make the overhead as thin as possible.

I was confused because the commit message says "Speed-up method-based hook...", so I was looking for a speedup.

Fabio


"=== BEFORE ===" means Compiler-mt.435 in Trunk.
"=== AFTER ===" means Compiler-mt.437 in Inbox but with the Hook enabled, which would allow me to extract FFI-specific parsing code to the FFI-Kernel package.

That's why my examples parse only some methods that have pragmas in them. There is no impact on parsing methods that do not have any pragmas.

Best,
Marcel

Am 13.06.2020 12:36:26 schrieb Fabio Niephaus <[hidden email]>:



On Sat, 13 Jun 2020 at 11:17 am, Marcel Taeumel <[hidden email]> wrote:
Hi all!

Here are some benchmarks. Same context as here:

=== BEFORE ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "39,800 per second. 25.1 microseconds per run. 7.5 % GC time.",
      "41,600 per second. 24 microseconds per run. 3.72 % GC time.",
      "40,800 per second. 24.5 microseconds per run. 3.92 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,610 per second. 178 microseconds per run. 2.26 % GC time.",
      "5,590 per second. 179 microseconds per run. 2.65947 % GC time.",
      "5,550 per second. 180 microseconds per run. 2.95941 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "25,800 per second. 38.7 microseconds per run. 2.9794 % GC time.",
      "25,800 per second. 38.8 microseconds per run. 3.19936 % GC time.",
      "26,000 per second. 38.5 microseconds per run. 3.14 % GC time."
   ],
   "Win32Pool class>>winver":[
      "16,100 per second. 62 microseconds per run. 3.65927 % GC time.",
      "16,200 per second. 61.7 microseconds per run. 3.66 % GC time.",
      "16,100 per second. 62 microseconds per run. 3.52 % GC time."
   ]
}

=== AFTER ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "37,200 per second. 26.8 microseconds per run. 7.4785 % GC time.",
      "37,800 per second. 26.4 microseconds per run. 6.77864 % GC time.",
      "37,400 per second. 26.7 microseconds per run. 7.16 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,140 per second. 195 microseconds per run. 8.04 % GC time.",
      "5,220 per second. 192 microseconds per run. 8.22 % GC time.",
      "5,270 per second. 190 microseconds per run. 8.22 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "24,000 per second. 41.7 microseconds per run. 9.43811 % GC time.",
      "23,900 per second. 41.9 microseconds per run. 9.25815 % GC time.",
      "23,500 per second. 42.6 microseconds per run. 9.3 % GC time."
   ],
   "Win32Pool class>>winver":[
      "13,900 per second. 72.1 microseconds per run. 8.88 % GC time.",
      "13,700 per second. 73 microseconds per run. 8.58 % GC time.",
      "13,800 per second. 72.6 microseconds per run. 8.7 % GC time."
   ]
}

Am I reading this wrong, or is after worse than before?

Fabio


Best,
Marcel

Am 13.06.2020 11:01:53 schrieb [hidden email] <[hidden email]>:

A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.

Note that custom pragma parsers need to fulfill two requirements:
(1) method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
(2) method must declare to be called.
This is for the protection of the parser's (message) namespace."

+ | parserSelector |
- | parserSelector parserMethod |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."

+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].

+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
^ self pragmaStatementKeywords!






Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Compiler-mt.437.mcz

marcel.taeumel
Hi Fabio,

> ... so I was looking for a speedup.

Here is the speed up for the same idea (and improvement of that idea) for the Shout Parser:

vs.

Sorry for the confusion.

Best,
Marcel

Am 13.06.2020 12:43:19 schrieb Fabio Niephaus <[hidden email]>:



On Sat, 13 Jun 2020 at 12:41 pm, Marcel Taeumel <[hidden email]> wrote:
Hi Fabio!

Am I reading this wrong, or is after worse than before?

Huh? Of course it is a little bit worse. I am proposing an extension hook for pragma parsing here. :-) The goal is to make the overhead as thin as possible.

I was confused because the commit message says "Speed-up method-based hook...", so I was looking for a speedup.

Fabio


"=== BEFORE ===" means Compiler-mt.435 in Trunk.
"=== AFTER ===" means Compiler-mt.437 in Inbox but with the Hook enabled, which would allow me to extract FFI-specific parsing code to the FFI-Kernel package.

That's why my examples parse only some methods that have pragmas in them. There is no impact on parsing methods that do not have any pragmas.

Best,
Marcel

Am 13.06.2020 12:36:26 schrieb Fabio Niephaus <[hidden email]>:



On Sat, 13 Jun 2020 at 11:17 am, Marcel Taeumel <[hidden email]> wrote:
Hi all!

Here are some benchmarks. Same context as here:

=== BEFORE ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "39,800 per second. 25.1 microseconds per run. 7.5 % GC time.",
      "41,600 per second. 24 microseconds per run. 3.72 % GC time.",
      "40,800 per second. 24.5 microseconds per run. 3.92 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,610 per second. 178 microseconds per run. 2.26 % GC time.",
      "5,590 per second. 179 microseconds per run. 2.65947 % GC time.",
      "5,550 per second. 180 microseconds per run. 2.95941 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "25,800 per second. 38.7 microseconds per run. 2.9794 % GC time.",
      "25,800 per second. 38.8 microseconds per run. 3.19936 % GC time.",
      "26,000 per second. 38.5 microseconds per run. 3.14 % GC time."
   ],
   "Win32Pool class>>winver":[
      "16,100 per second. 62 microseconds per run. 3.65927 % GC time.",
      "16,200 per second. 61.7 microseconds per run. 3.66 % GC time.",
      "16,100 per second. 62 microseconds per run. 3.52 % GC time."
   ]
}

=== AFTER ===

{
   "FFITestLibrary>>ffiPrintString:":[
      "37,200 per second. 26.8 microseconds per run. 7.4785 % GC time.",
      "37,800 per second. 26.4 microseconds per run. 6.77864 % GC time.",
      "37,400 per second. 26.7 microseconds per run. 7.16 % GC time."
   ],
   "BitBlt>>copyBits":[
      "5,140 per second. 195 microseconds per run. 8.04 % GC time.",
      "5,220 per second. 192 microseconds per run. 8.22 % GC time.",
      "5,270 per second. 190 microseconds per run. 8.22 % GC time."
   ],
   "ExternalPoolReadWriter>>fetchFromFile":[
      "24,000 per second. 41.7 microseconds per run. 9.43811 % GC time.",
      "23,900 per second. 41.9 microseconds per run. 9.25815 % GC time.",
      "23,500 per second. 42.6 microseconds per run. 9.3 % GC time."
   ],
   "Win32Pool class>>winver":[
      "13,900 per second. 72.1 microseconds per run. 8.88 % GC time.",
      "13,700 per second. 73 microseconds per run. 8.58 % GC time.",
      "13,800 per second. 72.6 microseconds per run. 8.7 % GC time."
   ]
}

Am I reading this wrong, or is after worse than before?

Fabio


Best,
Marcel

Am 13.06.2020 11:01:53 schrieb [hidden email] <[hidden email]>:

A new version of Compiler was added to project The Inbox:
http://source.squeak.org/inbox/Compiler-mt.437.mcz

==================== Summary ====================

Name: Compiler-mt.437
Author: mt
Time: 13 June 2020, 11:01:44.448351 am
UUID: ca2e1da8-da26-a840-ae3e-1822ce8ba67d
Ancestors: Compiler-mt.436

Speed-up method-based hook for custom pragma-parsing methods. Like in ShoutCore-mt.79

=============== Diff against Compiler-mt.436 ===============

Item was changed:
----- Method: Parser>>pragmaStatement (in category 'pragmas') -----
pragmaStatement
"Read a single pragma statement. Dispatch to the first available pragma parser using the current token as a simple getter to be called on self. If no pragma parser can be found, parse it as usual in the keywords form.

Note that custom pragma parsers need to fulfill two requirements:
(1) method selector must match the current token as simple getter,
e.g., matches #apicall or matches #primitive
(2) method must declare to be called.
This is for the protection of the parser's (message) namespace."

+ | parserSelector |
- | parserSelector parserMethod |
(hereType = #keyword or: [ hereType = #word or: [ hereType = #binary ] ])
ifFalse: [ ^ self expected: 'pragma declaration' ].

+ (here last == $:
+ and: [(parserSelector := Symbol lookup: here allButLast) notNil])
+ ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."

+ ^ self pragmaStatementKeywords].
- (self class includesSelector: (parserSelector := here asSimpleGetter)) ifTrue: [
- ((parserMethod := self class compiledMethodAt: parserSelector) pragmas
- anySatisfy: [:pragma | pragma keyword == #pragmaParser])
- ifTrue: [^ self executeMethod: parserMethod]].

+ self class methodDict
+ at: parserSelector
+ ifPresent: [:parserMethod |
+ (parserMethod pragmas
+ anySatisfy: [:pragma | pragma keyword == #pragmaParser])
+ ifTrue: [^ self executeMethod: parserMethod]].
+
^ self pragmaStatementKeywords!