@greg I’ll try it and see, thanks for the info
the important point is that ideally the logging stuff should have no impact on performance when logging is turned off
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
if you define your own logger with define-logger
(which you probably should) then it’s just the cost of checking (2)
the latter seems to be about 15 nanoseconds
good to know
the former is about 3x as expensive
Wait what adding logging could increase my web app response times from approximately 20 msec to 20.00006 msec ??
that’s assuming the logs are not created and the expressions to be logged are not evaluated
Sorry I was kidding that it’s probably not going to be a significant cause of people visiting https://downforeveryoneorjustme.com/
the thing is there can be multiple logging calls per frame, so it may add up
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
I thought about changing the emulation core to typed racket to see if it speeds up
@andreiformiga Which system are you emulaing?
colecovision, but once it works there are many interesting systems which are very similar, like MSX1 computers
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.
@lexi.lambda yes, that was my first thought regarding logging, and I hoped something like this would already exist :slightly_smiling_face:
I think, as @greg alludes to, 15 nanoseconds is easily in the noise for most people’s purposes.
C++ people love to do stuff like that with templates, but it’s so painful
Writing such a macro would also be pretty trivial, so it hardly needs to be a library!
Just write something like (define-for-syntax logging-enabled? #t)
(define-syntax when-logging-enabled
(syntax-parser
[(_ form ...)
(if logging-enabled? #'(let () form ...) #'(void))]))
@lexi.lambda thanks
the define-for-syntax
is something I was wondering about, how to define a variable for compile-time
It’s a small shorthand for (begin-for-syntax (define logging-enabled? #t))
.
you could also test the current log level before the loop to avoid testing it repeatedly inside the loop
@andreiformiga Nice project!
@soegaard2 I have an assembler (sexp-based, for now) & disassembler too… I hope to get together a kind of devkit
They are must have when debugging emulators.
Do you have any specific games you want running?
on the colecovision there are a few ports that seem interesting… actually I have never played a “real” one
on the MSX there are tons of interesting Konami games, some of which I played a long time ago
the CV is also almost the same hardware as the Sega SG–1000 and Sega Master System
Is there a z80 in sega master system?
yep
For some reason (well c64 and zx spectrum) the msx machines never got popular here (denmark).
yes, unfortunately. this means that many european MSX games were ported from the Spectrum, which had poorer graphics
Yeah, the spectrum is famous for its colour clashes.
Btw - do you represent the status registers as a single variable or do you have a variable for each flag?
single variable, makes it easier to implement instructions that treat F as a register
Consider splitting it. It’s a trick I picked up here: http://blargg.8bitalley.com/nes-emu/6502.html
Most instructions test or set a single flag.
So it is more important for those operations to be fast.
yeah I thought about it, I’ll try it some time, still much to do to get it right for now
the lazy calculation of flags is an interesting idea
I wish I had started with the 6502, so much simpler than the Z80
Yeah, much smaller instruction set.
@sean has joined the channel