andreiformiga
2018-7-11 14:36:55

@greg I’ll try it and see, thanks for the info


andreiformiga
2018-7-11 14:38:08

the important point is that ideally the logging stuff should have no impact on performance when logging is turned off


samth
2018-7-11 14:40:54

If you just write (log-info E) then the cost when there’s no logging is (1) fetching the current-logger (2) checking if that logger is interested in messages at the 'info level


samth
2018-7-11 14:42:06

if you define your own logger with define-logger (which you probably should) then it’s just the cost of checking (2)


samth
2018-7-11 14:50:00

the latter seems to be about 15 nanoseconds


andreiformiga
2018-7-11 14:50:12

good to know


samth
2018-7-11 14:51:00

the former is about 3x as expensive


greg
2018-7-11 14:56:09

Wait what adding logging could increase my web app response times from approximately 20 msec to 20.00006 msec ??


samth
2018-7-11 14:57:07

that’s assuming the logs are not created and the expressions to be logged are not evaluated


greg
2018-7-11 14:58:00

Sorry I was kidding that it’s probably not going to be a significant cause of people visiting https://downforeveryoneorjustme.com/


andreiformiga
2018-7-11 15:01:10

the thing is there can be multiple logging calls per frame, so it may add up


andreiformiga
2018-7-11 15:02:35

the emulated Z80 runs at ~20MHz when executing “headless”, but when rendering and events are added it’s at ~7MHz right now in my machine. for a 3.58MHz system, the margin is getting tight


andreiformiga
2018-7-11 15:03:59

I thought about changing the emulation core to typed racket to see if it speeds up


soegaard2
2018-7-11 15:16:25

@andreiformiga Which system are you emulaing?


andreiformiga
2018-7-11 15:23:53

colecovision, but once it works there are many interesting systems which are very similar, like MSX1 computers


lexi.lambda
2018-7-11 15:26:53

If you are writing something for which performance of a tight loop is critical, to the point where the overhead of logging might be unpalatable, you could always write a small macro that allows you to enable and disable logging at compile-time, so that code compiled with logging disabled would exhibit no overhead whatsoever. The downside of this, of course, is that you have to recompile the whole system to switch logging on or off.


andreiformiga
2018-7-11 15:32:29

@lexi.lambda yes, that was my first thought regarding logging, and I hoped something like this would already exist :slightly_smiling_face:


lexi.lambda
2018-7-11 15:33:24

I think, as @greg alludes to, 15 nanoseconds is easily in the noise for most people’s purposes.


andreiformiga
2018-7-11 15:33:27

C++ people love to do stuff like that with templates, but it’s so painful


lexi.lambda
2018-7-11 15:33:58

Writing such a macro would also be pretty trivial, so it hardly needs to be a library!


lexi.lambda
2018-7-11 15:35:32

Just write something like (define-for-syntax logging-enabled? #t) (define-syntax when-logging-enabled (syntax-parser [(_ form ...) (if logging-enabled? #'(let () form ...) #'(void))]))


andreiformiga
2018-7-11 15:36:45

@lexi.lambda thanks


andreiformiga
2018-7-11 15:40:31

the define-for-syntax is something I was wondering about, how to define a variable for compile-time


lexi.lambda
2018-7-11 15:41:18

It’s a small shorthand for (begin-for-syntax (define logging-enabled? #t)).


notjack
2018-7-11 15:45:48

you could also test the current log level before the loop to avoid testing it repeatedly inside the loop


soegaard2
2018-7-11 17:35:46

@andreiformiga Nice project!


andreiformiga
2018-7-11 18:51:52

@soegaard2 I have an assembler (sexp-based, for now) & disassembler too… I hope to get together a kind of devkit


soegaard2
2018-7-11 18:55:06

They are must have when debugging emulators.


soegaard2
2018-7-11 18:56:05

Do you have any specific games you want running?


andreiformiga
2018-7-11 19:02:55

on the colecovision there are a few ports that seem interesting… actually I have never played a “real” one


andreiformiga
2018-7-11 19:03:16

on the MSX there are tons of interesting Konami games, some of which I played a long time ago


andreiformiga
2018-7-11 19:07:01

the CV is also almost the same hardware as the Sega SG–1000 and Sega Master System


soegaard2
2018-7-11 19:10:06

Is there a z80 in sega master system?


soegaard2
2018-7-11 19:10:31

yep


soegaard2
2018-7-11 19:11:10

For some reason (well c64 and zx spectrum) the msx machines never got popular here (denmark).


andreiformiga
2018-7-11 19:12:53

yes, unfortunately. this means that many european MSX games were ported from the Spectrum, which had poorer graphics


soegaard2
2018-7-11 19:13:43

Yeah, the spectrum is famous for its colour clashes.


soegaard2
2018-7-11 19:19:03

Btw - do you represent the status registers as a single variable or do you have a variable for each flag?


andreiformiga
2018-7-11 19:20:59

single variable, makes it easier to implement instructions that treat F as a register


soegaard2
2018-7-11 19:21:27

Consider splitting it. It’s a trick I picked up here: http://blargg.8bitalley.com/nes-emu/6502.html


soegaard2
2018-7-11 19:21:48

Most instructions test or set a single flag.


soegaard2
2018-7-11 19:22:04

So it is more important for those operations to be fast.


andreiformiga
2018-7-11 19:23:14

yeah I thought about it, I’ll try it some time, still much to do to get it right for now


andreiformiga
2018-7-11 19:26:32

the lazy calculation of flags is an interesting idea


andreiformiga
2018-7-11 19:26:57

I wish I had started with the 6502, so much simpler than the Z80


soegaard2
2018-7-11 19:28:05

Yeah, much smaller instruction set.


sean
2018-7-12 04:50:42

@sean has joined the channel